Repository navigation
585 lines (535 loc) · 26.3 KB
/
Copy pathBuild Module.yml
File metadata and controls
585 lines (535 loc) · 26.3 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
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/software-installed-on-github-hosted-runners
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-powershell
# https://github.com/actions/upload-artifact#where-does-the-upload-go
name: Build Module
# Builds and tests the DLLPickle PowerShell module on Windows, Linux, and macOS.
# Can be run manually or called by other workflows.
on:
workflow_call:
inputs:
ref:
description: "Git reference (branch, tag, or commit SHA) to check out. Defaults to the ref that triggered the caller workflow."
type: string
required: false
workflow_dispatch:
pull_request:
# No path filter: this workflow always triggers on PRs to main so its "Build and test module"
# checks always REPORT (a required status check from a path-filtered workflow that never triggers
# stays Pending and blocks the PR forever). The expensive matrix build is gated below by the
# `changes` job — on a PR that doesn't touch build-relevant paths the build job is skipped, and a
# skipped job satisfies the required check, so docs-/CI-only PRs are never blocked.
branches: [main]
#push:
# branches:
# - main
# paths:
# - "src/**"
# - ".github/workflows/Build Module.yml"
permissions:
contents: read
security-events: write
concurrency:
group: ${{ github.workflow }}-${{ inputs.ref || github.ref }}
cancel-in-progress: true
jobs:
changes:
name: Detect build-relevant changes
# Only meaningful for a directly-triggered PR. workflow_call (release) passes inputs.ref and must
# always build; workflow_dispatch must always build. Both skip this job (handled in build's `if`).
if: github.event_name == 'pull_request' && inputs.ref == ''
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
outputs:
relevant: ${{ steps.detect.outputs.relevant }}
steps:
- name: Detect whether build-relevant paths changed
id: detect
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
# Detection is intentionally INLINE (not a shared .github/ci-scripts script): keeping the
# merge-gate logic in the workflow file benefits from GitHub's stricter workflow-edit review,
# so a PR can't relocate it to a less-scrutinized script and tamper the skip decision (#228).
# Fail-safe: default to relevant=true so any error enumerating changed files runs the build
# rather than silently skipping it. Use the PAGINATED REST files endpoint -- gh pr view
# --json files caps at 100 files and could miss a later src/ change on a large PR.
$Relevant = $true
try {
$ErrorActionPreference = 'Stop'
# Project previous_filename too, so a rename moving a tracked file OUT of a matched tree
# (reported as the new path in .filename, old path in .previous_filename) is still seen.
$Files = gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --paginate --jq '.[] | .filename, (.previous_filename // empty)'
# Native non-zero exits don't reliably throw in pwsh, so check explicitly -> fail-safe.
if ($LASTEXITCODE -ne 0) { throw "gh api exited $LASTEXITCODE while listing PR files" }
# docs/gaps/ is build-relevant: the gap-register guard (tests/Unit/GapRegister.Tests.ps1)
# must run when gap files or their index change, otherwise a docs-only gap edit would skip
# the very check that detects gap-register drift (GAP-011).
$Patterns = @(
'^src/'
'^build/'
'^tests/'
'^tools/'
'^\.oss-scanner/'
'^docs/gaps/'
'^\.github/ci-scripts/'
'^\.github/workflows/Build Module\.yml$'
'^\.github/workflows/OSS-Scanner\.yml$'
'^global\.json$'
'^build/powershell-test-matrix\.json$'
)
$Relevant = $false
foreach ($File in $Files) {
foreach ($Pattern in $Patterns) {
if ($File -match $Pattern) { $Relevant = $true; break }
}
if ($Relevant) { break }
}
} catch {
Write-Host "::warning::Changed-file detection failed; defaulting to relevant=true (fail-safe). $_"
$Relevant = $true
}
"relevant=$($Relevant.ToString().ToLowerInvariant())" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
Write-Host "Build-relevant change detected: $Relevant"
runtime-matrix:
name: Generate exact PowerShell runtime matrix
needs: changes
if: ${{ always() && (inputs.ref != '' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.relevant != 'false') }}
runs-on: ubuntu-24.04
permissions:
contents: read
outputs:
matrix: ${{ steps.generate.outputs.matrix }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false
- name: Generate matrix from support policy
id: generate
shell: pwsh
run: |
$Matrix = ./tools/New-DLLPicklePowerShellTestMatrix.ps1 -Compress
"matrix=$Matrix" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
build:
name: Build and test module (${{ matrix.os }})
needs: changes
# Always build for workflow_call (release; inputs.ref set) and workflow_dispatch. For a direct PR,
# build only when build-relevant paths changed; otherwise skip (a skipped job still satisfies the
# required "Build and test module" check). always() stops the skip of `changes` in the
# call/dispatch paths from cascading into a skip of build; the `!= 'false'` guard errs toward
# building on any ambiguity, so the release path is never accidentally skipped.
if: ${{ always() && (inputs.ref != '' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.relevant != 'false') }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
include:
- os: windows-latest
module_cache_paths: |
~/Documents/PowerShell/Modules
- os: ubuntu-latest
module_cache_paths: |
~/.local/share/powershell/Modules
- os: macos-latest
module_cache_paths: |
~/.local/share/powershell/Modules
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false
# Install the exact .NET SDK pinned by global.json so the build does not depend on the runner image.
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "src/DLLPickle.Build/packages.lock.json"
- name: Cache PowerShell modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ matrix.module_cache_paths }}
key: ${{ runner.os }}-${{ runner.arch }}-pwsh-${{ hashFiles('build/build-tool-versions.json') }}-psmodules-${{ hashFiles('build/DLLPickle.Build.ps1', 'build/DLLPickle.Tooling.ps1', '.github/ci-scripts/Actions_Bootstrap.ps1') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pwsh-${{ hashFiles('build/build-tool-versions.json') }}-psmodules-
- name: Bootstrap
shell: pwsh
run: ./.github/ci-scripts/Actions_Bootstrap.ps1
- name: Test and Build (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: ./tools/Invoke-DLLPickleBuild.ps1
- name: Test and Build (Linux/macOS)
if: runner.os != 'Windows'
shell: pwsh
run: ./tools/Invoke-DLLPickleBuild.ps1 -Task BuildCrossPlatform
- name: Verify package composition and size policy
if: runner.os == 'Windows'
shell: pwsh
run: |
$CompositionParameters = @{
OutputPath = './artifacts/package/artifact-composition.json'
Strict = $true
}
$Composition = ./tools/Test-DLLPicklePackageArtifact.ps1 @CompositionParameters
$SizeParameters = @{
OutputPath = './artifacts/package/artifact-size.json'
Strict = $true
}
$Size = ./tools/New-DLLPickleArtifactSizeReport.ps1 @SizeParameters
@(
'### Package policy'
''
"- Target frameworks: $($Composition.ActualTargetFrameworks -join ', ')"
"- Artifact composition: $($Composition.Passed)"
"- Material size review required: $($Size.ReviewRequired)"
"- Full unpacked bytes: $($Size.FullArtifact.UnpackedBytes)"
"- Full deterministic compressed bytes: $($Size.FullArtifact.CompressedBytes)"
) | Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY
- name: Generate PSScriptAnalyzer SARIF
if: always() && runner.os == 'Windows'
shell: pwsh
run: |
. ./build/DLLPickle.Tooling.ps1
$ToolPolicy = Get-DLLPickleBuildToolPolicy
$AnalyzerVersion = Get-DLLPickleBuildToolVersion -Policy $ToolPolicy -Name 'PSScriptAnalyzer'
$null = Import-DLLPickleBuildTool -Name 'PSScriptAnalyzer' -RequiredVersion $AnalyzerVersion
$null = New-Item -Path ./artifacts -ItemType Directory -Force
$Results = @(Invoke-ScriptAnalyzer -Path ./src/DLLPickle -Settings ./build/PSScriptAnalyzerSettings.psd1 -Recurse)
$Rules = @($Results | Group-Object RuleName | ForEach-Object {
$Item = $_.Group[0]
$Level = switch ($Item.Severity) { 'Error' { 'error' } 'Warning' { 'warning' } default { 'note' } }
[ordered]@{
id = $Item.RuleName
name = $Item.RuleName
shortDescription = @{ text = "$($Item.RuleName) violation" }
defaultConfiguration = @{ level = $Level }
}
})
$WorkDir = (Get-Location).Path
$SarifResults = @($Results | ForEach-Object {
$Level = switch ($_.Severity) { 'Error' { 'error' } 'Warning' { 'warning' } default { 'note' } }
$RelPath = $_.ScriptPath.Substring($WorkDir.Length).TrimStart('\', '/') -replace '\\', '/'
[ordered]@{
ruleId = $_.RuleName
level = $Level
message = @{ text = $_.Message }
locations = @(@{
physicalLocation = @{
artifactLocation = @{ uri = $RelPath }
region = @{ startLine = $_.Line; startColumn = $_.Column }
}
})
}
})
$Sarif = [ordered]@{
'$schema' = 'https://json.schemastore.org/sarif-2.1.0.json'
version = '2.1.0'
runs = @([ordered]@{
tool = @{ driver = @{
name = 'PSScriptAnalyzer'
version = (Get-Module PSScriptAnalyzer).Version.ToString()
rules = $Rules
}}
results = $SarifResults
})
}
$Sarif | ConvertTo-Json -Depth 20 | Set-Content -Path ./artifacts/psscriptanalyzer.sarif -Encoding UTF8
Write-Host "SARIF written with $($Results.Count) result(s)"
- name: Upload PSScriptAnalyzer SARIF to code scanning
if: always() && runner.os == 'Windows' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
uses: github/codeql-action/upload-sarif@33d7b85da1a04171e211befe2c739303b9a4c066 # v4.39.3
with:
sarif_file: ./artifacts/psscriptanalyzer.sarif
category: psscriptanalyzer
- name: Upload pester results
if: always() # Ensure this step runs even if prior steps fail
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: pester-results-${{ runner.os }}
path: ./artifacts/testOutput
if-no-files-found: warn
- name: Upload package policy reports
if: always() && runner.os == 'Windows'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package-policy-reports
path: ./artifacts/package
if-no-files-found: warn
- name: Upload zip module archive build
if: runner.os == 'Windows'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: zip-archive
path: ./archive
if-no-files-found: warn
- name: Upload module directory
if: runner.os == 'Windows'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: module-build
path: ./module/DLLPickle
if-no-files-found: warn
runtime-tests:
name: PowerShell ${{ matrix.powerShellVersion }} on ${{ matrix.platform }}
needs: runtime-matrix
if: ${{ needs.runtime-matrix.result == 'success' }}
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
permissions:
contents: read
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.runtime-matrix.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ inputs.ref || github.ref }}
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
cache: true
cache-dependency-path: "src/DLLPickle.Build/packages.lock.json"
- name: Cache exact stock PowerShell archive and payload
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/dllpickle-test-powershell
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.provider }}-${{ matrix.powerShellVersion }}-${{ hashFiles('build/powershell-test-matrix.json', 'tools/Install-DLLPickleTestPowerShell.ps1') }}
- name: Cache isolated PowerShell build modules
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/dllpickle-psmodules/${{ matrix.powerShellVersion }}
key: ${{ runner.os }}-${{ runner.arch }}-pwsh-${{ matrix.powerShellVersion }}-tools-${{ hashFiles('build/build-tool-versions.json', 'build/DLLPickle.Tooling.ps1', '.github/ci-scripts/Actions_Bootstrap.ps1') }}
- name: Provision and verify exact stock PowerShell
id: runtime
shell: pwsh
env:
MATRIX_PROVIDER: ${{ matrix.provider }}
MATRIX_POWERSHELL_VERSION: ${{ matrix.powerShellVersion }}
MATRIX_PLATFORM: ${{ matrix.platform }}
MATRIX_ARCHITECTURE: ${{ matrix.architecture }}
RUNTIME_INSTALL_ROOT: ${{ runner.temp }}/dllpickle-test-powershell
run: |
$InstallParameters = @{
Provider = $env:MATRIX_PROVIDER
PowerShellVersion = $env:MATRIX_POWERSHELL_VERSION
Platform = $env:MATRIX_PLATFORM
Architecture = $env:MATRIX_ARCHITECTURE
InstallRoot = $env:RUNTIME_INSTALL_ROOT
PassThru = $true
}
$Identity = ./tools/Install-DLLPickleTestPowerShell.ps1 @InstallParameters
"DLLPICKLE_TEST_PWSH=$($Identity.ExecutablePath)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
"DLLPICKLE_TEST_TFM=$($Identity.TargetFramework)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
$Identity | ConvertTo-Json -Depth 5 | Set-Content -LiteralPath ./runtime-identity.json -Encoding utf8
- name: Bootstrap exact tools in an isolated module path
shell: pwsh
env:
CELL_MODULE_ROOT: ${{ runner.temp }}/dllpickle-psmodules/${{ matrix.powerShellVersion }}
run: |
$CellModuleRoot = $env:CELL_MODULE_ROOT
$SystemModuleRoot = Join-Path -Path (Split-Path -Path $env:DLLPICKLE_TEST_PWSH -Parent) -ChildPath 'Modules'
$IsolatedModulePath = @($CellModuleRoot, $SystemModuleRoot) -join [System.IO.Path]::PathSeparator
"DLLPICKLE_TEST_PSMODULEPATH=$IsolatedModulePath" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
$env:PSModulePath = $IsolatedModulePath
& $env:DLLPICKLE_TEST_PWSH -NoLogo -NoProfile -NonInteractive -File ./.github/ci-scripts/Actions_Bootstrap.ps1 -ModuleInstallPath $CellModuleRoot
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Run unit tests in a fresh exact-runtime process
shell: pwsh
run: |
$env:PSModulePath = $env:DLLPICKLE_TEST_PSMODULEPATH
& $env:DLLPICKLE_TEST_PWSH -NoLogo -NoProfile -NonInteractive -File ./tools/Invoke-DLLPickleBuild.ps1 -Task Test
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Build, package, and run integration regressions in a fresh exact-runtime process
shell: pwsh
run: |
$env:PSModulePath = $env:DLLPICKLE_TEST_PSMODULEPATH
& $env:DLLPICKLE_TEST_PWSH -NoLogo -NoProfile -NonInteractive -File ./tools/Invoke-DLLPickleBuild.ps1 -Task IssueReproTest
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Inspect the exact-runtime package and resolved TFM assets
shell: pwsh
run: |
$env:PSModulePath = $env:DLLPICKLE_TEST_PSMODULEPATH
& $env:DLLPICKLE_TEST_PWSH -NoLogo -NoProfile -NonInteractive -File ./tools/Test-DLLPicklePackageArtifact.ps1 -Strict
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
& $env:DLLPICKLE_TEST_PWSH -NoLogo -NoProfile -NonInteractive -File ./tools/Test-DLLPickleTfmAlignment.ps1 -Strict
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Capture selected bundle and assembly load-context evidence
if: ${{ always() && steps.runtime.outcome == 'success' }}
shell: pwsh
env:
MATRIX_POWERSHELL_VERSION: ${{ matrix.powerShellVersion }}
MATRIX_TARGET_FRAMEWORK: ${{ matrix.targetFramework }}
RUNTIME_EVIDENCE_PATH: ./artifacts/runtime-evidence-${{ matrix.powerShellVersion }}-${{ matrix.platform }}.json
run: |
$EvidenceParameters = @{
PowerShellExecutable = $env:DLLPICKLE_TEST_PWSH
PowerShellVersion = $env:MATRIX_POWERSHELL_VERSION
TargetFramework = $env:MATRIX_TARGET_FRAMEWORK
ModuleManifestPath = './module/DLLPickle/DLLPickle.psd1'
OutputPath = $env:RUNTIME_EVIDENCE_PATH
}
./tools/New-DLLPickleRuntimeProfileEvidence.ps1 @EvidenceParameters
- name: Upload structured runtime result
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: runtime-${{ matrix.powerShellVersion }}-${{ matrix.platform }}-${{ matrix.architecture }}
path: |
runtime-identity.json
artifacts/runtime-evidence-*.json
artifacts/testOutput/*.xml
if-no-files-found: warn
retention-days: 14
dependency-change-report:
name: Per-TFM dependency change report
needs: [build, runtime-tests]
if: >-
github.event_name == 'pull_request' &&
github.actor == 'dependabot[bot]' &&
github.event.pull_request.user.login == 'dependabot[bot]' &&
needs.build.result == 'success' &&
needs.runtime-tests.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Check out candidate
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check out pull request base
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: dependency-baseline
persist-credentials: false
- name: Setup .NET
uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
- name: Restore and build baseline and candidate graphs
shell: pwsh
run: |
$BaselineGlobalJson = './dependency-baseline/global.json'
if (Test-Path -LiteralPath $BaselineGlobalJson -PathType Leaf) {
Remove-Item -LiteralPath $BaselineGlobalJson -Force
}
$Projects = @(
'./dependency-baseline/src/DLLPickle.Build/DLLPickle.csproj'
'./src/DLLPickle.Build/DLLPickle.csproj'
)
foreach ($Project in $Projects) {
dotnet restore $Project --locked-mode
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
dotnet build $Project --configuration Release --no-restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
- name: Download package size evidence
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: package-policy-reports
path: downloaded-package-policy
- name: Download exact-runtime scenario evidence
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: runtime-*
path: downloaded-runtime-evidence
- name: Generate per-TFM major-update evidence
shell: pwsh
run: |
$Parameters = @{
BaselineProjectAssetsPath = './dependency-baseline/src/DLLPickle.Build/obj/project.assets.json'
CandidateProjectAssetsPath = './src/DLLPickle.Build/obj/project.assets.json'
BaselineBuildOutputRoot = './dependency-baseline/src/DLLPickle.Build/bin/Release'
CandidateBuildOutputRoot = './src/DLLPickle.Build/bin/Release'
SupportPolicyPath = './src/DLLPickle/SupportedRuntimeProfiles.json'
DependencyPolicyPath = './build/dependency-policy.json'
SizeReportPath = './downloaded-package-policy/artifact-size.json'
ScenarioEvidencePath = './downloaded-runtime-evidence'
OutputPath = './artifacts/dependency/dependency-change-report.json'
}
./tools/New-DLLPickleDependencyChangeReport.ps1 @Parameters
- name: Upload per-TFM dependency report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dependency-change-report
path: ./artifacts/dependency/dependency-change-report.json
if-no-files-found: error
retention-days: 30
oss-scanner:
name: Validate offline scanner environment
needs: changes
if: ${{ always() && (inputs.ref != '' || github.event_name == 'workflow_dispatch' || needs.changes.outputs.relevant != 'false') }}
uses: ./.github/workflows/OSS-Scanner.yml
permissions:
contents: read
with:
ref: ${{ inputs.ref || github.ref }}
build-gate:
name: Build gate
# Aggregate required-check target. GitHub evaluates a matrix job's `if` BEFORE expanding the
# matrix, so skipping the `build` job does NOT create the per-OS "Build and test module (...)"
# check contexts -- requiring those directly would leave non-bundle PRs stuck "Expected - waiting
# for status". This single, always-running job is the stable check to require instead: it passes
# when the matrix build succeeded OR was skipped (no build-relevant changes) and fails when the
# build failed or was cancelled.
needs: [changes, runtime-matrix, build, runtime-tests, dependency-change-report, oss-scanner]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Aggregate build result
shell: pwsh
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_REF: ${{ inputs.ref }}
BUILD_RELEVANT: ${{ needs.changes.outputs.relevant }}
run: |
$Results = @{
changes = '${{ needs.changes.result }}'
runtimeMatrix = '${{ needs.runtime-matrix.result }}'
build = '${{ needs.build.result }}'
runtimeTests = '${{ needs.runtime-tests.result }}'
dependencyChangeReport = '${{ needs.dependency-change-report.result }}'
ossScanner = '${{ needs.oss-scanner.result }}'
}
$Results.GetEnumerator() | Sort-Object Name | ForEach-Object {
Write-Host "$($_.Name) job result: $($_.Value)"
}
$BuildRequired = -not [string]::IsNullOrWhiteSpace($env:INPUT_REF) -or
$env:EVENT_NAME -eq 'workflow_dispatch' -or
$env:BUILD_RELEVANT -ne 'false'
Write-Host "Exact runtime validation required: $BuildRequired"
$Failures = [System.Collections.Generic.List[string]]::new()
foreach ($Result in $Results.GetEnumerator()) {
if ($Result.Value -notin @('success', 'skipped')) {
$Failures.Add($Result.Name)
}
}
if ($BuildRequired) {
foreach ($RequiredJob in @('runtimeMatrix', 'build', 'runtimeTests', 'ossScanner')) {
if ($Results[$RequiredJob] -ne 'success' -and -not $Failures.Contains($RequiredJob)) {
$Failures.Add($RequiredJob)
}
}
}
if ($Failures.Count -eq 0) {
Write-Host 'Build gate passed.'
exit 0
}
Write-Host "::error::Build gate failed: $(@($Failures | Sort-Object -Unique) -join ', ')."
exit 1