@@ -3,57 +3,122 @@ name: Continuous Integration
33on :
44 push :
55 branches :
6- - develop
6+ - main
77 paths-ignore :
8- - ' README.md'
9- - ' docs/**'
10- - ' .github/workflows/docs.yml'
11- - ' .github/workflows/release.yml'
8+ - " **.md"
9+ - " renovate.json"
10+ - " .github/ISSUE_TEMPLATE/**"
11+ - " .github/PULL_REQUEST_TEMPLATE/**"
12+ - " .github/workflows/docs.yml"
13+ - " .github/workflows/release.yml"
1214
1315 pull_request :
1416 paths-ignore :
15- - ' README.md'
16- - ' docs/**'
17- - ' .github/workflows/docs.yml'
18- - ' .github/workflows/release.yml'
19-
17+ - " **.md"
18+ - " renovate.json"
19+ - " .github/ISSUE_TEMPLATE/**"
20+ - " .github/PULL_REQUEST_TEMPLATE/**"
21+ - " .github/workflows/docs.yml"
22+ - " .github/workflows/release.yml"
2023concurrency :
2124 group : ${{ github.workflow }}-${{ github.ref }}
2225 cancel-in-progress : true
2326
2427jobs :
25- unit-tests :
26- name : Unit Tests
28+ test-and-analysis :
29+ name : Test & Analysis
2730 runs-on : ubuntu-latest
31+ timeout-minutes : 30
32+ permissions :
33+ contents : read
2834 env :
29- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
30- SONAR_ORGANIZATION : ${{ secrets.SONAR_ORGANIZATION }}
31- SONAR_PROJECT_KEY : ${{ secrets.SONAR_PROJECT_KEY }}
3235 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
36+ SONAR_ANALYSIS : true
3337
3438 steps :
35- - name : Checkout
36- uses : actions/checkout@v6
37- with :
38- fetch-depth : 0
39- show-progress : false
40- - name : Install .NET SDK
41- uses : actions/setup-dotnet@v5
42- with :
43- global-json-file : global.json
44- - name : NuGet Cache
45- uses : actions/cache@v5
46- with :
47- path : ~/.nuget/packages
48- key : ${{ runner.os}}-nuget-${{ hashFiles('**/packages.lock.json') }}
49- restore-keys : ${{ runner.os }}-nuget
50- - name : Test
51- run : ./build.sh Test
52- - name : Publish Test Results
53- if : always()
54- uses : dorny/test-reporter@v2
55- with :
56- name : Test Results
57- path : .nuke/temp/TestResults/*.trx
58- reporter : dotnet-trx
59- path-replace-backslashes : true
39+ - name : Checkout
40+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41+ with :
42+ fetch-depth : 0
43+ show-progress : false
44+
45+ - name : Setup .NET
46+ uses : actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
47+ with :
48+ global-json-file : global.json
49+ cache : true
50+ cache-dependency-path : ' **/Directory.Packages.props'
51+
52+ - name : Restore dependencies
53+ run : dotnet restore
54+
55+ - name : Install SonarCloud scanner
56+ if : github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
57+ run : dotnet tool update dotnet-sonarscanner --tool-path .sonar/scanner
58+
59+ - name : Begin SonarCloud analysis
60+ if : github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
61+ run : |
62+ .sonar/scanner/dotnet-sonarscanner begin \
63+ /k:"visus:AddressValidation" \
64+ /o:"visus" \
65+ /d:sonar.token="$SONAR_TOKEN" \
66+ /d:sonar.host.url="https://sonarcloud.io" \
67+ /d:sonar.cs.vscoveragexml.reportsPaths="**/TestResults/**/*.xml" \
68+ /d:sonar.cs.vstest.reportsPaths="**/TestResults/**/*.trx"
69+
70+ - name : Build
71+ run : dotnet build -c Release --no-restore
72+
73+ - name : Run tests
74+ run : |
75+ dotnet test -c Release --no-build --no-restore -- \
76+ --coverage \
77+ --coverage-output-format xml \
78+ --report-trx
79+
80+ - name : Upload test results
81+ if : always()
82+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
83+ with :
84+ name : test-results
85+ path : " **/TestResults/*.trx"
86+ retention-days : 1
87+
88+ - name : End SonarCloud analysis
89+ if : github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]'
90+ run : |
91+ .sonar/scanner/dotnet-sonarscanner end \
92+ /d:sonar.token="$SONAR_TOKEN"
93+
94+ publish-test-results :
95+ name : Publish Test Results
96+ runs-on : ubuntu-latest
97+ needs : test-and-analysis
98+ if : always()
99+ timeout-minutes : 10
100+ permissions :
101+ contents : read
102+ checks : write
103+ pull-requests : write
104+
105+ steps :
106+ - name : Checkout
107+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
108+ with :
109+ fetch-depth : 1
110+ show-progress : false
111+
112+ - name : Download test results
113+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
114+ with :
115+ name : test-results
116+ path : test-results
117+
118+ - name : Publish test results
119+ uses : dorny/test-reporter@df6247429542221bc30d46a036ee47af1102c451 # v2.7.0
120+ with :
121+ name : Test Results
122+ path : test-results/**/*.trx
123+ reporter : dotnet-trx
124+ fail-on-error : false
0 commit comments