فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
ci(a08): activate targeted installed native benchmark workflow (#200)
* ci(a08): stage standalone manual NSIS artifact reuse workflow * ci(a08): reject foreign artifact runs and verify native workflow provenance * ci(a08): verify reusable native artifact availability and archive digest * ci(a08): fail closed on downloaded NSIS archive SHA256 mismatch
davoodmehraban89 committed
Nov 23, 2026 at 22:21 UTC
e4f9b020f50ba617db7f4a9fdd5eadc8fb6f0fa2
1 file changed
+99
.github/workflows/a08-targeted-native-reuse.yml
new
+99
@@ -0,0 +1,99 @@
1
+name: A08 targeted installed Windows benchmark (reuse NSIS)
2
+on:
3
+ workflow_dispatch:
4
+ inputs:
5
+ artifact_run_id:
6
+ description: 'Native Windows workflow run holding candidate NSIS from this exact commit'
7
+ required: true
8
+ type: string
9
+ source_sha:
10
+ description: 'Exact 40-character commit SHA used to build the installer (not the workflow dispatch SHA)'
11
+ required: true
12
+ type: string
13
+ expected_version:
14
+ description: 'Candidate installer version from that run'
15
+ required: true
16
+ type: string
17
+permissions:
18
+ contents: read
19
+ actions: read
20
+jobs:
21
+ targeted-native-a08:
22
+ runs-on: windows-latest
23
+ timeout-minutes: 35
24
+ steps:
25
+ # Re-run the benchmark harness from the exact binary-producing commit.
26
+ # The workflow_dispatch event itself may be at a newer commit.
27
+ - uses: actions/checkout@v4
28
+ with:
29
+ ref: ${{ inputs.source_sha }}
30
+ persist-credentials: false
31
+ - uses: actions/setup-node@v4
32
+ with:
33
+ node-version: '22'
34
+ - name: Verify artifact source SHA and workflow identity
35
+ shell: pwsh
36
+ env:
37
+ GH_TOKEN: ${{ github.token }}
38
+ SOURCE_RUN: ${{ inputs.artifact_run_id }}
39
+ SOURCE_SHA: ${{ inputs.source_sha }}
40
+ EXPECTED_VERSION: ${{ inputs.expected_version }}
41
+ run: |
42
+ if ($env:SOURCE_RUN -notmatch '^[0-9]+$') { throw 'Invalid source run ID' }
43
+ if ($env:SOURCE_SHA -notmatch '^[a-fA-F0-9]{40}$') { throw 'Invalid source commit SHA' }
44
+ if ((git rev-parse HEAD).Trim() -ne $env:SOURCE_SHA) { throw 'Checked out source SHA mismatch' }
45
+ if ($env:EXPECTED_VERSION -notmatch '^\d+\.\d+\.\d+$') { throw 'Invalid candidate version' }
46
+ $run=gh api "repos/$env:GITHUB_REPOSITORY/actions/runs/$env:SOURCE_RUN" | ConvertFrom-Json
47
+ # Reject artifacts produced by a fork or by an unrelated workflow.
48
+ $repo=gh api "repos/$env:GITHUB_REPOSITORY" | ConvertFrom-Json
49
+ if ($run.repository.id -ne $repo.id -or $run.head_repository.id -ne $repo.id -or
50
+ $run.head_sha -ne $env:SOURCE_SHA -or $run.status -ne 'completed' -or
51
+ $run.conclusion -ne 'success' -or $run.event -notin @('pull_request','push','workflow_dispatch') -or
52
+ $run.path -notmatch '(^|/)windows-vm-native-lab[.]yml(@|$)') {
53
+ throw 'Source must be a successful first-party native lab run on exactly this commit'
54
+ }
55
+ $artifacts=gh api "repos/$env:GITHUB_REPOSITORY/actions/runs/$env:SOURCE_RUN/artifacts?per_page=100" | ConvertFrom-Json
56
+ $candidate=@($artifacts.artifacts | Where-Object { $_.name -eq 'phase-a-native-candidate-nsis' })
57
+ if ($candidate.Count -ne 1 -or $candidate[0].expired -or
58
+ $candidate[0].size_in_bytes -lt 500000 -or
59
+ $candidate[0].digest -notmatch '^sha256:[a-fA-F0-9]{64}$') {
60
+ throw 'Missing, expired, duplicated or unverifiable native candidate artifact'
61
+ }
62
+ Write-Host ("Verified candidate run "+$run.html_url+" SHA "+$run.head_sha+
63
+ " artifact "+$candidate[0].id+" archive digest "+$candidate[0].digest)
64
+ - name: Download and independently verify NSIS artifact archive SHA256
65
+ shell: pwsh
66
+ env:
67
+ GH_TOKEN: ${{ github.token }}
68
+ SOURCE_RUN: ${{ inputs.artifact_run_id }}
69
+ run: |
70
+ $ErrorActionPreference='Stop'
71
+ $artifacts=gh api "repos/$env:GITHUB_REPOSITORY/actions/runs/$env:SOURCE_RUN/artifacts?per_page=100" | ConvertFrom-Json
72
+ $candidate=@($artifacts.artifacts | Where-Object { $_.name -eq 'phase-a-native-candidate-nsis' })
73
+ if ($candidate.Count -ne 1 -or $candidate[0].expired -or
74
+ $candidate[0].digest -notmatch '^sha256:[a-fA-F0-9]{64}$') { throw 'Candidate artifact is missing or unverifiable' }
75
+ $zip=Join-Path $env:RUNNER_TEMP 'verified-a08-nsis.zip'
76
+ $headers=@{ Authorization="Bearer $env:GH_TOKEN"; Accept='application/vnd.github+json'; 'X-GitHub-Api-Version'='2022-11-28' }
77
+ Invoke-WebRequest -Uri "https://api.github.com/repos/$env:GITHUB_REPOSITORY/actions/artifacts/$($candidate[0].id)/zip" -Headers $headers -OutFile $zip
78
+ $actual=(Get-FileHash -LiteralPath $zip -Algorithm SHA256).Hash.ToLowerInvariant()
79
+ $expected=($candidate[0].digest -split ':',2)[1].ToLowerInvariant()
80
+ if ($actual -ne $expected) { throw "Downloaded artifact archive SHA256 mismatch: $actual" }
81
+ New-Item -ItemType Directory -Path test-installer -Force | Out-Null
82
+ Expand-Archive -LiteralPath $zip -DestinationPath test-installer -Force
83
+ Write-Host "Verified downloaded native artifact archive SHA256: $actual"
84
+ - name: Run only real installed WebView2 A08 10k/50k benchmark
85
+ shell: pwsh
86
+ env:
87
+ EXPECTED_VERSION: ${{ inputs.expected_version }}
88
+ run: |
89
+ $files=@(Get-ChildItem test-installer -Recurse -Filter '*x64-setup.exe')
90
+ if ($files.Count -ne 1) { throw 'Expected exactly one reused NSIS installer' }
91
+ ./scripts/windows-vm-targeted-a08.ps1 -Installer $files[0].FullName -ExpectedVersion $env:EXPECTED_VERSION
92
+ - name: Upload targeted native A08 evidence
93
+ if: always()
94
+ uses: actions/upload-artifact@v4
95
+ with:
96
+ name: a08-targeted-installed-webview2-evidence
97
+ path: ${{ runner.temp }}/factor-a08-targeted-native/reports/*.json
98
+ retention-days: 14
99
+ if-no-files-found: warn