ReviewOS

also looking at this

craft-native/craft

Stop re-running the first-party Zig dependency setup

#324
Merged glennmichael123 wants to merge fix/duplicate-zig-deps-step into main
3 files +16 -9
.github/workflows/ci.ymlmodified+0-3
Changes to .github/workflows/ci.yml
@@ -65,9 +65,6 @@ jobs:
6565 VERSION="$(bun -p "require('./package.json').version")"
6666 bun scripts/verify-native-startup.ts packages/zig/zig-out/bin/craft "$VERSION"
6767
68 - name: First-party Zig dependencies
69 uses: ./.github/actions/first-party-zig-deps
70
7168 - name: Test Zig core
7269 working-directory: packages/zig
7370 run: zig build test
.github/workflows/release.ymlmodified+0-6
Changes to .github/workflows/release.yml
@@ -89,9 +89,6 @@ jobs:
8989 run: bun run build:core
9090
9191 # ── Cross-compile all targets ────────────────────────────────
92 - name: First-party Zig dependencies
93 uses: ./.github/actions/first-party-zig-deps
94
9592 - name: Cross-compile additional targets (macOS)
9693 if: runner.os == 'macOS'
9794 working-directory: packages/zig
@@ -154,9 +151,6 @@ jobs:
154151 check zig-out/bin/craft
155152 check zig-out/cross/darwin-x64/craft
156153
157 - name: First-party Zig dependencies
158 uses: ./.github/actions/first-party-zig-deps
159
160154 - name: Cross-compile additional targets (Linux)
161155 if: runner.os == 'Linux'
162156 working-directory: packages/zig
scripts/release-workflow.test.tsmodified+16-0
Changes to scripts/release-workflow.test.ts
@@ -100,3 +100,19 @@ test('SBOM generation validates required documents before uploading artifacts',
100100 expect(workflow.jobs['vulnerability-scan'].steps!.find(step => step.uses?.startsWith('actions/download-artifact@'))?.uses).toBe(artifactDownload)
101101 expect(release.jobs['attach-release-sbom'].steps!.find(step => step.uses?.startsWith('actions/download-artifact@'))?.uses).toBe(artifactDownload)
102102})
103
104// A composite action under .github/actions is setup: it clones pinned
105// dependencies, installs a toolchain, and returns early when the work is
106// already done. Running one twice in a job is therefore always waste rather
107// than intent, and it happens by accident when two pull requests insert steps
108// into the same region. Repeating a published action can be deliberate --
109// uploading two artifacts, say -- so only local ones are checked here.
110test('no job runs the same local composite action twice', () => {
111 for (const file of ['ci.yml', 'release.yml', 'sbom.yml', 'mobile-e2e.yml']) {
112 const workflow = Bun.YAML.parse(readFileSync(join(import.meta.dir, '../.github/workflows/', file), 'utf8')) as { jobs: Record<string, Job> }
113 for (const [name, job] of Object.entries(workflow.jobs)) {
114 const local = (job.steps ?? []).map(step => step.uses).filter((uses): uses is string => uses?.startsWith('./') ?? false)
115 expect(new Set(local).size, `${file} job ${name} repeats a local action: ${local.join(', ')}`).toBe(local.length)
116 }
117 }
118})