Skip to content

Commit ff1a37f

Browse files
authored
Merge pull request #22 from magic5644:feat-add-sonarqube-scan
Add SonarQube integration and enhance GitHub Actions for MacOS
2 parents 32954a7 + 9a0a307 commit ff1a37f

2 files changed

Lines changed: 50 additions & 2 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,51 @@ jobs:
3131
uses: actions/setup-dotnet@v4
3232
with:
3333
dotnet-version: ${{ matrix.dotnet.version }}
34+
35+
- name: Setup Java
36+
if: matrix.platform.name == 'MacOS'
37+
uses: actions/setup-java@v4
38+
with:
39+
distribution: 'zulu'
40+
java-version: '21'
41+
42+
- name: Cache SonarCloud packages
43+
if: matrix.platform.name == 'MacOS'
44+
uses: actions/cache@v4
45+
with:
46+
path: ~/sonar/cache
47+
key: ${{ runner.os }}-sonar
48+
restore-keys: ${{ runner.os }}-sonar
49+
50+
- name: Cache SonarCloud scanner
51+
if: matrix.platform.name == 'MacOS'
52+
id: cache-sonar-scanner
53+
uses: actions/cache@v4
54+
with:
55+
path: ./.sonar/scanner
56+
key: ${{ runner.os }}-sonar-scanner
57+
restore-keys: ${{ runner.os }}-sonar-scanner
58+
59+
- name: Install SonarCloud scanner
60+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' && matrix.platform.name == 'MacOS'
61+
shell: pwsh
62+
run: |
63+
dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
64+
3465
- name: Enforce SDK Version
3566
run: dotnet new globaljson --sdk-version ${{ steps.setup-dotnet.outputs.dotnet-version }} --force
36-
- name: Build
67+
68+
- name: build and analyze
69+
if: matrix.platform.name == 'MacOS'
70+
run: |
71+
dotnet restore
72+
dotnet tool update --global dotnet-coverage
73+
./.sonar/scanner/dotnet-sonarscanner begin /k:"magic5644_codeLineCounter" /o:"magic5644" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml /d:sonar.scanner.scanAll=false
74+
dotnet build --no-incremental
75+
dotnet-coverage collect 'dotnet test --no-build' -f xml -o 'coverage.xml'
76+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
77+
78+
- name: Build Release
3779
run: dotnet build -c Release
3880
- name: Test
3981
if: matrix.platform.name == 'MacOS'
@@ -45,7 +87,7 @@ jobs:
4587
reportgenerator -reports:test-result.cobertura.xml -targetdir:coverage-report -reporttypes:"Html;JsonSummary;MarkdownSummaryGithub;Badges"
4688
cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
4789
48-
- name: ReportGenerator
90+
- name: ReportGenerator_CoverageReport
4991
if: matrix.platform.name == 'MacOS'
5092
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.11
5193
with:
@@ -84,6 +126,8 @@ jobs:
84126
run: |
85127
echo "![Coverage](./coverage-report/badge_combined.svg)" > coverage-badge.md
86128
cat coverage-badge.md >> README.md
129+
130+
87131

88132
publish_badge:
89133
runs-on: ubuntu-24.04

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@
2020
/codeql*
2121
/*.dot
2222
/*snyk*
23+
24+
# Mac OS
25+
.DS_Store
26+
.AppleDouble

0 commit comments

Comments
 (0)