Skip to content

Commit b9617d5

Browse files
authored
Add SonarQube analysis
1 parent df8a634 commit b9617d5

File tree

1 file changed

+50
-15
lines changed

1 file changed

+50
-15
lines changed
+50-15
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,69 @@
1-
name: Build ConnyConsole
2-
permissions:
3-
contents: read
4-
pull-requests: write
1+
name: Build and analyze ConnyConsole
52

63
on:
74
push:
8-
branches:
9-
- "develop"
10-
- "master"
11-
pull_request:
12-
branches:
13-
- "develop"
14-
- "master"
5+
branches: [develop, master]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
branches: [develop, master]
159
workflow_dispatch:
1610

11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
1715
env:
1816
solutionPath: './src/ConnyConsole.sln'
1917

2018
jobs:
2119
build:
22-
20+
name: Build and analyze
2321
runs-on: windows-latest
24-
2522
steps:
2623
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
2726
- name: Setup .NET
2827
uses: actions/setup-dotnet@v4
2928
with:
3029
dotnet-version: 9.0.x
31-
- name: Restore dependencies
30+
- name: Set up JDK 17
31+
uses: actions/setup-java@v4
32+
with:
33+
java-version: 17
34+
distribution: 'zulu'
35+
- name: Cache SonarQube Cloud packages
36+
uses: actions/cache@v4
37+
with:
38+
path: ~\sonar\cache
39+
key: ${{ runner.os }}-sonar
40+
restore-keys: ${{ runner.os }}-sonar
41+
- name: Cache SonarQube Cloud scanner
42+
id: cache-sonar-scanner
43+
uses: actions/cache@v4
44+
with:
45+
path: .\.sonar\scanner
46+
key: ${{ runner.os }}-sonar-scanner
47+
restore-keys: ${{ runner.os }}-sonar-scanner
48+
- name: Install SonarQube Cloud scanner
49+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
50+
shell: powershell
51+
run: |
52+
New-Item -Path .\.sonar\scanner -ItemType Directory
53+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
54+
- name: Restore ${{ env.solutionPath }} dependencies
3255
run: dotnet restore ${{ env.solutionPath }}
33-
- name: Build
56+
- name: Prepare SonarQube analyze
57+
env:
58+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
59+
shell: powershell
60+
run: |
61+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"HaGGi13_ConnyConsole" /o:"haggi13" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
62+
- name: Build ${{ env.solutionPath }}
3463
run: dotnet build --no-restore ${{ env.solutionPath }}
64+
- name: Build and analyze
65+
env:
66+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67+
shell: powershell
68+
run: |
69+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)