8
8
jobs :
9
9
build :
10
10
name : Build and analyze
11
- runs-on : windows -latest
11
+ runs-on : ubuntu -latest # <-- match OS of the artifacts producer
12
12
steps :
13
- - name : Set up JDK 17
14
- uses : actions/setup-java@v3
13
+ - uses : actions/checkout@v4
15
14
with :
16
- java-version : 17
17
- distribution : ' zulu'
18
- - uses : actions/checkout@v3
19
- with :
20
- fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
21
- - name : Cache SonarCloud packages
22
- uses : actions/cache@v3
15
+ fetch-depth : 0
16
+
17
+ - uses : actions/download-artifact@v4
23
18
with :
24
- path : ~\sonar\cache
25
- key : ${{ runner.os }}-sonar
26
- restore-keys : ${{ runner.os }}-sonar
19
+ name : test-artifacts
20
+ path : artifacts
27
21
28
- - name : Cache SonarCloud scanner
29
- id : cache-sonar-scanner
30
- uses : actions/cache@v3
22
+ - uses : actions/setup-dotnet@v4
31
23
with :
32
- path : .\.sonar\scanner
33
- key : ${{ runner.os }}-sonar-scanner
34
- restore-keys : ${{ runner.os }}-sonar-scanner
24
+ dotnet-version : 6.0.x
35
25
36
26
- name : Install SonarCloud scanner
37
- if : steps.cache-sonar-scanner.outputs.cache-hit != 'true'
38
- shell : powershell
39
- run : |
40
- New-Item -Path .\.sonar\scanner -ItemType Directory
41
- dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
27
+ run : dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner
42
28
43
- - name : Install Coverage tool
44
- shell : powershell
29
+ - name : Sonar begin
30
+ env :
31
+ SONAR_TOKEN : ${{ secrets.SONARCLOUD_TOKEN }}
45
32
run : |
46
- dotnet tool install --global dotnet-coverage
33
+ ./.sonar/scanner/dotnet-sonarscanner begin \
34
+ /k:"firebolt-db_firebolt-net-sdk" \
35
+ /o:"firebolt-db" \
36
+ /d:sonar.token="$SONAR_TOKEN" \
37
+ /d:sonar.host.url="https://sonarcloud.io" \
38
+ /d:sonar.cs.vscoveragexml.reportsPaths="artifacts/coverage/coverage.xml" \
39
+ /d:sonar.cs.vstest.reportsPaths="artifacts/**/*.trx"
40
+
41
+ # Sonar needs this step to collect the required information about the project
42
+ - name : Build
43
+ run : dotnet build --no-incremental
47
44
48
- - name : Build and analyze
45
+ - name : Sonar end
49
46
env :
50
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
51
47
SONAR_TOKEN : ${{ secrets.SONARCLOUD_TOKEN }}
52
- shell : powershell
53
- run : |
54
- .\.sonar\scanner\dotnet-sonarscanner begin /k:"firebolt-db_firebolt-net-sdk" /o:"firebolt-db" /d:sonar.token="${{ secrets.SONARCLOUD_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml"
55
- dotnet build --no-incremental
56
- dotnet-coverage collect 'dotnet test --filter "Category!=Integration"' -f xml -o "coverage.xml"
57
- .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONARCLOUD_TOKEN }}"
48
+ run : ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"
0 commit comments