Skip to content

Commit 3169480

Browse files
authored
Integrate SonarQube analysis in build (#5)
Extended the build pipeline by a SonarQube analysis and updated the README with build status, SonarQube project link and a missing tutorial link.
1 parent df8a634 commit 3169480

File tree

2 files changed

+62
-16
lines changed

2 files changed

+62
-16
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
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: Run SonarQube 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 }}"

README.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
1+
[![Build and analyze](https://github.com/HaGGi13/ConnyConsole/actions/workflows/build-connyconsole.yaml/badge.svg)](https://github.com/HaGGi13/ConnyConsole/actions/workflows/build-connyconsole.yaml)
2+
13
# ConnyConsole
24
ConnyConsole is a console CLI project that uses `System.CommandLine` from Microsoft for argument parsing to collect some experience with this library.
35

4-
Following some references/documentation:
6+
## References/documentation:
7+
Following are some used articles listed.
58
- [Parse the Command Line with System.CommandLine][1]
69
- [System.CommandLine overview][2]
710
- [System.CommandLine on GitHub][3]
811
- [Tutorial: Get started with System.CommandLine][4]
12+
- [A Beginner's Guide to .NET's HostBuilder: Part 1 and following][5]
13+
14+
<p align="center">
15+
<a href="https://sonarcloud.io/summary/new_code?id=HaGGi13_ConnyConsole">
16+
<img src="https://sonarcloud.io/images/project_badges/sonarcloud-light.svg" />
17+
</a>
18+
</p>
919

1020
<!--# references --->
1121
[1]: https://learn.microsoft.com/en-us/archive/msdn-magazine/2019/march/net-parse-the-command-line-with-system-commandline "Parse the Command Line with System.CommandLine"
1222
[2]: https://learn.microsoft.com/en-us/dotnet/standard/commandline/ "System.CommandLine overview"
1323
[3]: https://github.com/dotnet/command-line-api "GitHub: dotnet > command-line-api"
1424
[4]: https://learn.microsoft.com/en-us/dotnet/standard/commandline/get-started-tutorial "Tutorial: Get started with System.CommandLine"
25+
[5]: https://medium.com/@sawyer.watts/a-beginners-guide-to-net-s-hostbuilder-part-0-78882aab60f8

0 commit comments

Comments
 (0)