openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
.github/workflows/main.yml
60lines · modecode
| 1 | # This workflow is triggered on push to main, pull request, or by manual invocation. |
| 2 | # It builds and unit tests the codebase. |
| 3 | name: Build and Unit Test |
| 4 | |
| 5 | on: |
| 6 | workflow_dispatch: |
| 7 | push: |
| 8 | branches: |
| 9 | - main |
| 10 | pull_request: |
| 11 | types: [opened, reopened, synchronize] |
| 12 | |
| 13 | permissions: |
| 14 | contents: read |
| 15 | |
| 16 | jobs: |
| 17 | build: # Test, pack and publish the Open AI nuget package as a build artifact |
| 18 | name: Build |
| 19 | runs-on: ubuntu-latest |
| 20 | env: |
| 21 | version_suffix_args: ${{ format('/p:VersionSuffix="alpha.{0}"', github.run_number) }} |
| 22 | steps: |
| 23 | - name: Setup .NET 10 |
| 24 | uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 |
| 25 | with: |
| 26 | dotnet-version: '10.x' |
| 27 | |
| 28 | - name: Setup .NET 9 |
| 29 | uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 |
| 30 | with: |
| 31 | dotnet-version: '9.x' |
| 32 | |
| 33 | - name: Setup .NET 8 |
| 34 | uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 |
| 35 | with: |
| 36 | dotnet-version: '8.x' |
| 37 | |
| 38 | - name: Checkout code |
| 39 | uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 40 | |
| 41 | - name: Build and pack |
| 42 | run: dotnet pack |
| 43 | --configuration Release |
| 44 | --output "${{github.workspace}}/artifacts/packages" |
| 45 | ${{ env.version_suffix_args}} |
| 46 | |
| 47 | - name: Run unit tests |
| 48 | run: dotnet test |
| 49 | --configuration Release |
| 50 | --logger "trx;LogFilePrefix=smoke" |
| 51 | --results-directory ${{github.workspace}}/artifacts/test-results |
| 52 | ${{ env.version_suffix_args}} |
| 53 | -- NUnit.Where="cat == Smoke and cat != Manual" |
| 54 | |
| 55 | - name: Upload artifact |
| 56 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 |
| 57 | if: ${{ !cancelled() }} |
| 58 | with: |
| 59 | name: build-artifacts |
| 60 | path: ${{github.workspace}}/artifacts |