Increase Code Coverage #131
Workflow file for this run
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] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'benchmarks/**' | |
| - 'tools/**' | |
| - '*.slnx' | |
| - '*.props' | |
| - 'global.json' | |
| - '.github/workflows/build-and-test.yml' | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'benchmarks/**' | |
| - 'tools/**' | |
| - '*.slnx' | |
| - '*.props' | |
| - 'global.json' | |
| - '.github/workflows/build-and-test.yml' | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-and-test: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| global-json-file: global.json | |
| - name: Restore dependencies | |
| run: dotnet restore ./Light.GuardClauses.slnx | |
| - name: Build | |
| run: dotnet build ./Light.GuardClauses.slnx -c Release --no-restore | |
| - name: Install ReportGenerator | |
| run: dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.5.10 | |
| - name: Test | |
| run: > | |
| dotnet test | |
| --solution ./Light.GuardClauses.slnx | |
| -c Release | |
| --no-build | |
| --no-restore | |
| --results-directory artifacts/test-results | |
| --coverage | |
| --coverage-output-format cobertura | |
| - name: Merge coverage | |
| if: always() | |
| run: > | |
| reportgenerator | |
| "-reports:artifacts/test-results/**/*.cobertura.xml" | |
| "-targetdir:artifacts/coverage" | |
| "-reporttypes:Cobertura;MarkdownSummaryGithub" | |
| - name: Create coverage summary | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: artifacts/coverage/Cobertura.xml | |
| format: markdown | |
| output: both | |
| badge: true | |
| thresholds: '60 85' | |
| - name: Store coverage summary | |
| run: mv code-coverage-results.md artifacts/coverage/code-coverage-results.md | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: artifacts/test-results | |
| if-no-files-found: warn | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-report | |
| path: artifacts/coverage | |
| if-no-files-found: warn | |
| coverage-comment: | |
| name: Coverage comment | |
| runs-on: ubuntu-latest | |
| needs: build-and-test | |
| if: > | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Download coverage report | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: artifacts/coverage | |
| - name: Update pull request comment | |
| uses: marocchino/sticky-pull-request-comment@v3.0.4 | |
| with: | |
| header: code-coverage | |
| path: artifacts/coverage/code-coverage-results.md |