# This workflow is triggered on push to main, pull request, or by manual invocation. # It builds and runs playback tests on the codebase. name: Build and run playback tests on: workflow_dispatch: push: branches: - main pull_request: types: [opened, reopened, synchronize] permissions: contents: read 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('/p:VersionSuffix="alpha.{0}"', github.run_number) }} steps: - name: Setup .NET 10 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: dotnet-version: '10.x' - name: Setup .NET 9 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: dotnet-version: '9.x' - name: Setup .NET 8 uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0 with: dotnet-version: '8.x' - name: Checkout code uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Build and pack run: dotnet pack --configuration Release --output "${{github.workspace}}/artifacts/packages" ${{ env.version_suffix_args}} - name: Restore tools run: dotnet tool restore --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json - name: Run tests in Playback mode run: dotnet test ./tests/OpenAI.Tests.csproj --configuration Release --logger "trx;LogFilePrefix=playback" --results-directory ${{ github.workspace }}/artifacts/test-results ${{ env.version_suffix_args }} env: CLIENTMODEL_TEST_MODE: Playback CLIENTMODEL_DISABLE_AUTO_RECORDING: true - name: Upload artifact uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 if: ${{ !cancelled() }} with: name: build-artifacts path: ${{github.workspace}}/artifacts