-
Notifications
You must be signed in to change notification settings - Fork 1
145 lines (140 loc) Β· 4.61 KB
/
scheduled-sonarcloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: "Scheduled SonarCloud"
on:
schedule:
- cron: '0 06 */7 * *'
jobs:
build-test:
name: "Build and Test"
runs-on: ubuntu-latest
steps:
###
# Checkout repository
###
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
###
# π§° Install .Net SDKs
#
# Configure the pipeline to use the correct .Net sdk versions
###
- name: π§° Install .Net SDKs
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
###
# π§° Setup .Net tools
#
# Register tools necessary to run the `test` pipeline-job
###
- name: π§° Setup .NET tools
run: |-
dotnet tool install --global dotnet-reportgenerator-globaltool
###
# π§° Setup SonarCloud scanner
#
# Installs and initializes the SonarCloud scanner
###
- name: π§° Setup SonarCloud scanner
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
[System.IO.Directory]::CreateDirectory('${{github.workspace}}/.sonar/scanner')
dotnet tool install dotnet-sonarscanner --tool-path '${{github.workspace}}/.sonar/scanner'
./.sonar/scanner/dotnet-sonarscanner begin
/k:"Marvin-Brouwer_FluentSerializer"
/o:"marvin-brouwer"
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/s:"${{github.workspace}}/SonarQube.Analysis.xml"
###
# π Restore dependencies
#
# Fill the NuGet store with necessary libraries
###
- name: π Restore dependencies
run: dotnet restore
###
# π Build
#
# Build the library code for later use
###
- name: π Build
run: dotnet build --no-restore --nologo --configuration "Release"
###
# π§ͺ Run unit tests
#
# Run the unit tests of category `UnitTest` and generate a code coverage report.
###
- name: π§ͺ Run unit tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--logger "trx;LogFileName=test-results.trx"
--collect "DotnetCodeCoverage"
--collect "XPlat Code coverage"
--results-directory:"${{github.workspace}}/test-results"
--filter:"Category=UnitTest"
/p:CollectCoverage="true"
/p:CoverletOutputFormat="opencover"
/p:CoverletOutput="${{github.workspace}}/test-results/coverage/"
/p:MergeWith="${{github.workspace}}/test-results/coverage/"
/p:Exclude="[*Tests]*%2c[*TestUtils]*%2c[*UseCase*]*"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
reportgenerator
-reports:"${{github.workspace}}/test-results/*/coverage.cobertura.xml"
-targetdir:"${{github.workspace}}/test-results/coverage"
-reporttypes:SonarQube;
working-directory: ${{github.workspace}}
###
# π§ͺ Run integration tests
#
# Run the unit tests of category `IntegrationTest` to verify the integration of various unit-tests.
###
- name: π§ͺ Run integration tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--filter:"Category=IntegrationTest"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
working-directory: ${{github.workspace}}
###
# π§ͺ Run use-case tests
#
# Run the unit tests of category `UseCase` to illustrate the library still works as intended.
# This is basically a kind of integration test.
###
- name: π§ͺ Run use-case tests
run: >-
dotnet test --verbosity:normal
--no-build --no-restore --nologo
--configuration="Release"
--logger:"console;verbosity=detailed"
--logger:"GitHubActions"
--filter:"Category=UseCase"
/clp:forceconsolecolor
"${{github.workspace}}/FluentSerializer.sln";
working-directory: ${{github.workspace}}
###
# π¬ Perform SonarCloud Analysis
###
- name: π¬ Perform SonarCloud Analysis
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >-
./.sonar/scanner/dotnet-sonarscanner end
/d:sonar.login="${{ secrets.SONAR_TOKEN }}"