1313 - feature/ci
1414
1515jobs :
16-
17- build-debug :
18- strategy :
19- matrix :
20- os : [ubuntu-latest, windows-latest]
21- dotnet-version : [6.x, 7.x]
22-
23- defaults :
24- run :
25- working-directory : ./src
26-
27- runs-on : ${{ matrix.os }}
28-
29- steps :
30- - uses : actions/checkout@v3
31- - name : Setup dotNET
32- uses : actions/setup-dotnet@v3
33- with :
34- dotnet-version : ${{ matrix.dotnet-version }}
35- - name : Restore dependencies
36- run : dotnet restore
37- - name : Build
38- run : dotnet build --no-restore -c debug
3916
40- test-debug :
41-
42- needs : build-debug
43-
17+ build-and-test-debug :
18+ name : Build and test in Debug configuration
4419 strategy :
4520 matrix :
4621 os : [ubuntu-latest, windows-latest]
47- dotnet-version : [6.x, 7.x]
48-
22+ version : [6.x, 7.x]
4923 defaults :
5024 run :
5125 working-directory : ./src
52-
5326 runs-on : ${{ matrix.os }}
54-
5527 steps :
5628 - uses : actions/checkout@v3
5729 - name : Setup dotNET
5830 uses : actions/setup-dotnet@v3
5931 with :
60- dotnet-version : ${{ matrix.dotnet- version }}
32+ dotnet-version : ${{ matrix.version }}
6133 - name : Restore dependencies
6234 run : dotnet restore
6335 - name : Build
6436 run : dotnet build --no-restore -c Debug
6537 - name : Test
6638 run : dotnet test --no-build --verbosity normal
67-
39+
6840 build-and-test-release :
69-
70- needs : [build-debug, test-debug]
71-
41+ name : Build and test in Release configuration
42+ needs : build-and-test-debug
7243 defaults :
7344 run :
7445 working-directory : ./src
75-
76- runs-on : ubuntu-latest
77-
46+ runs-on : windows-latest
7847 steps :
7948 - uses : actions/checkout@v3
8049 - name : Setup dotNET
@@ -88,17 +57,62 @@ jobs:
8857 - name : Test
8958 run : dotnet test --no-build --verbosity normal
9059
60+ sonarcloud :
61+ name : Build and analyze with SonarCloud
62+ needs : build-and-test-release
63+ runs-on : windows-latest
64+ steps :
65+ - name : Set up JDK 11
66+ uses : actions/setup-java@v1
67+ with :
68+ java-version : 1.11
69+ - uses : actions/checkout@v3
70+ with :
71+ fetch-depth : 0 # Shallow clones should be disabled for a better relevancy of analysis
72+ - name : Cache SonarCloud packages
73+ uses : actions/cache@v1
74+ with :
75+ path : ~\sonar\cache
76+ key : ${{ runner.os }}-sonar
77+ restore-keys : ${{ runner.os }}-sonar
78+ - name : Cache SonarCloud scanner
79+ id : cache-sonar-scanner
80+ uses : actions/cache@v1
81+ with :
82+ path : .\.sonar\scanner
83+ key : ${{ runner.os }}-sonar-scanner
84+ restore-keys : ${{ runner.os }}-sonar-scanner
85+ - name : Setup dotNET
86+ uses : actions/setup-dotnet@v3
87+ with :
88+ dotnet-version : 7.x
89+ - name : Install SonarCloud scanner
90+ if : steps.cache-sonar-scanner.outputs.cache-hit != 'true'
91+ shell : powershell
92+ run : |
93+ New-Item -Path .\.sonar\scanner -ItemType Directory
94+ dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
95+ - name : Build and analyze
96+ env :
97+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
98+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
99+ shell : powershell
100+ run : |
101+ .\.sonar\scanner\dotnet-sonarscanner begin /k:"jjm-one_jjm.one.Serilog.Extensions.Logging.Helpers" /o:"jjm-one" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
102+ cd .\src
103+ dotnet restore
104+ dotnet build --no-restore
105+ .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
106+
91107 publish-nuget :
92-
93- needs : [build-and-test-release]
94-
95- defaults :
96- run :
97- working-directory : ./src
98-
108+ name : Publish the NuGet package
109+ needs : [build-and-test-debug, build-and-test-release, sonarcloud]
99110 runs-on : ubuntu-latest
100-
101111 steps :
112+ - name : Setup dotNET
113+ uses : actions/setup-dotnet@v3
114+ with :
115+ dotnet-version : 7.x
102116 - name : Publish the package to nuget.org
103117 run : |
104118 ls -la
0 commit comments