33
44name : .NET
55
6- on :
7- push :
8- branches : ["main"]
9- pull_request :
10- branches : ["main"]
6+ on : [push, pull_request]
7+
8+ env :
9+ DOTNET_CLI_TELEMETRY_OPTOUT : 1
1110
1211jobs :
1312
1413 build :
15- runs-on : ubuntu-latest
14+ name : ${{ matrix.platform.name }} ${{ matrix.dotnet.name }}
15+ runs-on : ${{ matrix.platform.os }}
16+ # runs-on: ubuntu-latest
17+
18+ strategy :
19+ fail-fast : false
20+ matrix :
21+ platform :
22+ - { name: Linux, os: ubuntu-24.04 }
23+ - { name: Windows, os: windows-2022 }
24+ - { name: macOS, os: macos-15 }
25+ dotnet :
26+ - { name: .NET 9, version: "9.0.x" }
1627
1728 steps :
1829 - uses : actions/checkout@v4
19- - name : Setup .NET
30+ - id : setup-dotnet
2031 uses : actions/setup-dotnet@v4
2132 with :
22- dotnet-version : 9.0.x
23- - name : Restore dependencies
24- run : dotnet restore
33+ dotnet-version : ${{ matrix.dotnet.version }}
34+ - name : Enforce SDK Version
35+ run : dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
2536 - name : Build
26- run : dotnet build --no-restore
27-
28- - run : dotnet test --results-directory "test-results" --collect:"Code Coverage"
29- - run : dotnet tool update --global dotnet-coverage
30- - run : dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura "test-results/**/*.coverage"
31- - run : dotnet tool install --global dotnet-reportgenerator-globaltool
32- - run : reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges"
33- - run : cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
37+ run : dotnet build -c Release
38+ - name : Test
39+ if : matrix.platform.name == 'MacOS'
40+ run : |
41+ dotnet test --results-directory "test-results" --collect:"Code Coverage"
42+ dotnet tool update --global dotnet-coverage
43+ dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura "test-results/**/*.coverage"
44+ dotnet tool install --global dotnet-reportgenerator-globaltool
45+ reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges"
46+ cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
3447
3548 - name : ReportGenerator
49+ if : matrix.platform.name == 'MacOS'
3650 uses : danielpalme/ReportGenerator-GitHub-Action@5.3.11
3751 with :
3852 reports : " test-result.cobertura.xml"
@@ -41,34 +55,38 @@ jobs:
4155
4256 - name : Upload coverage report artifact
4357 uses : actions/upload-artifact@v4
58+ if : matrix.platform.name == 'MacOS'
4459 with :
4560 name : coverage-report
4661 path : coverage-report
4762
4863 - name : Upload coverage badge artifact
4964 uses : actions/upload-artifact@v4
65+ if : matrix.platform.name == 'MacOS'
5066 with :
5167 name : coverage-badge.svg
5268 path : coverage-report/badge_combined.svg
5369
5470 - name : Add comment to PR
55- if : github.event_name == 'pull_request'
71+ if : github.event_name == 'pull_request' && matrix.platform.name == 'MacOS'
5672 run : gh pr comment $PR_NUMBER --body-file coverage-report/SummaryGithub.md
5773 env :
5874 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5975 PR_NUMBER : ${{ github.event.pull_request.number }}
6076
6177 - name : Publish coverage in build summary # Only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
78+ if : matrix.platform.name == 'MacOS'
6279 run : cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
6380 shell : bash
6481
6582 - name : Generate Coverage Badge
83+ if : matrix.platform.name == 'MacOS'
6684 run : |
6785 echo "" > coverage-badge.md
6886 cat coverage-badge.md >> README.md
6987
7088 publish_badge :
71- runs-on : ubuntu-latest
89+ runs-on : ubuntu-24.04
7290 needs : build
7391 steps :
7492 - name : Checkout gh-pages
0 commit comments