Skip to content

Commit 2bc5597

Browse files
committed
Sonar workflow updates
1 parent b8782e7 commit 2bc5597

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

.config/dotnet-tools.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,20 @@
88
"reportgenerator"
99
],
1010
"rollForward": false
11+
},
12+
"dotnet-coverage": {
13+
"version": "18.1.0",
14+
"commands": [
15+
"dotnet-coverage"
16+
],
17+
"rollForward": false
18+
},
19+
"dotnet-sonarscanner": {
20+
"version": "11.0.0",
21+
"commands": [
22+
"dotnet-sonarscanner"
23+
],
24+
"rollForward": false
1125
}
1226
}
1327
}

.github/workflows/sonar.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
- "src/**"
88
- "tests/**"
99
- "**/*.props"
10+
- "**/packages.lock.json"
11+
- ".config/dotnet-tools.json"
1012
- "global.json"
1113
- ".github/workflows/sonar.yml"
1214
pull_request:
@@ -15,6 +17,9 @@ on:
1517
paths:
1618
- "src/**"
1719
- "tests/**"
20+
- "**/*.props"
21+
- "**/packages.lock.json"
22+
- ".config/dotnet-tools.json"
1823
- "global.json"
1924
- ".github/workflows/sonar.yml"
2025
workflow_dispatch:
@@ -34,6 +39,8 @@ jobs:
3439
uses: actions/setup-dotnet@v5
3540
with:
3641
global-json-file: ./global.json
42+
cache: true
43+
cache-dependency-path: "**/packages.lock.json"
3744
- name: Set up JDK
3845
uses: actions/setup-java@v5
3946
with:
@@ -52,30 +59,25 @@ jobs:
5259
path: .\.sonar\scanner
5360
key: ${{ runner.os }}-sonar-scanner
5461
restore-keys: ${{ runner.os }}-sonar-scanner
55-
- name: Install SonarCloud scanner
56-
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
57-
shell: powershell
58-
run: |
59-
New-Item -Path .\.sonar\scanner -ItemType Directory
60-
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
61-
- name: Install dotnet-coverage tool
62-
run: |
63-
dotnet tool install --global dotnet-coverage
62+
- name: Install tools
63+
run: dotnet tool restore
6464
- name: Build and analyze with coverage
6565
env:
6666
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67+
USE_MOCK_SERVER: ${{ vars.USE_MOCK_SERVER }}
6768
shell: powershell
6869
run: |
69-
# Start SonarCloud analysis
7070
.\.sonar\scanner\dotnet-sonarscanner begin `
7171
/k:"Tsingis_bitcoin-web-api" `
7272
/o:"tsingis" `
73-
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" `
73+
/d:sonar.token="${{ env.SONAR_TOKEN }}" `
7474
/d:sonar.host.url="https://sonarcloud.io" `
7575
/d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" `
76-
/d:sonar.scanner.scanAll=false `
77-
/d:sonar.exclusions="global.json"
78-
dotnet build --no-incremental
79-
dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
76+
/d:sonar.scanner.scanAll=false
77+
78+
dotnet restore
79+
dotnet build --no-restore
80+
dotnet tool run dotnet-coverage collect "dotnet test --no-restore --no-build" -f xml -o "coverage.xml"
81+
8082
.\.sonar\scanner\dotnet-sonarscanner end `
81-
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
83+
/d:sonar.token="${{ env.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)