-
Notifications
You must be signed in to change notification settings - Fork 33
124 lines (120 loc) · 5.38 KB
/
continuous-integration.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
name: Continuous Integration
on: [push, pull_request]
env:
Configuration: Release
ContinuousIntegrationBuild: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
package:
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
fail-fast: false
runs-on: ${{ matrix.os }}
name: Build and run tests
steps:
- name: Checkout git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve cached NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
- name: Restore NuGet packages for Core
run: dotnet restore CoreTest/CoreTest.csproj --verbosity normal
- name: Build solution for Core
run: dotnet build CoreTest/CoreTest.csproj --verbosity normal
- name: Run tests for Core
run: dotnet test CoreTest/CoreTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html"
- name: Restore NuGet packages for PixelCanvas
run: dotnet restore PixelCanvasTest/PixelCanvasTest.csproj --verbosity normal
- name: Build solution for PixelCanvas
run: dotnet build PixelCanvasTest/PixelCanvasTest.csproj --verbosity normal
- name: Run tests for PixelCanvas
run: dotnet test PixelCanvasTest/PixelCanvasTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html"
- name: Restore NuGet packages for Windows
run: dotnet restore WindowsTest/WindowsTest.csproj --verbosity normal
if: startsWith(matrix.os,'windows')
- name: Build solution for Windows
run: dotnet build WindowsTest/WindowsTest.csproj --verbosity normal
if: startsWith(matrix.os,'windows')
- name: Run tests for Windows
run: dotnet test WindowsTest/WindowsTest.csproj --no-build --verbosity normal --logger:"html;LogFileName=../../TestResults-${{ runner.os }}.html"
if: startsWith(matrix.os,'windows')
- name: Upload received files from failing tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: Received-${{ runner.os }}
path: "**/*.received.*"
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: TestResults-${{ runner.os }}
path: TestResults-${{ runner.os }}.html
- name: Create and validate NuGet package for Core
run: dotnet pack --no-build --verbosity normal Core/Core.csproj
if: startsWith(matrix.os,'windows')
- name: Create and validate NuGet package for PixelCanvas
run: dotnet pack --no-build --verbosity normal PixelCanvas/PixelCanvas.csproj
if: startsWith(matrix.os,'windows')
- name: Create and validate NuGet package for Windows
run: dotnet pack --no-build --verbosity normal WindowsTest/WindowsTest.csproj
if: startsWith(matrix.os,'windows')
- name: Set up JDK 17 (for SonarQube)
if: startsWith(matrix.os,'windows')
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu'
- name: Cache SonarCloud packages
if: startsWith(matrix.os,'windows')
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
if: startsWith(matrix.os,'windows')
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: startsWith(matrix.os,'windows') && steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Cache dotnet-coverage
if: startsWith(matrix.os,'windows')
id: cache-dotnet-coverage
uses: actions/cache@v4
with:
path: .\.dotnet-coverage
key: ${{ runner.os }}-dotnet-coverage
restore-keys: ${{ runner.os }}-dotnet-coverage
- name: Install dotnet-coverage
if: startsWith(matrix.os,'windows') && steps.cache-dotnet-coverage.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.dotnet-coverage -ItemType Directory
dotnet tool update dotnet-coverage --tool-path .\.dotnet-coverage
- name: Build and analyze
if: startsWith(matrix.os,'windows')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
dotnet clean
.\.sonar\scanner\dotnet-sonarscanner begin /k:"manuelbl_SwissQRBill.NET" /o:"manuelbl-github" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build --no-incremental
.\.dotnet-coverage\dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"