generated from demaconsulting/TemplateDotNetTool
-
Notifications
You must be signed in to change notification settings - Fork 0
559 lines (480 loc) · 16.4 KB
/
build.yaml
File metadata and controls
559 lines (480 loc) · 16.4 KB
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
---
on:
workflow_call:
inputs:
version:
required: true
type: string
secrets:
SONAR_TOKEN:
required: true
jobs:
# Performs quick quality checks for project formatting consistency including
# markdown linting, spell checking, and YAML validation.
quality-checks:
name: Quality Checks
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Restore Tools
run: dotnet tool restore
- name: Capture tool versions
shell: bash
run: |
dotnet versionmark --capture --job-id "quality" -- dotnet git versionmark
- name: Upload version capture
uses: actions/upload-artifact@v7
with:
name: version-capture-quality
path: versionmark-quality.json
- name: Run markdown linter
uses: DavidAnson/markdownlint-cli2-action@v22
with:
globs: '**/*.md'
- name: Run spell checker
uses: streetsidesoftware/cspell-action@v8
with:
files: '**/*.{md,cs}'
incremental_files_only: false
- name: Run YAML linter
uses: ibiqlik/action-yamllint@v3
with:
config_file: .yamllint.yaml
# Builds and unit-tests the project on supported operating systems to ensure
# unit-tests operate on all platforms and to run SonarScanner for generating
# the code quality report.
build:
name: Build ${{ matrix.os }}
needs: quality-checks
permissions:
contents: read
pull-requests: write
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.x
9.x
10.x
- name: Restore Tools
run: >
dotnet tool restore
- name: Restore Dependencies
run: >
dotnet restore
- name: Start Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
begin
/k:"demaconsulting_VersionMark"
/o:"demaconsulting"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
/d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths=**/*.opencover.xml
/d:sonar.scanner.scanAll=false
- name: Build
run: >
dotnet build
--no-restore
--configuration Release
--property:Version=${{ inputs.version }}
- name: Test
run: >
dotnet test
--no-build
--configuration Release
--property:Version=${{ inputs.version }}
--collect "XPlat Code Coverage;Format=opencover"
--logger "trx;LogFilePrefix=${{ matrix.os }}"
--results-directory test-results
- name: End Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
end
/d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Create Dotnet Tool
run: >
dotnet pack
--no-build
--no-restore
--property:PackageVersion=${{ inputs.version }}
- name: Upload Test Results
uses: actions/upload-artifact@v7
with:
name: test-results-${{ matrix.os }}
path: test-results/*.trx
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: artifacts-${{ matrix.os }}
path: |
src/DemaConsulting.VersionMark/bin/Release/*.nupkg
src/DemaConsulting.VersionMark/bin/Release/*.snupkg
# Runs CodeQL security and quality analysis, gathering results to include
# in the code quality report.
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
needs: quality-checks
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: csharp
queries: security-and-quality
config-file: ./.github/codeql-config.yml
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.x
9.x
10.x
- name: Restore Tools
run: >
dotnet tool restore
- name: Restore Dependencies
run: >
dotnet restore
- name: Build
run: >
dotnet build
--no-restore
--configuration Release
--property:Version=${{ inputs.version }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:csharp"
output: sarif-results
upload: false
- name: Upload CodeQL SARIF
uses: actions/upload-artifact@v7
with:
name: codeql-sarif
path: sarif-results/csharp.sarif
# Performs integration testing on a matrix of operating systems and .NET runtimes,
# involving basic tool execution and running self-validation to ensure compatibility
# across different platforms and runtime versions.
integration-test:
name: Integration Test ${{ matrix.os }} .NET ${{ matrix.dotnet-version }}
runs-on: ${{ matrix.os }}
needs: build
permissions:
contents: read
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
dotnet-version: ['8.x', '9.x', '10.x']
steps:
- name: Checkout
uses: actions/checkout@v6
with:
sparse-checkout: |
.versionmark.yaml
.config/dotnet-tools.json
uses: actions/download-artifact@v8
with:
name: artifacts-${{ matrix.os }}
path: packages
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install tool from package
shell: bash
run: |
echo "Installing package version ${{ inputs.version }} from: packages/"
dotnet tool install --global \
--add-source packages \
--version ${{ inputs.version }} \
DemaConsulting.VersionMark
- name: Test version display
shell: bash
run: |
echo "Testing versionmark --version..."
versionmark --version || { echo "✗ Version command failed"; exit 1; }
echo "✓ Version command succeeded"
- name: Test help display
shell: bash
run: |
echo "Testing versionmark --help..."
versionmark --help || { echo "✗ Help command failed"; exit 1; }
echo "✓ Help command succeeded"
- name: Run self-validation
shell: bash
run: |
echo "Running self-validation..."
versionmark --validate --results validation-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}.trx \
|| { echo "✗ Self-validation failed"; exit 1; }
echo "✓ Self-validation succeeded"
- name: Capture tool versions
shell: bash
run: |
echo "Capturing tool versions..."
# Create short job ID: int-win-8, int-win-9, int-ubuntu-8, etc.
OS_SHORT=$(echo "${{ matrix.os }}" | sed 's/windows-latest/win/;s/ubuntu-latest/ubuntu/')
DOTNET_SHORT=$(echo "${{ matrix.dotnet-version }}" | sed 's/\.x$//')
JOB_ID="int-${OS_SHORT}-${DOTNET_SHORT}"
versionmark --capture --job-id "${JOB_ID}" -- dotnet git
echo "✓ Tool versions captured"
- name: Upload validation test results
if: always()
uses: actions/upload-artifact@v7
with:
name: validation-test-results-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}
path: validation-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}.trx
- name: Upload version capture
uses: actions/upload-artifact@v7
with:
name: version-capture-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}
path: versionmark-int-*.json
# Builds the supporting documentation including user guides, requirements,
# trace matrices, code quality reports, and build notes.
build-docs:
name: Build Documents
runs-on: windows-latest
needs: [build, integration-test, codeql]
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 'lts/*'
- name: Download all test results
uses: actions/download-artifact@v8
with:
path: test-results
pattern: '*test-results*'
continue-on-error: true
- name: Download VersionMark package
uses: actions/download-artifact@v8
with:
name: artifacts-windows-latest
path: packages
- name: Download CodeQL SARIF
uses: actions/download-artifact@v8
with:
name: codeql-sarif
path: codeql-results
- name: Download all version captures
uses: actions/download-artifact@v8
with:
path: version-captures
pattern: 'version-capture-*'
continue-on-error: true
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Install npm dependencies
run: npm install
- name: Install VersionMark from package
shell: bash
run: |
echo "Installing VersionMark version ${{ inputs.version }}"
dotnet tool install --global \
--add-source packages \
--version ${{ inputs.version }} \
DemaConsulting.VersionMark
- name: Restore Tools
run: dotnet tool restore
- name: Capture tool versions for build-docs
shell: bash
run: |
echo "Capturing tool versions..."
versionmark --capture --job-id "build-docs" -- \
dotnet git node npm pandoc weasyprint sarifmark sonarmark reqstream buildmark
echo "✓ Tool versions captured"
- name: Generate Requirements Report, Justifications, and Trace Matrix
run: >
dotnet reqstream
--requirements requirements.yaml
--tests "test-results/**/*.trx"
--report docs/requirements/requirements.md
--justifications docs/justifications/justifications.md
--matrix docs/tracematrix/tracematrix.md
--enforce
- name: Generate CodeQL Quality Report with SarifMark
run: >
dotnet sarifmark
--sarif codeql-results/csharp.sarif
--report docs/quality/codeql-quality.md
--heading "VersionMark CodeQL Analysis"
--report-depth 1
- name: Display CodeQL Quality Report
shell: bash
run: |
echo "=== CodeQL Quality Report ==="
cat docs/quality/codeql-quality.md
- name: Generate SonarCloud Quality Report
shell: bash
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
dotnet sonarmark
--server https://sonarcloud.io
--project-key demaconsulting_VersionMark
--branch ${{ github.ref_name }}
--token "$SONAR_TOKEN"
--report docs/quality/sonar-quality.md
--report-depth 1
- name: Display SonarCloud Quality Report
shell: bash
run: |
echo "=== SonarCloud Quality Report ==="
cat docs/quality/sonar-quality.md
- name: Generate Build Notes with BuildMark
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet buildmark
--build-version ${{ inputs.version }}
--report docs/buildnotes.md
--report-depth 1
- name: Display Build Notes Report
shell: bash
run: |
echo "=== Build Notes Report ==="
cat docs/buildnotes.md
- name: Publish Tool Versions
shell: bash
run: |
echo "Publishing tool versions..."
versionmark --publish --report docs/buildnotes/versions.md --report-depth 1 \
-- "versionmark-*.json" "version-captures/**/versionmark-*.json"
echo "✓ Tool versions published"
- name: Display Tool Versions Report
shell: bash
run: |
echo "=== Tool Versions Report ==="
cat docs/buildnotes/versions.md
- name: Generate Build Notes HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/buildnotes/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/buildnotes/buildnotes.html
- name: Generate Build Notes PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/buildnotes/buildnotes.html
"docs/VersionMark Build Notes.pdf"
- name: Generate Guide HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/guide/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/guide/guide.html
- name: Generate Guide PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/guide/guide.html
"docs/VersionMark User Guide.pdf"
- name: Generate Code Quality HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/quality/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/quality/quality.html
- name: Generate Code Quality PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/quality/quality.html
"docs/VersionMark Code Quality.pdf"
- name: Generate Requirements HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/requirements/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/requirements/requirements.html
- name: Generate Requirements PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/requirements/requirements.html
"docs/VersionMark Requirements.pdf"
- name: Generate Requirements Justifications HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/justifications/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/justifications/justifications.html
- name: Generate Requirements Justifications PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/justifications/justifications.html
"docs/VersionMark Requirements Justifications.pdf"
- name: Generate Trace Matrix HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/tracematrix/definition.yaml
--filter node_modules/.bin/mermaid-filter.cmd
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--output docs/tracematrix/tracematrix.html
- name: Generate Trace Matrix PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/tracematrix/tracematrix.html
"docs/VersionMark Trace Matrix.pdf"
- name: Upload documentation
uses: actions/upload-artifact@v7
with:
name: documents
path: |
docs/*.pdf
docs/buildnotes.md