ReviewOS

also looking at this

craft-native/craft

Gate releases on shipped artifact findings

#316
Merged glennmichael123 wants to merge codex/gate-shipped-artifacts into main
11 files +454 -25

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

.github/workflows/release.ymlmodified+0-1
Changes to .github/workflows/release.yml
@@ -314,7 +314,6 @@ jobs:
314314 env:
315315 CRAFT_PLATFORM: ${{ runner.os == 'macOS' && 'macos' || 'linux' }}
316316 run: bun scripts/scan-release-artifacts.ts "$CRAFT_PLATFORM" packages/zig/zig-out "$RUNNER_TEMP/native-release-scan"
317 done
318317
319318 # ── Publish & Release ──────────────────────────────
320319 # Pantry action handles everything:
scripts/release-workflow.test.tsmodified+2-0
Changes to scripts/release-workflow.test.ts
@@ -45,6 +45,8 @@ test('npm publication follows artifact validation, and macOS downloads run on bo
4545 const native = release.jobs.pantry.steps!
4646 expect(native.findIndex(step => step.name === 'Scan binaries prepared for publication')).toBeGreaterThan(native.findIndex(step => step.name === 'Notarize macOS binaries'))
4747 expect(native.findIndex(step => step.name === 'Publish & Release')).toBeGreaterThan(native.findIndex(step => step.name === 'Scan binaries prepared for publication'))
48 expect(native.find(step => step.name === 'Scan binaries prepared for publication')?.run)
49 .toBe('bun scripts/scan-release-artifacts.ts "$CRAFT_PLATFORM" packages/zig/zig-out "$RUNNER_TEMP/native-release-scan"')
4850 expect(native.filter(step => step.uses === './.github/actions/setup-release-scanners')).toHaveLength(1)
4951 expect(release.jobs.npm.steps!.filter(step => step.uses === './.github/actions/setup-release-scanners')).toHaveLength(1)
5052 expect(release.jobs['verify-macos-downloads'].strategy?.matrix.platform).toEqual([
scripts/scan-release-artifacts.test.tsmodified+10-0
Changes to scripts/scan-release-artifacts.test.ts
@@ -48,6 +48,16 @@ test('Bun audit parser fails closed and only High or Critical blocks', () => {
4848 expect(() => summarizeBunAudit(invalid)).toThrow()
4949})
5050
51test('release scanner rejects extra arguments before scanning', () => {
52 const result = Bun.spawnSync([
53 process.execPath,
54 join(import.meta.dir, 'scan-release-artifacts.ts'),
55 'linux', '/missing', '/missing', 'done',
56 ], { stdout: 'pipe', stderr: 'pipe' })
57 expect(result.exitCode).not.toBe(0)
58 expect(result.stderr.toString()).toContain('Usage: scan-release-artifacts.ts')
59})
60
5161function binary(root: string, path: string, magic: string) {
5262 const absolute = join(root, path)
5363 mkdirSync(join(absolute, '..'), { recursive: true })
scripts/scan-release-artifacts.tsmodified+4-2
Changes to scripts/scan-release-artifacts.ts
@@ -160,8 +160,10 @@ function scanNative(binaryRoot: string, platform: 'macos' | 'linux', output: str
160160}
161161
162162if (import.meta.main) {
163 const [mode, input, output] = Bun.argv.slice(2)
164 if (!mode || !input || !output) throw new Error('Usage: scan-release-artifacts.ts <npm|macos|linux> <input> <output>')
163 const args = Bun.argv.slice(2)
164 if (args.length !== 3 || args.some(arg => !arg))
165 throw new Error('Usage: scan-release-artifacts.ts <npm|macos|linux> <input> <output>')
166 const [mode, input, output] = args as [string, string, string]
165167 const syft = process.env.CRAFT_SYFT ?? 'syft'
166168 const grype = process.env.CRAFT_GRYPE ?? 'grype'
167169 if (mode === 'npm') scanNpm(resolve(input), resolve(output), syft, grype)