-
Notifications
You must be signed in to change notification settings - Fork 0
682 lines (570 loc) · 21.2 KB
/
build.yaml
File metadata and controls
682 lines (570 loc) · 21.2 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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
---
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:
# === INSTALL DEPENDENCIES ===
# This section installs all required dependencies for quality checks.
- 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
# === CAPTURE TOOL VERSIONS ===
# This section captures the versions of all tools used in the quality checks.
- name: Capture tool versions
shell: bash
run: |
mkdir -p artifacts
echo "Capturing tool versions..."
dotnet versionmark --capture --job-id "quality" \
--output "artifacts/versionmark-quality.json" -- \
dotnet git versionmark
echo "✓ Tool versions captured"
# === CAPTURE OTS SELF-VALIDATION RESULTS ===
# This section captures self-validation results from OTS tools.
- name: Run VersionMark self-validation
run: dotnet versionmark --validate --results artifacts/versionmark-self-validation-quality.trx
# === RUN QUALITY CHECKS ===
# This section runs all quality checks for the project.
- 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
# === UPLOAD ARTIFACTS ===
# This section uploads all quality artifacts.
- name: Upload quality artifacts
uses: actions/upload-artifact@v7
with:
name: artifacts-quality
path: artifacts/
# Builds and unit-tests the project on supported operating systems with SonarCloud analysis.
build:
name: Build ${{ matrix.os }}
needs: quality-checks
permissions:
contents: read # To read repository contents
pull-requests: write # To write pull requests analysis results and artifacts
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
# === INSTALL DEPENDENCIES ===
# This section installs all required dependencies for the build.
- 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
# === CAPTURE TOOL VERSIONS ===
# This section captures the versions of all tools used in the build process.
- name: Capture tool versions
shell: bash
run: |
mkdir -p artifacts
echo "Capturing tool versions..."
# Create short job ID: build-windows, build-ubuntu, build-macos
OS_SHORT=$(echo "${{ matrix.os }}" | sed 's/-latest//')
JOB_ID="build-${OS_SHORT}"
dotnet versionmark --capture --job-id "${JOB_ID}" \
--output "artifacts/versionmark-${JOB_ID}.json" -- \
dotnet git dotnet-sonarscanner versionmark
echo "✓ Tool versions captured"
# === CAPTURE OTS SELF-VALIDATION RESULTS ===
# This section captures self-validation results from OTS tools.
- name: Run VersionMark self-validation
run: dotnet versionmark --validate --results artifacts/versionmark-self-validation-${{ matrix.os }}.trx
# === BUILD AND TEST ===
# This section builds and tests the project.
- name: Restore Dependencies
run: >
dotnet restore
- name: Start Sonar Scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: >
dotnet dotnet-sonarscanner
begin
/k:"demaconsulting_SonarMark"
/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 artifacts
- 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 }}
# === UPLOAD ARTIFACTS ===
# This section uploads all build artifacts.
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: artifacts-build-${{ matrix.os }}
path: artifacts/
- name: Upload packages
uses: actions/upload-artifact@v7
with:
name: packages-${{ matrix.os }}
path: |
src/DemaConsulting.SonarMark/bin/Release/*.nupkg
src/DemaConsulting.SonarMark/bin/Release/*.snupkg
# Performs security analysis using CodeQL.
codeql:
name: CodeQL Analysis
runs-on: ubuntu-latest
needs: quality-checks
permissions:
actions: read
contents: read
security-events: write
steps:
# === INSTALL DEPENDENCIES ===
# This section installs all required dependencies for CodeQL analysis.
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: csharp
build-mode: manual
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
# === BUILD AND ANALYZE ===
# This section builds the project and runs CodeQL analysis.
- 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: artifacts
upload: false
# === UPLOAD ARTIFACTS ===
# This section uploads all CodeQL artifacts.
- name: Upload CodeQL artifacts
uses: actions/upload-artifact@v7
with:
name: artifacts-codeql
path: artifacts/
# Tests the packaged tool on multiple OS and .NET 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, macos-latest]
dotnet-version: ['8.x', '9.x', '10.x']
steps:
# === INSTALL DEPENDENCIES ===
# This section installs all required dependencies and tools for integration testing.
- name: Checkout
uses: actions/checkout@v6
with:
sparse-checkout: |
.versionmark.yaml
.config/dotnet-tools.json
- name: Download package
uses: actions/download-artifact@v8
with:
name: packages-${{ matrix.os }}
path: packages
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Restore Tools
run: >
dotnet tool restore
- 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.SonarMark
# === CAPTURE TOOL VERSIONS ===
# This section captures the versions of all tools used in the integration tests.
- name: Capture tool versions
shell: bash
run: |
mkdir -p artifacts
echo "Capturing tool versions..."
# Create short job ID: int-windows-8, int-ubuntu-9, int-macos-10, etc.
OS_SHORT=$(echo "${{ matrix.os }}" | sed 's/-latest//')
DOTNET_SHORT=$(echo "${{ matrix.dotnet-version }}" | sed 's/\.x$//')
JOB_ID="int-${OS_SHORT}-${DOTNET_SHORT}"
dotnet versionmark --capture --job-id "${JOB_ID}" \
--output "artifacts/versionmark-${JOB_ID}.json" -- \
dotnet git versionmark
echo "✓ Tool versions captured"
# === RUN INTEGRATION TESTS ===
# This section runs the integration tests for the tool.
- name: Test version display
shell: bash
run: |
echo "Testing sonarmark --version..."
sonarmark --version || { echo "✗ Version command failed"; exit 1; }
echo "✓ Version command succeeded"
- name: Test help display
shell: bash
run: |
echo "Testing sonarmark --help..."
sonarmark --help || { echo "✗ Help command failed"; exit 1; }
echo "✓ Help command succeeded"
- name: Test SonarMark analysis generation
shell: bash
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
echo "Testing sonarmark analysis generation..."
sonarmark \
--server https://sonarcloud.io \
--project-key demaconsulting_SonarMark \
--branch ${{ github.ref_name }} \
--token "$SONAR_TOKEN" \
--report analysis-report-${{ matrix.os }}-${{ matrix.dotnet-version }}.md \
|| { echo "✗ Analysis generation failed"; exit 1; }
echo "✓ Analysis generation succeeded"
# Verify report file was created
if [ ! -f "analysis-report-${{ matrix.os }}-${{ matrix.dotnet-version }}.md" ]; then
echo "✗ Report file was not created"
exit 1
fi
echo "✓ Report file exists"
# Display report summary
echo "Report summary:"
cat "analysis-report-${{ matrix.os }}-${{ matrix.dotnet-version }}.md"
- name: Run SonarMark self-validation
shell: bash
run: |
echo "Running SonarMark self-validation..."
sonarmark --validate \
--results artifacts/sonarmark-self-validation-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}.trx \
|| { echo "✗ Self-validation failed"; exit 1; }
echo "✓ Self-validation succeeded"
# === UPLOAD ARTIFACTS ===
# This section uploads all generated artifacts for use by downstream jobs.
- name: Upload validation artifacts
if: always()
uses: actions/upload-artifact@v7
with:
name: artifacts-validation-${{ matrix.os }}-dotnet${{ matrix.dotnet-version }}
path: artifacts/
# Generates all documentation including requirements, trace matrix, and build notes.
build-docs:
name: Build Documentation
runs-on: windows-latest
needs: [build, integration-test, codeql]
permissions:
contents: read
steps:
# === CHECKOUT AND DOWNLOAD ARTIFACTS ===
# This section retrieves the code and all necessary artifacts from previous jobs.
- name: Checkout
uses: actions/checkout@v6
- name: Download all job artifacts
uses: actions/download-artifact@v8
with:
path: artifacts
pattern: 'artifacts-*'
merge-multiple: true
continue-on-error: true
- name: Download SonarMark package
uses: actions/download-artifact@v8
with:
name: packages-ubuntu-latest
path: packages
# === INSTALL DEPENDENCIES ===
# This section installs all required dependencies and tools for document generation.
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 'lts/*'
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
- name: Install npm dependencies
run: npm install
- name: Install SonarMark from package
shell: bash
run: |
echo "Installing SonarMark version ${{ inputs.version }}"
dotnet tool install --global \
--add-source packages \
--version ${{ inputs.version }} \
DemaConsulting.SonarMark
- name: Restore Tools
run: dotnet tool restore
# === CAPTURE TOOL VERSIONS ===
# This section captures the versions of all tools used in the build process.
- name: Capture tool versions for build-docs
shell: bash
run: |
echo "Capturing tool versions..."
dotnet versionmark --capture --job-id "build-docs" \
--output "artifacts/versionmark-build-docs.json" -- \
dotnet git node npm pandoc weasyprint sarifmark sonarmark reqstream buildmark versionmark
echo "✓ Tool versions captured"
# === CAPTURE OTS SELF-VALIDATION RESULTS ===
# This section captures self-validation results from OTS tools.
- name: Run ReqStream self-validation
run: dotnet reqstream --validate --results artifacts/reqstream-self-validation.trx
- name: Run BuildMark self-validation
run: dotnet buildmark --validate --results artifacts/buildmark-self-validation.trx
- name: Run VersionMark self-validation
run: dotnet versionmark --validate --results artifacts/versionmark-self-validation.trx
- name: Run SarifMark self-validation
run: dotnet sarifmark --validate --results artifacts/sarifmark-self-validation.trx
- name: Run SonarMark self-validation
run: sonarmark --validate --results artifacts/sonarmark-self-validation.trx
# === GENERATE MARKDOWN REPORTS ===
# This section generates all markdown reports from various tools and sources.
- name: Generate Requirements Report and Trace Matrix
run: >
dotnet reqstream
--requirements requirements.yaml
--tests "artifacts/**/*.trx"
--report docs/requirements/requirements.md
--matrix docs/tracematrix/tracematrix.md
--justifications docs/justifications/justifications.md
--enforce
- name: Generate CodeQL Quality Report with SarifMark
shell: bash
run: >
dotnet sarifmark
--sarif artifacts/csharp.sarif
--report docs/quality/codeql-quality.md
--heading "SonarMark 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 Code Quality Report with SonarMark
shell: bash
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
sonarmark
--server https://sonarcloud.io
--project-key demaconsulting_SonarMark
--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
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
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..."
dotnet versionmark --publish --report docs/buildnotes/versions.md --report-depth 1 \
-- "artifacts/**/versionmark-*.json"
echo "✓ Tool versions published"
- name: Display Tool Versions Report
shell: bash
run: |
echo "=== Tool Versions Report ==="
cat docs/buildnotes/versions.md
# === GENERATE HTML DOCUMENTS WITH PANDOC ===
# This section converts markdown documents to HTML using Pandoc.
- name: Generate Guide HTML with Pandoc
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 Requirements HTML with Pandoc
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 Trace Matrix HTML with Pandoc
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 Justifications HTML with Pandoc
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 Build Notes HTML with Pandoc
shell: bash
run: >
dotnet pandoc
--defaults docs/buildnotes/definition.yaml
--metadata version="${{ inputs.version }}"
--metadata date="$(date +'%Y-%m-%d')"
--filter node_modules/.bin/mermaid-filter.cmd
--output docs/buildnotes/buildnotes.html
- name: Generate Code Quality HTML with Pandoc
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
# === GENERATE PDF DOCUMENTS WITH WEASYPRINT ===
# This section converts HTML documents to PDF using Weasyprint.
- name: Generate Guide PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/guide/guide.html
"docs/SonarMark User Guide.pdf"
- name: Generate Requirements PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/requirements/requirements.html
"docs/SonarMark Requirements.pdf"
- name: Generate Trace Matrix PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/tracematrix/tracematrix.html
"docs/SonarMark Trace Matrix.pdf"
- name: Generate Justifications PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/justifications/justifications.html
"docs/SonarMark Requirements Justifications.pdf"
- name: Generate Build Notes PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/buildnotes/buildnotes.html
"docs/SonarMark Build Notes.pdf"
- name: Generate Code Quality PDF with Weasyprint
run: >
dotnet weasyprint
--pdf-variant pdf/a-3u
docs/quality/quality.html
"docs/SonarMark Code Quality.pdf"
# === UPLOAD ARTIFACTS ===
# This section uploads all generated documentation artifacts.
- name: Upload documentation
uses: actions/upload-artifact@v7
with:
name: documents
path: |
docs/*.pdf
docs/buildnotes.md