From 6692becb9fa94f09cadcc68ffc0e766c2066c1dd Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Mon, 15 Jul 2024 08:05:20 -0700 Subject: [PATCH 01/19] Add live testing to main and release --- .github/workflows/main.yml | 41 ++++++++++++++++++++------ .github/workflows/release.yml | 54 ++++++++++++++++++++++++++--------- 2 files changed, 73 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aacd2f6e0..113ada83f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,13 +28,11 @@ jobs: --output "${{github.workspace}}/artifacts/packages" ${{ env.version_suffix_args }} - - name: Test + - name: Unit Test run: dotnet test --configuration Release - --filter="TestCategory~${{ github.event_name == 'pull_request' && 'Offline' || 'Online' }}|TestCategory~Smoke" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + --filter="TestCategory=Smoke&TestCategory!=Manual" + --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" - name: Upload artifact uses: actions/upload-artifact@v2 @@ -42,19 +40,44 @@ jobs: name: build-artifacts path: ${{github.workspace}}/artifacts + test: + name: Live Tests + needs: build + runs-on: ubuntu-latest + environment: Live Testing + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.x + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Run Live Tests + run: dotnet test + --configuration Release + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/live.trx" + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + + deploy: + if: github.event_name != 'pull_request' + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v2 - name: NuGet Autenticate - if: github.event_name != 'pull_request' run: dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --name "github" --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text - - name: Publish - if: github.event_name != 'pull_request' run: dotnet nuget push - ${{github.workspace}}/artifacts/packages/*.nupkg + ${{github.workspace}}/build-artifacts/packages/*.nupkg --source "github" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59fb59f04..cbe876dff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,7 @@ on: types: [published] jobs: - deploy: + build: runs-on: ubuntu-latest permissions: packages: write @@ -24,28 +24,56 @@ jobs: /p:PackageProjectUrl="${{ github.server_url }}/${{ github.repository }}/tree/${{ github.event.release.tag_name }}" /p:PackageReleaseNotes="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md" - - name: Test + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: build-artifacts + path: ${{github.workspace}}/artifacts + + test: + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + environment: Live Testing + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.x' # SDK Version to use. + + # Pack the client nuget package and include url back to the repository and release tag + - name: Run Live Tests run: dotnet test --configuration Release - --filter="TestCategory~Online" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/full.trx" + --filter="TestCategory!=Smoke&TestCategory!=Image&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/live.trx" env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - # Append the nuget package to the github release that triggered this workflow - - name: Upload release asset - run: gh release upload ${{ github.event.release.tag_name }} - ${{github.workspace}}/artifacts/packages/*.*nupkg - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: build-artifacts + name: test-artifacts path: ${{github.workspace}}/artifacts - - name: Publish + deploy: + needs: test + runs-on: ubuntu-latest + permissions: + packages: write + contents: write + steps: + - uses: actions/download-artifact@v2 + + # Append the nuget package to the github release that triggered this workflow + - name: Upload release asset + run: gh release upload ${{ github.event.release.tag_name }} + ${{github.workspace}}/build-artifacts/packages/*.*nupkg + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish NuGet package run: dotnet nuget push ${{github.workspace}}/artifacts/packages/*.nupkg --source https://api.nuget.org/v3/index.json From 9d6792ce2cd9ad20a99b8ec033ad15c97e6aa256 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 23 Jul 2024 11:58:11 -0700 Subject: [PATCH 02/19] Add live tests to release and main --- .github/workflows/main.yml | 10 +++++++++- .github/workflows/release.yml | 34 ++++++++++++---------------------- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 113ada83f..552294ff6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,7 @@ on: jobs: build: # Test, pack and publish the Open AI nuget package as a build artifact + name: Build runs-on: ubuntu-latest env: version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} @@ -41,7 +42,7 @@ jobs: path: ${{github.workspace}}/artifacts test: - name: Live Tests + name: Live Test needs: build runs-on: ubuntu-latest environment: Live Testing @@ -62,7 +63,14 @@ jobs: env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: test-artifacts + path: ${{github.workspace}}/artifacts + deploy: + name: Publish Package if: github.event_name != 'pull_request' needs: build runs-on: ubuntu-latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cbe876dff..d28f5338a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,9 @@ on: jobs: build: + name: Build runs-on: ubuntu-latest + environment: Live Testing permissions: packages: write contents: write @@ -24,29 +26,16 @@ jobs: /p:PackageProjectUrl="${{ github.server_url }}/${{ github.repository }}/tree/${{ github.event.release.tag_name }}" /p:PackageReleaseNotes="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md" - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: build-artifacts - path: ${{github.workspace}}/artifacts - - test: - runs-on: ubuntu-latest - permissions: - packages: write - contents: write - environment: Live Testing - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v3 - with: - dotnet-version: '8.x' # SDK Version to use. + - name: Unit Test + run: dotnet test + --configuration Release + --filter="TestCategory=Smoke&TestCategory!=Manual" + --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" - # Pack the client nuget package and include url back to the repository and release tag - name: Run Live Tests run: dotnet test --configuration Release - --filter="TestCategory!=Smoke&TestCategory!=Image&TestCategory!=Moderations&TestCategory!=Manual" + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/live.trx" env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} @@ -54,11 +43,12 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 with: - name: test-artifacts + name: build-artifacts path: ${{github.workspace}}/artifacts deploy: - needs: test + name: Deploy + needs: build runs-on: ubuntu-latest permissions: packages: write @@ -66,7 +56,7 @@ jobs: steps: - uses: actions/download-artifact@v2 - # Append the nuget package to the github release that triggered this workflow + # Append the nuget package to the github release that triggered this workflow - name: Upload release asset run: gh release upload ${{ github.event.release.tag_name }} ${{github.workspace}}/build-artifacts/packages/*.*nupkg From ff541318c43669b225df9bf08bd98eb9574aca8a Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 23 Jul 2024 13:32:27 -0700 Subject: [PATCH 03/19] Use --results-directory parameter --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 552294ff6..0dbbb1e10 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,10 +33,12 @@ jobs: run: dotnet test --configuration Release --filter="TestCategory=Smoke&TestCategory!=Manual" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" + --logger "trx;LogFilePrefix=smoke" + --results-directory ${{github.workspace}}/artifacts/test-results - name: Upload artifact uses: actions/upload-artifact@v2 + if: ${{ !cancelled() }} with: name: build-artifacts path: ${{github.workspace}}/artifacts @@ -59,7 +61,8 @@ jobs: run: dotnet test --configuration Release --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/live.trx" + --logger "trx;LogFilePrefix=live" + --results-directory ${{github.workspace}}/artifacts/test-results env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} From 0f3c24f7e6ba1f0b1d31890e0c7691dde95ee154 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 23 Jul 2024 13:40:16 -0700 Subject: [PATCH 04/19] Add !cancelled() condition to all artifact uploads --- .github/workflows/main.yml | 1 + .github/workflows/release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0dbbb1e10..80d5a447a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -68,6 +68,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 + if: ${{ !cancelled() }} with: name: test-artifacts path: ${{github.workspace}}/artifacts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d28f5338a..4f52bd941 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v2 + if: ${{ !cancelled() }} with: name: build-artifacts path: ${{github.workspace}}/artifacts From 5844f2b6a6b11f2958393520beeed64162d13d1f Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 23 Jul 2024 15:06:58 -0700 Subject: [PATCH 05/19] Try workflow dispatch with args --- .github/actions/live-test/action.yml | 19 +++++++++++++++ .github/workflows/live-test.yml | 36 ++++++++++++++++++++++++++++ .github/workflows/main.yml | 14 +++++------ .github/workflows/release.yml | 9 +++---- 4 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 .github/actions/live-test/action.yml create mode 100644 .github/workflows/live-test.yml diff --git a/.github/actions/live-test/action.yml b/.github/actions/live-test/action.yml new file mode 100644 index 000000000..bde2139b8 --- /dev/null +++ b/.github/actions/live-test/action.yml @@ -0,0 +1,19 @@ +name: Live Test +description: 'Run live tests against the OpenAI API' +inputs: + openai_api_key: + description: 'API key for the OpenAI API' + required: true +runs: + using: 'composite' + steps: + - name: Run Live Tests + shell: pwsh + run: dotnet test + --configuration Release + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFilePrefix=live" + --results-directory ${{github.workspace}}/artifacts/test-results + env: + OPENAI_API_KEY: ${{ github.event.inputs.openai_api_key }} + diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml new file mode 100644 index 000000000..ee2f9dcf4 --- /dev/null +++ b/.github/workflows/live-test.yml @@ -0,0 +1,36 @@ +name: Live Test + +on: + workflow_dispatch: + inputs: + ref: + description: 'Committish to checkout and test' + required: true + +jobs: + test: + name: Live Test + runs-on: ubuntu-latest + environment: Live Testing + steps: + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 8.x + + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + + - name: Run Live Tests + uses: ./.github/actions/live-test + with: + openai_api_key: ${{ secrets.OPENAI_API_KEY }} + + - name: Upload artifact + uses: actions/upload-artifact@v2 + if: ${{ !cancelled() }} + with: + name: test-artifacts + path: ${{github.workspace}}/artifacts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 80d5a447a..5a5c6a580 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,6 +2,9 @@ name: Build and Test on: workflow_dispatch: + inputs: + commit_sha: + description: 'Commit SHA to checkout and test' push: branches: - main @@ -48,6 +51,7 @@ jobs: needs: build runs-on: ubuntu-latest environment: Live Testing + if: github.event_name != 'pull_request' steps: - name: Setup .NET uses: actions/setup-dotnet@v1 @@ -58,13 +62,9 @@ jobs: uses: actions/checkout@v2 - name: Run Live Tests - run: dotnet test - --configuration Release - --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" - --logger "trx;LogFilePrefix=live" - --results-directory ${{github.workspace}}/artifacts/test-results - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + uses: ./.github/actions/live-test + with: + openai_api_key: ${{ secrets.OPENAI_API_KEY }} - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f52bd941..8074d6962 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,12 +33,9 @@ jobs: --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" - name: Run Live Tests - run: dotnet test - --configuration Release - --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/live.trx" - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + uses: ./.github/actions/live-test + with: + openai_api_key: ${{ secrets.OPENAI_API_KEY }} - name: Upload artifact uses: actions/upload-artifact@v2 From fe81d68a509de807d26062e466da5c96cdb9b45e Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 23 Jul 2024 15:14:33 -0700 Subject: [PATCH 06/19] Remove action --- .github/actions/live-test/action.yml | 19 ------------------- .github/workflows/live-test.yml | 13 ++++++++----- .github/workflows/main.yml | 13 +++++++------ .github/workflows/release.yml | 10 +++++++--- 4 files changed, 22 insertions(+), 33 deletions(-) delete mode 100644 .github/actions/live-test/action.yml diff --git a/.github/actions/live-test/action.yml b/.github/actions/live-test/action.yml deleted file mode 100644 index bde2139b8..000000000 --- a/.github/actions/live-test/action.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Live Test -description: 'Run live tests against the OpenAI API' -inputs: - openai_api_key: - description: 'API key for the OpenAI API' - required: true -runs: - using: 'composite' - steps: - - name: Run Live Tests - shell: pwsh - run: dotnet test - --configuration Release - --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" - --logger "trx;LogFilePrefix=live" - --results-directory ${{github.workspace}}/artifacts/test-results - env: - OPENAI_API_KEY: ${{ github.event.inputs.openai_api_key }} - diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index ee2f9dcf4..ba922546e 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -5,7 +5,6 @@ on: inputs: ref: description: 'Committish to checkout and test' - required: true jobs: test: @@ -21,12 +20,16 @@ jobs: - name: Checkout code uses: actions/checkout@v2 with: - ref: ${{ github.event.inputs.ref }} + ref: ${{ github.event.inputs.ref || github.sha }} - name: Run Live Tests - uses: ./.github/actions/live-test - with: - openai_api_key: ${{ secrets.OPENAI_API_KEY }} + run: dotnet test + --configuration Release + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFilePrefix=live" + --results-directory ${{github.workspace}}/artifacts/test-results + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a5c6a580..f38ad3a15 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,9 +2,6 @@ name: Build and Test on: workflow_dispatch: - inputs: - commit_sha: - description: 'Commit SHA to checkout and test' push: branches: - main @@ -62,9 +59,13 @@ jobs: uses: actions/checkout@v2 - name: Run Live Tests - uses: ./.github/actions/live-test - with: - openai_api_key: ${{ secrets.OPENAI_API_KEY }} + run: dotnet test + --configuration Release + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFilePrefix=live" + --results-directory ${{github.workspace}}/artifacts/test-results + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Upload artifact uses: actions/upload-artifact@v2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8074d6962..a51eef2dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,9 +33,13 @@ jobs: --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" - name: Run Live Tests - uses: ./.github/actions/live-test - with: - openai_api_key: ${{ secrets.OPENAI_API_KEY }} + run: dotnet test + --configuration Release + --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" + --logger "trx;LogFilePrefix=live" + --results-directory ${{github.workspace}}/artifacts/test-results + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Upload artifact uses: actions/upload-artifact@v2 From e16af97ad5879f4a01d25c4fbc8e5389fb19315a Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Mon, 29 Jul 2024 11:01:56 -0700 Subject: [PATCH 07/19] Add push trigger --- .github/workflows/live-test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index ba922546e..a65b06832 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -1,6 +1,9 @@ name: Live Test on: + push: + branches: + - users/pahallis/environment workflow_dispatch: inputs: ref: From 88ac42c0b747c485637a653205d0b26b9a127daf Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Mon, 29 Jul 2024 11:03:01 -0700 Subject: [PATCH 08/19] Remove push trigger --- .github/workflows/live-test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index a65b06832..ba922546e 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -1,9 +1,6 @@ name: Live Test on: - push: - branches: - - users/pahallis/environment workflow_dispatch: inputs: ref: From 58574d5df6b13fa0450192192dd928f292c44981 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 13:14:25 -0700 Subject: [PATCH 09/19] Refactor worflows to support pr, ci, live-test, schedule, manual and release --- .github/workflows/live-test.yml | 6 ++++ .github/workflows/main.yml | 63 ++++++--------------------------- .github/workflows/release.yml | 48 +++++++++++++++++++------ 3 files changed, 53 insertions(+), 64 deletions(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index ba922546e..38fc9c9a8 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -1,8 +1,11 @@ +# This workflow is triggered by the user and runs the live tests on the codebase. name: Live Test on: workflow_dispatch: inputs: + # The user can specify the committish to checkout and test using the ref input. + # This is required because github UI only allows queuing runs for a branch or tag, not a specific commit or PR ref. ref: description: 'Committish to checkout and test' @@ -11,6 +14,8 @@ jobs: name: Live Test runs-on: ubuntu-latest environment: Live Testing + env: + version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} steps: - name: Setup .NET uses: actions/setup-dotnet@v1 @@ -28,6 +33,7 @@ jobs: --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" --logger "trx;LogFilePrefix=live" --results-directory ${{github.workspace}}/artifacts/test-results + ${{ env.version_suffix_args }} env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f38ad3a15..9ea0cecdf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,7 +1,14 @@ -name: Build and Test +# This worflow is triggered on push to main, pull request, or by manual invocation. +# It builds and unit tests the codebase. +name: Build and Unit Test on: workflow_dispatch: + inputs: + # The user can specify the committish to checkout and test using the ref input. + # This is required because github UI only allows queuing runs for a branch or tag, not a specific commit or PR ref. + ref: + description: 'Committish to checkout and test' push: branches: - main @@ -22,6 +29,8 @@ jobs: - name: Checkout code uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref || github.sha }} - name: Build and Pack run: dotnet pack @@ -42,55 +51,3 @@ jobs: with: name: build-artifacts path: ${{github.workspace}}/artifacts - - test: - name: Live Test - needs: build - runs-on: ubuntu-latest - environment: Live Testing - if: github.event_name != 'pull_request' - steps: - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 8.x - - - name: Checkout code - uses: actions/checkout@v2 - - - name: Run Live Tests - run: dotnet test - --configuration Release - --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" - --logger "trx;LogFilePrefix=live" - --results-directory ${{github.workspace}}/artifacts/test-results - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - - - name: Upload artifact - uses: actions/upload-artifact@v2 - if: ${{ !cancelled() }} - with: - name: test-artifacts - path: ${{github.workspace}}/artifacts - - deploy: - name: Publish Package - if: github.event_name != 'pull_request' - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v2 - - name: NuGet Autenticate - run: dotnet nuget add source - "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" - --name "github" - --username ${{ github.actor }} - --password ${{ secrets.GITHUB_TOKEN }} - --store-password-in-clear-text - - name: Publish - run: dotnet nuget push - ${{github.workspace}}/build-artifacts/packages/*.nupkg - --source "github" - --api-key ${{ secrets.GITHUB_TOKEN }} - --skip-duplicate diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a51eef2dd..6147b1229 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,23 @@ +# This workflow is triggered by new releases and on a daily schedule. +# It builds, unit tests, live tests and published the Open AI nuget package. +# For daily runs, the package is published to the GitHub package registry. +# For releases, the package is published to the NuGet package registry. name: Release package on: release: types: [published] + schedule: + # run every day at 00:00 + - cron: '0 0 * * *' jobs: build: name: Build runs-on: ubuntu-latest environment: Live Testing + env: + version_suffix_args: ${{ github.event_name == 'schedule' && format('--version-suffix="alpha.{0}"', github.run_number) || '' }} permissions: packages: write contents: write @@ -22,22 +31,25 @@ jobs: - name: Build and Pack run: dotnet pack --configuration Release - --output "${{github.workspace}}/artifacts/packages" + --output "${{ github.workspace }}/artifacts/packages" /p:PackageProjectUrl="${{ github.server_url }}/${{ github.repository }}/tree/${{ github.event.release.tag_name }}" /p:PackageReleaseNotes="${{ github.server_url }}/${{ github.repository }}/blob/${{ github.event.release.tag_name }}/CHANGELOG.md" + ${{ env.version_suffix_args }} - name: Unit Test run: dotnet test --configuration Release --filter="TestCategory=Smoke&TestCategory!=Manual" - --logger "trx;LogFileName=${{github.workspace}}/artifacts/test-results/smoke.trx" - + --logger "trx;LogFileName=${{ github.workspace }}/artifacts/test-results/smoke.trx" + ${{ env.version_suffix_args }} + - name: Run Live Tests run: dotnet test --configuration Release --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" --logger "trx;LogFilePrefix=live" - --results-directory ${{github.workspace}}/artifacts/test-results + --results-directory ${{ github.workspace }}/artifacts/test-results + ${{ env.version_suffix_args }} env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} @@ -46,28 +58,42 @@ jobs: if: ${{ !cancelled() }} with: name: build-artifacts - path: ${{github.workspace}}/artifacts + path: ${{ github.workspace }}/artifacts deploy: - name: Deploy + name: Publish Package needs: build + if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: packages: write contents: write + env: + NUGET_API_KEY: ${{ github.event_name == 'release' && secrets.NUGET_API_KEY || secrets.GITHUB_TOKEN }} + PUBLISH_TARGET: ${{ github.event_name == 'release' && 'https://api.nuget.org/v3/index.json' || 'github' }} steps: - uses: actions/download-artifact@v2 # Append the nuget package to the github release that triggered this workflow - name: Upload release asset + if: github.event_name == 'release' run: gh release upload ${{ github.event.release.tag_name }} - ${{github.workspace}}/build-artifacts/packages/*.*nupkg + ${{ github.workspace }}/build-artifacts/packages/*.*nupkg env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: NuGet Autenticate + if: github.event_name != 'release' + run: dotnet nuget add source + "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" + --name "github" + --username ${{ github.actor }} + --password ${{ secrets.GITHUB_TOKEN }} + --store-password-in-clear-text + - name: Publish NuGet package run: dotnet nuget push - ${{github.workspace}}/artifacts/packages/*.nupkg - --source https://api.nuget.org/v3/index.json - --api-key ${{ secrets.NUGET_API_KEY }} - --skip-duplicate + ${{github.workspace}}/build-artifacts/packages/*.nupkg + --source ${{ env.NUGET_API_KEY }} + --api-key ${{ env.NUGET_API_KEY }} + --skip-duplicate From 9da90a75fe66562eb93a0a11fbdb1809d07282dc Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 13:18:01 -0700 Subject: [PATCH 10/19] Better comment for live-test workflow --- .github/workflows/live-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index 38fc9c9a8..7783e9858 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -1,4 +1,4 @@ -# This workflow is triggered by the user and runs the live tests on the codebase. +# This workflow is triggered by the user and runs live tests on the codebase. name: Live Test on: From 37c5507c116c67cb5a88eb31131e081382e5eafe Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 13:58:38 -0700 Subject: [PATCH 11/19] Remove the ref parameter from manual runs of main --- .github/workflows/main.yml | 11 ++--------- .github/workflows/release.yml | 10 ++++++---- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ea0cecdf..c717416d1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,11 +4,6 @@ name: Build and Unit Test on: workflow_dispatch: - inputs: - # The user can specify the committish to checkout and test using the ref input. - # This is required because github UI only allows queuing runs for a branch or tag, not a specific commit or PR ref. - ref: - description: 'Committish to checkout and test' push: branches: - main @@ -23,14 +18,12 @@ jobs: version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} steps: - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.x + dotnet-version: '8.x' - name: Checkout code uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.ref || github.sha }} - name: Build and Pack run: dotnet pack diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6147b1229..a5d5f1127 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,13 @@ jobs: packages: write contents: write steps: - - uses: actions/checkout@v4 - - uses: actions/setup-dotnet@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v3 with: - dotnet-version: '8.x' # SDK Version to use. + dotnet-version: '8.x' + + - name: Checkout code + uses: actions/checkout@v2 # Pack the client nuget package and include url back to the repository and release tag - name: Build and Pack @@ -63,7 +66,6 @@ jobs: deploy: name: Publish Package needs: build - if: github.event_name != 'pull_request' runs-on: ubuntu-latest permissions: packages: write From 2e71fcb67e92fe71f93ff0e3acd1790ee8b66923 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:00:33 -0700 Subject: [PATCH 12/19] Fix source argument in nuget publish step --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5d5f1127..ef91d8ec5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,6 +96,6 @@ jobs: - name: Publish NuGet package run: dotnet nuget push ${{github.workspace}}/build-artifacts/packages/*.nupkg - --source ${{ env.NUGET_API_KEY }} + --source ${{ env.PUBLISH_TARGET }} --api-key ${{ env.NUGET_API_KEY }} --skip-duplicate From f31149afe034cce9a22aec7ab29bf9cedb5bd9de Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:33:44 -0700 Subject: [PATCH 13/19] Always publish to local feed in release pipeline --- .github/workflows/release.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef91d8ec5..41db6db44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,9 +70,6 @@ jobs: permissions: packages: write contents: write - env: - NUGET_API_KEY: ${{ github.event_name == 'release' && secrets.NUGET_API_KEY || secrets.GITHUB_TOKEN }} - PUBLISH_TARGET: ${{ github.event_name == 'release' && 'https://api.nuget.org/v3/index.json' || 'github' }} steps: - uses: actions/download-artifact@v2 @@ -85,7 +82,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: NuGet Autenticate - if: github.event_name != 'release' run: dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --name "github" @@ -93,9 +89,16 @@ jobs: --password ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text - - name: Publish NuGet package + - name: Publish package to local feed + run: dotnet nuget push + ${{github.workspace}}/build-artifacts/packages/*.nupkg + --source github + --skip-duplicate + + - name: Publish package to nuget.org + if: github.event_name == 'release' run: dotnet nuget push ${{github.workspace}}/build-artifacts/packages/*.nupkg - --source ${{ env.PUBLISH_TARGET }} - --api-key ${{ env.NUGET_API_KEY }} + --source https://api.nuget.org/v3/index.json + --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate From d11977fc0c943719ba76d969209242f3c2c3dfa2 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:38:06 -0700 Subject: [PATCH 14/19] Make step names more consistent --- .github/workflows/live-test.yml | 2 +- .github/workflows/main.yml | 4 ++-- .github/workflows/release.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index 7783e9858..243f4fc84 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -27,7 +27,7 @@ jobs: with: ref: ${{ github.event.inputs.ref || github.sha }} - - name: Run Live Tests + - name: Run live tests run: dotnet test --configuration Release --filter="TestCategory!=Smoke&TestCategory!=Images&TestCategory!=Moderations&TestCategory!=Manual" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c717416d1..b7d22414c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,13 +25,13 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Build and Pack + - name: Build and pack run: dotnet pack --configuration Release --output "${{github.workspace}}/artifacts/packages" ${{ env.version_suffix_args }} - - name: Unit Test + - name: Run unit tests run: dotnet test --configuration Release --filter="TestCategory=Smoke&TestCategory!=Manual" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 41db6db44..92ae8a1d3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,7 +81,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: NuGet Autenticate + - name: NuGet autenticate run: dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --name "github" From 82c22bd0c57502e52f26da8b3c2f78cea4866004 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Tue, 30 Jul 2024 14:46:28 -0700 Subject: [PATCH 15/19] Update .github/workflows/release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92ae8a1d3..e68bbd690 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -81,7 +81,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: NuGet autenticate + - name: NuGet authenticate run: dotnet nuget add source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" --name "github" From 854a6a03b176da32adb20841142872860f3fc8a9 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:55:13 -0700 Subject: [PATCH 16/19] Update .github/workflows/live-test.yml Co-authored-by: Wes Haggard --- .github/workflows/live-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index 243f4fc84..adb12b765 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -18,7 +18,7 @@ jobs: version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} steps: - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: dotnet-version: 8.x From e9598dd896c39c61e2b4e26746180204694e3fdc Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:54:08 -0700 Subject: [PATCH 17/19] Allow for queuing live tests throught PR label --- .github/workflows/live-test.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index adb12b765..0588f8bfb 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -3,16 +3,15 @@ name: Live Test on: workflow_dispatch: - inputs: - # The user can specify the committish to checkout and test using the ref input. - # This is required because github UI only allows queuing runs for a branch or tag, not a specific commit or PR ref. - ref: - description: 'Committish to checkout and test' + pull_request: + types: + - labeled jobs: test: name: Live Test runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Live Test') environment: Live Testing env: version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }} @@ -24,8 +23,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - with: - ref: ${{ github.event.inputs.ref || github.sha }} - name: Run live tests run: dotnet test From 52e9413054e5a2f43812e779601d033398d7dce9 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:56:05 -0700 Subject: [PATCH 18/19] Live trigger --- .github/workflows/live-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index 0588f8bfb..bebf2fe5e 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 8.x + dotnet-version: '8.x' - name: Checkout code uses: actions/checkout@v2 From c8d92785863242db7f5ecad44704625597dcb8c3 Mon Sep 17 00:00:00 2001 From: Patrick Hallisey Date: Tue, 30 Jul 2024 14:59:28 -0700 Subject: [PATCH 19/19] change casing on live test label --- .github/workflows/live-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/live-test.yml b/.github/workflows/live-test.yml index bebf2fe5e..db7837720 100644 --- a/.github/workflows/live-test.yml +++ b/.github/workflows/live-test.yml @@ -11,7 +11,7 @@ jobs: test: name: Live Test runs-on: ubuntu-latest - if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Live Test') + if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'live test') environment: Live Testing env: version_suffix_args: ${{ format('--version-suffix="alpha.{0}"', github.run_number) }}