Skip to content

Commit 00b4655

Browse files
committed
ci: run sonar analysis on all branches
1 parent 30fdc92 commit 00b4655

1 file changed

Lines changed: 34 additions & 17 deletions

File tree

.github/workflows/build.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
name: Build
2+
23
on:
34
push:
4-
branches:
5-
- master
65
pull_request:
76
types: [opened, synchronize, reopened]
87

98
jobs:
109
build:
1110
name: Build
1211
runs-on: windows-latest
12+
1313
steps:
1414
- name: Set up JDK 17
15-
uses: actions/setup-java@v3
15+
uses: actions/setup-java@v5
1616
with:
17-
distribution: "temurin"
17+
distribution: temurin
1818
java-version: "17"
1919

20-
- uses: actions/checkout@v4
20+
- name: Checkout
21+
uses: actions/checkout@v6
2122
with:
2223
fetch-depth: 0
2324

2425
- name: Cache SonarQube packages
2526
uses: actions/cache@v4
2627
with:
27-
path: ~\sonar\cache
28+
path: ~\.sonar\cache
2829
key: ${{ runner.os }}-sonar
2930
restore-keys: ${{ runner.os }}-sonar
3031

@@ -38,34 +39,50 @@ jobs:
3839

3940
- name: Install SonarQube scanner
4041
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
41-
shell: powershell
42+
shell: pwsh
4243
run: |
43-
New-Item -Path .\.sonar\scanner -ItemType Directory
44+
New-Item -Path .\.sonar\scanner -ItemType Directory -Force
4445
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
4546
46-
- name: Start Analyze
47-
shell: powershell
47+
- name: Start analyze
48+
shell: pwsh
4849
env:
4950
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
50-
run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"danilrudin_Consyzer" /o:"danilrudin" /d:sonar.token=$env:SONAR_TOKEN /d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
51+
run: |
52+
$ErrorActionPreference = "Stop"
53+
$PSNativeCommandUseErrorActionPreference = $true
54+
55+
if ([string]::IsNullOrWhiteSpace($env:SONAR_TOKEN)) {
56+
throw "SONAR_TOKEN is empty or unavailable"
57+
}
58+
59+
.\.sonar\scanner\dotnet-sonarscanner begin `
60+
/k:"danilrudin_Consyzer" `
61+
/o:"danilrudin" `
62+
/d:sonar.token="$env:SONAR_TOKEN" `
63+
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
5164
5265
- name: Build
5366
run: dotnet build --configuration Release
5467

5568
- name: Unit Tests Executing
56-
run: dotnet test --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
69+
run: >
70+
dotnet test
71+
--configuration Release
72+
--collect:"XPlat Code Coverage"
73+
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
5774
58-
- name: End Analyze
59-
shell: powershell
75+
- name: End analyze
76+
shell: pwsh
6077
env:
6178
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
62-
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token=$env:SONAR_TOKEN
79+
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="$env:SONAR_TOKEN"
6380

6481
- name: Publish
6582
run: dotnet publish Consyzer/Consyzer.csproj -c Release -o _publish/Consyzer
6683

67-
- name: Upload Artifact
84+
- name: Upload artifact
6885
uses: actions/upload-artifact@v4
6986
with:
7087
name: Consyzer
71-
path: _publish/
88+
path: _publish/Consyzer

0 commit comments

Comments
 (0)