Merge pull request #67 from feO2x/66-resolve-first-stryker-survivor-q… #164
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: Build and Test | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v7 | |
| - name: Set up .NET | |
| uses: actions/setup-dotnet@v6 | |
| with: | |
| global-json-file: ./global.json | |
| - name: Cache NuGet packages | |
| uses: ./.github/actions/cache-nuget | |
| - name: Restore dependencies | |
| run: dotnet restore ./Light.PortableResults.slnx /p:ContinuousIntegrationBuild=true | |
| - name: Build | |
| run: dotnet build ./Light.PortableResults.slnx --configuration Release --no-restore /p:ContinuousIntegrationBuild=true | |
| # Microsoft.Testing.Platform takes its own arguments after the `--` separator. | |
| # --coverage-settings needs an absolute path: each test app runs with its own | |
| # output directory as the working directory, so a relative path does not resolve. | |
| - name: Test | |
| run: > | |
| dotnet test ./Light.PortableResults.slnx | |
| --configuration Release | |
| --no-build | |
| -- | |
| --coverage | |
| --coverage-settings ${{ github.workspace }}/coverage.runsettings | |
| --coverage-output-format cobertura | |
| # Each test project writes TestResults/<guid>.cobertura.xml, so the reports are | |
| # matched by extension rather than by a fixed file name. | |
| - name: Merge coverage reports | |
| run: | | |
| dotnet tool install --global dotnet-reportgenerator-globaltool | |
| reportgenerator -reports:'**/*.cobertura.xml' -targetdir:./coverage-merged -reporttypes:Cobertura | |
| - name: Publish coverage summary | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: 'coverage-merged/Cobertura.xml' | |
| badge: true | |
| format: 'markdown' | |
| output: 'both' | |
| fail_below_min: true | |
| thresholds: '60 85' | |
| - name: Upload coverage results | |
| if: always() && github.event_name == 'pull_request' | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-results | |
| path: code-coverage-results.md | |
| - name: Test netstandard2.0 core asset | |
| run: > | |
| dotnet test ./tests/Light.PortableResults.Tests/Light.PortableResults.Tests.csproj | |
| --configuration Release | |
| -p:PortableResultsAssetTargetFramework=netstandard2.0 | |
| -p:ContinuousIntegrationBuild=true | |
| coverage-comment: | |
| if: always() && github.event_name == 'pull_request' | |
| needs: build-and-test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Download coverage results | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: coverage-results | |
| # Add Coverage PR Comment runs always to ensure the comment is updated | |
| - name: Add Coverage PR Comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| recreate: true | |
| path: code-coverage-results.md |