Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

fix(release): reuse exact main Linux CI [C7]

Corey Olson4701bd21a8cc
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 6dff656f..62d1ee17 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -1,5 +1,5 @@
-# A release is a tag on a green commit (I15). Pushing a tag vX.Y.Z runs the gate on that exact commit,
-# checks the tag matches package.json's version, and publishes to npm with provenance through npm's
+# A release is a tag on a green commit (I15). Pushing a tag vX.Y.Z checks the Linux gate jobs for that
+# exact commit on main, checks package.json's version, and publishes to npm with provenance through npm's
# trusted publishing: no token is stored anywhere. npmjs.com must list this workflow (release.yml in
# pullboard-dev/pullboard) as the package's trusted publisher, set once by the person.
name: release
@@ -10,6 +10,7 @@ on:
permissions:
contents: read
+ actions: read
id-token: write
jobs:
@@ -25,7 +26,40 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- name: The tag names package.json's version
run: test "v$(node -p "require('./package.json').version")" = "$GITHUB_REF_NAME"
- - run: npm run gate
+ - name: Main CI passed this commit
+ id: main-ci
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ set -euo pipefail
+ run_id=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow gate.yml --branch main --event push --commit "$GITHUB_SHA" --limit 1 --json databaseId --jq '.[0].databaseId // empty')
+ if [ -z "$run_id" ]; then
+ printf '::error::No gate.yml run for commit %s on main; refusing npm publish.\n' "$GITHUB_SHA"
+ exit 1
+ fi
+ if ! gh run view "$run_id" --repo "$GITHUB_REPOSITORY" --json databaseId,headSha,headBranch,event,url,jobs > "$RUNNER_TEMP/release-gate.json"; then
+ printf '::error::Could not read gate.yml run %s; refusing npm publish.\n' "$run_id"
+ exit 1
+ fi
+ node --input-type=module <<'NODE'
+ import { appendFileSync, readFileSync } from 'node:fs';
+ import { join } from 'node:path';
+ const run = JSON.parse(readFileSync(join(process.env.RUNNER_TEMP, 'release-gate.json'), 'utf8'));
+ const label = `gate.yml run ${run.databaseId} (${run.url})`;
+ const linux = (run.jobs ?? []).filter(job => /^linux(?:\s|$)/u.test(job.name));
+ const failed = linux.filter(job => job.status !== 'completed' || job.conclusion !== 'success');
+ if (run.headSha !== process.env.GITHUB_SHA || run.headBranch !== 'main' || run.event !== 'push') {
+ throw new Error(`${label} is not main CI for tagged commit ${process.env.GITHUB_SHA}; refusing npm publish.`);
+ }
+ if (!linux.length) throw new Error(`${label} has no Linux jobs; refusing npm publish.`);
+ if (failed.length) {
+ const names = failed.map(job => `${job.name}: ${job.status}/${job.conclusion || 'pending'}`).join(', ');
+ throw new Error(`${label} has Linux jobs that did not succeed: ${names}; refusing npm publish.`);
+ }
+ console.log(`${label}: all ${linux.length} Linux jobs succeeded for ${run.headSha}.`);
+ appendFileSync(process.env.GITHUB_OUTPUT, 'passed=true\n');
+ NODE
- name: npm new enough for trusted publishing
run: npm install -g npm@latest
- - run: npm publish --provenance --access public
+ - if: ${{ steps.main-ci.outputs.passed == 'true' }}
+ run: npm publish --provenance --access public
diff --git a/test/ci.test.js b/test/ci.test.js
index 4fe1a365..cba15b07 100644
--- a/test/ci.test.js
+++ b/test/ci.test.js
@@ -4,12 +4,76 @@
* on private repositories. The workflow is read as text: the suite has no YAML parser and needs none.
*/
import assert from 'node:assert/strict';
-import { readFileSync } from 'node:fs';
-import { resolve } from 'node:path';
+import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
import { test } from 'node:test';
+import { runFixtureChild } from './fixture-child.js';
const ROOT = resolve(import.meta.dirname, '..');
const WORKFLOW = readFileSync(resolve(ROOT, '.github/workflows/gate.yml'), 'utf8');
+const RELEASE = readFileSync(resolve(ROOT, '.github/workflows/release.yml'), 'utf8');
+
+/** Execute the workflow's actual decision code against a saved API response in a private folder. */
+function releaseDecision(t, script, run) {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-release-ci-'));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const output = join(directory, 'outputs');
+ writeFileSync(join(directory, 'release-gate.json'), JSON.stringify(run));
+ const result = runFixtureChild(process.execPath, ['--input-type=module', '-e', script], {
+ cwd: directory, encoding: 'utf8',
+ env: { ...process.env, RUNNER_TEMP: directory, GITHUB_OUTPUT: output, GITHUB_SHA: 'a'.repeat(40) },
+ });
+ return { ...result, approved: existsSync(output) ? readFileSync(output, 'utf8') : '' };
+}
+
+/** Require a real completed Linux matrix; other platforms do not replace its evidence. */
+function assertReleaseDecisions(t, script) {
+ const linux = ['22.13', '24'].flatMap(node => [1, 2, 3].map(shard => ({
+ name: `linux (${node}) ${shard}/3`, status: 'completed', conclusion: 'success',
+ })));
+ const run = { databaseId: 123, url: 'https://github.com/example/project/actions/runs/123',
+ headSha: 'a'.repeat(40), headBranch: 'main', event: 'push', jobs: [...linux,
+ { name: 'macos (24) 1/2', status: 'in_progress', conclusion: '' }] };
+ const green = releaseDecision(t, script, run);
+ assert.equal(green.status, 0, green.context);
+ assert.equal(green.approved, 'passed=true\n', 'passing Linux jobs permit the publish step while macOS still runs');
+ for (const conclusion of ['failure', 'cancelled', 'skipped', 'neutral', 'timed_out', '']) {
+ const jobs = linux.map((job, index) => index ? job : { ...job,
+ status: conclusion ? 'completed' : 'in_progress', conclusion });
+ const red = releaseDecision(t, script, { ...run, jobs });
+ assert.equal(red.status, 1, red.context);
+ assert.equal(red.approved, '', `${conclusion || 'pending'} never authorizes publication`);
+ assert.match(red.stderr, /gate\.yml run 123.*Linux jobs that did not succeed: linux \(22\.13\) 1\/3/u,
+ 'the refusal names the gate run and the exact failed or unfinished Linux job');
+ }
+ for (const change of [{ jobs: [] }, { headSha: 'b'.repeat(40) }, { headBranch: 'topic' }, { event: 'pull_request' }]) {
+ const red = releaseDecision(t, script, { ...run, ...change });
+ assert.equal(red.status, 1, red.context);
+ assert.equal(red.approved, '', 'absent jobs or a different CI origin never authorize publication');
+ assert.match(red.stderr, /gate\.yml run 123.*refusing npm publish/u);
+ }
+}
+
+test('a tag publishes only a commit main CI passed [C7]', (t) => {
+ assert.doesNotMatch(RELEASE, /npm\s+(?:run\s+gate|test)\b/u, 'a release reuses main CI instead of starting a different gate');
+ assert.match(RELEASE, /\n actions: read\n/u, 'the workflow can read the exact gate run');
+ assert.match(RELEASE, /gh run list[^\n]*--workflow gate\.yml[^\n]*--branch main[^\n]*--event push[^\n]*--commit "\$GITHUB_SHA"/u,
+ 'the evidence comes from main push CI for the tagged commit');
+ assert.match(RELEASE, /if \[ -z "\$run_id" \]; then\n[^\n]*No gate\.yml run[^\n]*\n\s+exit 1/u,
+ 'a missing run refuses publication explicitly');
+ assert.match(RELEASE, /gh run view "\$run_id"[^\n]*--json [^\n]*headSha[^\n]*jobs/u,
+ 'the selected run supplies commit identity and individual job results');
+ assert.match(RELEASE, /id: main-ci\n/u);
+ assert.match(RELEASE, /- if: \$\{\{ steps\.main-ci\.outputs\.passed == 'true' \}\}\n\s+run: npm publish --provenance --access public/u,
+ 'publication requires the main-CI decision and retains trusted provenance publishing');
+ assert.ok(RELEASE.indexOf('id: main-ci') < RELEASE.indexOf('run: npm publish'), 'CI evidence is checked before publishing');
+ assert.ok(RELEASE.includes('test "v$(node -p "require(\'./package.json\').version")" = "$GITHUB_REF_NAME"'),
+ 'the tag must still match the package version');
+ const match = RELEASE.match(/node --input-type=module <<'NODE'\n([\s\S]*?)\n {10}NODE/u);
+ assert.ok(match, 'the workflow contains its executable CI decision');
+ assertReleaseDecisions(t, match[1].replace(/^ {10}/gmu, ''));
+});
/**
* One job's text, from its name to the next job or the end.