-
Notifications
You must be signed in to change notification settings - Fork 12
251 lines (248 loc) · 9.39 KB
/
dotnet.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: CI
on:
workflow_dispatch:
inputs:
build_configuration:
type: choice
description: Build configuration
options:
- Debug
- Release
required: true
default: 'Debug'
run_build:
type: boolean
description: Run build
required: true
default: true
run_tests:
type: boolean
description: Run tests
required: true
default: true
publish_testresults:
type: boolean
description: Publish test results
required: true
default: true
run_sonarcloud:
type: boolean
description: Run SonarCloud
required: true
default: true
push:
branches:
- 'master'
pull_request:
branches:
- '**'
jobs:
build:
name: Build
runs-on: windows-latest
if: (github.event_name != 'workflow_dispatch' && true || inputs.run_build) == true
permissions:
id-token: write
contents: read
attestations: write
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: |
6.x
8.x
9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
run: dotnet workload install maui-ios
- name: Setup .NET workload wasm-tools
run: dotnet workload install wasm-tools
- name: Restore
run: dotnet restore PDFtoZPL.Build.slnf
- name: Build
run: dotnet build PDFtoZPL.Build.slnf -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} -p:VersionSuffix=ci --no-restore
- name: Pack
run: dotnet pack PDFtoZPL/PDFtoZPL.csproj -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }} -p:VersionSuffix=ci --no-restore
- name: Generate artifact attestation
if: github.repository == 'sungaila/PDFtoZPL' && github.ref == 'refs/heads/master'
uses: actions/attest-build-provenance@main
with:
subject-path: PDFtoZPL/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg
- name: Publish libraries
uses: actions/upload-artifact@main
with:
name: Library assemblies
path: |
PDFtoZPL/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
!**/*.nupkg
!**/*.snupkg
if-no-files-found: error
- name: Publish NuGet packages
uses: actions/upload-artifact@main
with:
name: NuGet packages
path: |
PDFtoZPL/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.nupkg
PDFtoZPL/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}/*.snupkg
if-no-files-found: error
- name: Publish tests
uses: actions/upload-artifact@main
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
with:
name: Test assemblies
path: Tests/bin/${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
if-no-files-found: error
retention-days: 1
compression-level: 9
test:
name: Test (${{ matrix.os }})
needs: build
strategy:
fail-fast: false
matrix:
os: [windows-2019, windows-2022, ubuntu-20.04, ubuntu-22.04, ubuntu-24.04, macos-13, macos-14, macos-15]
runs-on: ${{ matrix.os }}
if: success() && (github.event_name != 'workflow_dispatch' && true || inputs.run_tests) == true
steps:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: |
6.x
8.x
9.x
dotnet-quality: 'ga'
- name: Download test assemblies
if: (success() || failure())
uses: actions/download-artifact@main
with:
name: Test assemblies
- name: .NET Framework 4.6.2
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net462/*.Tests.dll --logger trx --verbosity detailed
- name: .NET Framework 4.7.1
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net471/*.Tests.dll --logger trx --verbosity detailed
- name: .NET Framework 4.8.1
if: runner.os == 'Windows' && (success() || failure())
run: dotnet test net481/*.Tests.dll --logger trx --verbosity detailed
- name: .NET 6
if: success() || failure()
run: dotnet test net6.0/*.Tests.dll --logger trx --verbosity detailed
- name: .NET 8
if: success() || failure()
run: dotnet test net8.0/*.Tests.dll --logger trx --verbosity detailed
- name: .NET 9
if: success() || failure()
run: dotnet test net9.0/*.Tests.dll --logger trx --verbosity detailed
- name: Upload test results
if: success() || failure()
uses: actions/upload-artifact@main
with:
name: Test results (${{ matrix.os }})
path: ./**/*.trx
if-no-files-found: error
retention-days: 1
publish-test-results:
name: Publish tests results
needs: test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
concurrency:
group: "publish-test-results"
cancel-in-progress: false
if: (success() || failure()) && (github.event_name != 'workflow_dispatch' && true || inputs.publish_testresults) == true
steps:
- name: Download Artifacts
uses: actions/download-artifact@main
with:
pattern: Test results (*)
merge-multiple: true
path: artifacts
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@master
with:
files: artifacts/**/*.trx
check_name: Test results
compare_to_earlier_commit: false
action_fail_on_inconclusive: true
json_file: test-results.json
- name: Upload test results to GitHub Gist
if: github.repository == 'sungaila/PDFtoZPL' && github.ref == 'refs/heads/master' && success()
uses: exuanbo/actions-deploy-gist@main
with:
token: ${{ secrets.GIST_TOKEN }}
gist_id: 47230c16cb63a1be5b5604830579714d
gist_description: ${{ github.repository }} test results as JSON
gist_file_name: ${{ github.repository_owner }}_${{ github.event.repository.name }}_test-results.json
file_path: test-results.json
file_type: text
sonarcloud:
name: SonarCloud
runs-on: windows-latest
if: (github.repository == 'sungaila/PDFtoZPL' && github.ref == 'refs/heads/master') && ((github.event_name != 'workflow_dispatch' || inputs.run_sonarcloud) == true)
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: |
6.x
8.x
9.x
dotnet-quality: 'ga'
- name: Setup .NET workload maui-android
run: dotnet workload install maui-android
- name: Setup .NET workload maui-ios
run: dotnet workload install maui-ios
- name: Setup dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Setup JDK 17
uses: actions/setup-java@main
with:
java-version: 17
java-package: jdk
distribution: 'zulu'
- name: Cache SonarCloud packages
uses: actions/cache@main
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@main
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: 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: Analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"sungaila_PDFtoZPL" /o:"sungaila" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
dotnet build PDFtoZPL.SonarCloud.slnf -c ${{ github.event_name != 'workflow_dispatch' && 'Debug' || inputs.build_configuration }}
dotnet-coverage collect "dotnet test PDFtoZPL.SonarCloud.slnf --verbosity detailed" -f xml -o "coverage.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"