chore(ci): Separate PR and Release automations #5
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: PR | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_NOLOGO: true | |
| jobs: | |
| check: | |
| name: Check | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: read | |
| outputs: | |
| has_test_results: ${{ steps.upload-test.outputs.artifact-id != '' }} | |
| has_coverage: ${{ steps.upload-coverage.outputs.artifact-id != '' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Setup .NET Core SDK | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| global-json-file: global.json | |
| cache: 'true' | |
| cache-dependency-path: '**/packages.lock.json' | |
| - name: Restore .NET Packages | |
| run: dotnet restore --locked-mode | |
| - name: Build .NET Solution | |
| run: dotnet build --configuration Release --no-restore | |
| - name: Test .NET Solution | |
| run: | | |
| dotnet test \ | |
| --configuration Release \ | |
| --no-restore \ | |
| --collect "XPlat Code Coverage" \ | |
| --logger "junit;LogFileName={assembly}-{framework}-result.xml;MethodFormat=Class;FailureBodyFormat=Verbose" \ | |
| --results-directory test-results | |
| - name: Upload Test Results | |
| id: upload-test | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: test | |
| path: | | |
| test-results/ | |
| !test-results/**/coverage.cobertura.xml | |
| - name: Upload Coverage Results | |
| id: upload-coverage | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: coverage | |
| path: test-results/**/coverage.cobertura.xml | |
| test-report: | |
| name: Test Report | |
| runs-on: ubuntu-latest | |
| needs: check | |
| if: needs.check.outputs.has_test_results == 'true' | |
| permissions: | |
| checks: write | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Download Test Artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: test | |
| - name: Generate Test Result Report(s) | |
| uses: EnricoMi/publish-unit-test-result-action@v2 | |
| if: always() | |
| with: | |
| files: | | |
| **/*.xml | |
| coverage-report: | |
| name: Coverage Report | |
| runs-on: ubuntu-latest | |
| needs: check | |
| if: needs.check.outputs.has_coverage == 'true' | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Download Coverage Artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: coverage | |
| - name: Code Coverage Summary Report | |
| uses: irongut/CodeCoverageSummary@v1.3.0 | |
| with: | |
| filename: '**/coverage.cobertura.xml' | |
| badge: true | |
| format: 'markdown' | |
| output: 'both' | |
| - name: Add Coverage PR Comment | |
| uses: marocchino/sticky-pull-request-comment@v2 | |
| with: | |
| recreate: true | |
| path: code-coverage-results.md | |
| - name: Write to Job Summary | |
| run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY |