@@ -33,22 +33,19 @@ jobs:
3333 dotnet-version : ${{ matrix.dotnet.version }}
3434
3535 - name : Setup Java
36- if : matrix.platform.name == 'MacOS'
3736 uses : actions/setup-java@v4
3837 with :
3938 distribution : ' zulu'
4039 java-version : ' 21'
4140
4241 - name : Cache SonarCloud packages
43- if : matrix.platform.name == 'MacOS'
4442 uses : actions/cache@v4
4543 with :
4644 path : ~/sonar/cache
4745 key : ${{ runner.os }}-sonar
4846 restore-keys : ${{ runner.os }}-sonar
4947
5048 - name : Cache SonarCloud scanner
51- if : matrix.platform.name == 'MacOS'
5249 id : cache-sonar-scanner
5350 uses : actions/cache@v4
5451 with :
5754 restore-keys : ${{ runner.os }}-sonar-scanner
5855
5956 - name : Install SonarCloud scanner
60- if : steps.cache-sonar-scanner.outputs.cache-hit != 'true' && matrix.platform.name == 'MacOS'
57+ if : steps.cache-sonar-scanner.outputs.cache-hit != 'true'
6158 shell : pwsh
6259 run : |
6360 dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
6663 run : dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
6764
6865 - name : build and analyze
69- if : matrix.platform.name == 'MacOS'
7066 shell : pwsh
7167 run : |
7268 dotnet tool install --global dotnet-coverage
7571 dotnet build --no-incremental
7672 dotnet-coverage collect 'dotnet test --no-build --results-directory "test-results" --collect:"Code Coverage"' -f xml -o 'coverage.xml'
7773 dotnet-coverage merge --output coverage.xml --output-format xml "test-results/**/*.coverage"
78- ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
79-
80- - name : Build Release
81- run : dotnet build -c Release
82- - name : Test
83- if : matrix.platform.name == 'MacOS'
84- run : |
85- dotnet test --results-directory "test-results" --collect:"Code Coverage"
86- dotnet tool update --global dotnet-coverage
87- dotnet-coverage merge --output test-result.cobertura.xml --output-format cobertura "test-results/**/*.coverage"
88- dotnet tool install --global dotnet-reportgenerator-globaltool
89- reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges"
90- cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
91-
92- - name : ReportGenerator_CoverageReport
93- if : matrix.platform.name == 'MacOS'
94- uses : danielpalme/ReportGenerator-GitHub-Action@5.3.11
95- with :
96- reports : " test-result.cobertura.xml"
97- targetdir : " coverage-report"
98- reporttypes : " Html;JsonSummary;MarkdownSummaryGithub;Badges"
99-
100- - name : Upload coverage report artifact
101- uses : actions/upload-artifact@v4
102- if : matrix.platform.name == 'MacOS'
103- with :
104- name : coverage-report
105- path : coverage-report
106-
107- - name : Upload coverage badge artifact
108- uses : actions/upload-artifact@v4
109- if : matrix.platform.name == 'MacOS'
110- with :
111- name : coverage-badge.svg
112- path : coverage-report/badge_combined.svg
113-
114- - name : Add comment to PR
115- if : github.event_name == 'pull_request' && matrix.platform.name == 'MacOS'
116- run : gh pr comment $PR_NUMBER --body-file coverage-report/SummaryGithub.md
117- env :
118- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119- PR_NUMBER : ${{ github.event.pull_request.number }}
120-
121- - name : Publish coverage in build summary # Only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
122- if : matrix.platform.name == 'MacOS'
123- run : cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
124- shell : bash
125-
126- - name : Generate Coverage Badge
127- if : matrix.platform.name == 'MacOS'
128- run : |
129- echo "" > coverage-badge.md
130- cat coverage-badge.md >> README.md
131-
132-
133-
134- publish_badge :
135- runs-on : ubuntu-24.04
136- needs : build
137- steps :
138- - name : Checkout gh-pages
139- uses : actions/checkout@v4
140- with :
141- token : ${{ secrets.GH_PAT }}
142- repository : " magic5644/magic5644"
143- ref : gh-pages
144-
145- - name : download badge
146- uses : actions/download-artifact@v4
147- with :
148- name : coverage-badge.svg
149- path : coverage-report/badge_combined.svg
150-
151- - name : Deploy Badges
152- uses : stefanzweifel/git-auto-commit-action@v5
153- with :
154- commit_message : " Update badges [skip ci]"
155- branch : gh-pages
156- skip_fetch : true
157- skip_checkout : true
158- file_pattern : " *.svg"
74+ ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
0 commit comments