Experimental: Update to Microsoft Testing Platform v2 #451
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Steeltoe.All | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - '[0-9]+.x' | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| STEELTOE_MACOS_DIAGNOSE_HOSTNAME_LOOKUP: true | |
| DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
| DOTNET_NOLOGO: true | |
| SOLUTION_FILE: 'src/Steeltoe.All.sln' | |
| TEST_OUTPUT_DIRECTORY: '${{ github.workspace }}/TestOutput' | |
| COMMON_TEST_ARGS: >- | |
| --no-build --no-progress --configuration Release --results-directory '${{ github.workspace }}/TestOutput' | |
| --report-trx --coverage --coverage-settings coverage.config --crashdump --hangdump --hangdump-timeout 1m | |
| jobs: | |
| analyze: | |
| name: Build and Test | |
| timeout-minutes: 60 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| include: | |
| - os: ubuntu-latest | |
| runDockerContainers: true | |
| - os: windows-latest | |
| skipIntegrationTests: true | |
| - os: macos-latest | |
| skipIntegrationTests: true | |
| runs-on: ${{ matrix.os }} | |
| continue-on-error: true | |
| services: | |
| eurekaServer: | |
| image: ${{ matrix.runDockerContainers && 'steeltoe.azurecr.io/eureka-server' || null }} | |
| ports: | |
| - 8761:8761 | |
| configServer: | |
| image: ${{ matrix.runDockerContainers && 'steeltoe.azurecr.io/config-server' || null }} | |
| env: | |
| eureka.client.enabled: true | |
| eureka.client.serviceUrl.defaultZone: http://eurekaServer:8761/eureka | |
| eureka.instance.hostname: localhost | |
| eureka.instance.instanceId: localhost:configServer:8888 | |
| ports: | |
| - 8888:8888 | |
| steps: | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: | | |
| 8.0.* | |
| 9.0.* | |
| 10.0.* | |
| - name: Turn off dev certificate (macOS only) | |
| if: ${{ matrix.os == 'macos-latest' }} | |
| # Setting DOTNET_GENERATE_ASPNET_CERTIFICATE to "false" makes it easier to determine which test failed on macOS when it tried to start a web server with https enabled. | |
| # Without setting this, the following message appears in the logs: | |
| # The application is trying to access the ASP.NET Core developer certificate key. A prompt might appear to ask for permission to access the key. | |
| # When that happens, select 'Always Allow' to grant 'dotnet' access to the certificate key in the future. | |
| # and the test run fails, but without indicating which test caused it. By setting this, the causing test fails with the next message: | |
| # Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. | |
| # To prevent the causing test from failing the test run, disable it on macOS using FactSkippedOnPlatform/TheorySkippedOnPlatform. | |
| shell: bash | |
| run: echo "DOTNET_GENERATE_ASPNET_CERTIFICATE=false" >> $GITHUB_ENV | |
| - name: Git checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Restore packages | |
| run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release --verbosity minimal | |
| - name: Build solution | |
| run: dotnet build ${{ env.SOLUTION_FILE }} --no-restore --configuration Release --verbosity minimal | |
| - name: Test | |
| run: dotnet test --solution ${{ env.SOLUTION_FILE }} --filter-query "${{ matrix.skipIntegrationTests == true && '/[(Category!=MemoryDumps)&(Category!=Integration)]' || '/[Category!=MemoryDumps]' }}" ${{ env.COMMON_TEST_ARGS }} | |
| - name: Test (memory dumps) | |
| run: dotnet test --project src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj --filter-trait "Category=MemoryDumps" ${{ env.COMMON_TEST_ARGS }} | |
| - name: Upload crash/hang dumps (on failure) | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: FailedTestOutput-${{ matrix.os }} | |
| path: | | |
| ${{ env.TEST_OUTPUT_DIRECTORY }}/*.dmp | |
| ${{ env.TEST_OUTPUT_DIRECTORY }}/Sequence_*.xml | |
| if-no-files-found: ignore | |
| - name: Report test results | |
| if: ${{ !cancelled() }} | |
| uses: dorny/test-reporter@v2 | |
| with: | |
| name: ${{ matrix.os }} test results | |
| reporter: dotnet-trx | |
| path: '${{ env.TEST_OUTPUT_DIRECTORY }}/*.trx' | |
| path-replace-backslashes: true | |
| fail-on-empty: 'true' | |
| fail-on-error: 'false' | |
| - name: Generate code coverage report | |
| uses: danielpalme/ReportGenerator-GitHub-Action@v5 | |
| with: | |
| reports: '${{ env.TEST_OUTPUT_DIRECTORY }}/*cobertura.xml' | |
| targetdir: 'coveragereport' | |
| reporttypes: 'MarkdownAssembliesSummary;MarkdownSummaryGithub' | |
| filefilters: '-*.g.cs' | |
| title: 'All Code Coverage (${{ matrix.os }})' | |
| tag: '${{ github.run_number }}_${{ github.run_id }}' | |
| - name: Add coverage to build summary | |
| shell: bash | |
| run: cat coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY | |
| - name: Add coverage comment to PR (linux only) | |
| if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' }} | |
| run: gh pr comment $PR_NUMBER --edit-last --create-if-none --body-file coveragereport/Summary.md | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_NUMBER: ${{ github.event.number }} |