Skip to content

Commit c66ba11

Browse files
fix: FIR-48856 fix sonar (#136)
1 parent df29353 commit c66ba11

File tree

3 files changed

+42
-38
lines changed

3 files changed

+42
-38
lines changed

.github/workflows/pull-request.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check title name convention
12-
uses: jef/conventional-commits-pr-action@v1.0.0
12+
uses: firebolt-db/action-pr-checks@519d59493b028e944971deaeca570933c378f09e
1313
with:
14-
token: ${{ secrets.GITHUB_TOKEN }}
14+
github-key: ${{ secrets.GITHUB_TOKEN }}
1515
build:
1616
uses: ./.github/workflows/build.yml
1717
code-checkers:
@@ -20,5 +20,6 @@ jobs:
2020
uses: ./.github/workflows/unit-tests.yml
2121
sonar-scan:
2222
uses: ./.github/workflows/sonar-scan.yml
23+
needs: [build, unit-tests]
2324
secrets:
2425
SONARCLOUD_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}

.github/workflows/sonar-scan.yml

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,41 @@ on:
88
jobs:
99
build:
1010
name: Build and analyze
11-
runs-on: windows-latest
11+
runs-on: ubuntu-latest # <-- match OS of the artifacts producer
1212
steps:
13-
- name: Set up JDK 17
14-
uses: actions/setup-java@v3
13+
- uses: actions/checkout@v4
1514
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
2318
with:
24-
path: ~\sonar\cache
25-
key: ${{ runner.os }}-sonar
26-
restore-keys: ${{ runner.os }}-sonar
19+
name: test-artifacts
20+
path: artifacts
2721

28-
- name: Cache SonarCloud scanner
29-
id: cache-sonar-scanner
30-
uses: actions/cache@v3
22+
- uses: actions/setup-dotnet@v4
3123
with:
32-
path: .\.sonar\scanner
33-
key: ${{ runner.os }}-sonar-scanner
34-
restore-keys: ${{ runner.os }}-sonar-scanner
24+
dotnet-version: 6.0.x
3525

3626
- 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
4228

43-
- name: Install Coverage tool
44-
shell: powershell
29+
- name: Sonar begin
30+
env:
31+
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
4532
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
4744

48-
- name: Build and analyze
45+
- name: Sonar end
4946
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
5147
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"

.github/workflows/unit-tests.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,22 @@ jobs:
2626
run: |
2727
dotnet new globaljson --sdk-version '${{ steps.dotnet-setup.outputs.dotnet-version }}'
2828
29+
- name: Install coverage tool
30+
run: dotnet tool install --global dotnet-coverage --version 17.12.6
31+
2932
- name: Install dependencies
3033
run: |
3134
dotnet restore
3235
3336
- name: Run unit tests
3437
run: |
35-
dotnet test --filter "Category!=Integration"
38+
mkdir -p coverage
39+
dotnet-coverage collect 'dotnet test --filter "Category!=Integration" --logger trx' -f xml -o "coverage/coverage.xml"
40+
41+
- name: Upload test artifacts
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: test-artifacts
45+
path: |
46+
**/TestResults/*.trx
47+
coverage/coverage.xml

0 commit comments

Comments
 (0)