Skip to content

Commit df0dd06

Browse files
committed
docs(sdk): make the reference PR's draft/ready state follow the events safely
Review finding on #1106 (nik13): a candidate event arriving after the same version-pair PR was already marked ready rewrote the branch and the body and printed "(candidate, draft)" while the PR stayed ready for merge. The PR step moves into scripts/sdk-reference-pr.sh with explicit state rules: - An existing PR that is already ready belongs to a released revision the registries confirmed; a later candidate (or any draft decision) is a stale or reordered event and is ignored outright: no push, no title/body edit, no state change, a ::notice:: saying so, exit 0. - A ready decision promotes a draft with `gh pr ready`, and a failed promotion fails the run. The final state is read back from GitHub after every run and must match the decision, or the run fails; the printed state is the real one. - A no-op diff opens nothing and closes an open PR for the release; a preview is its own draft on its own branch. scripts/sdk-reference-pr.test.mjs runs the real script against a fake `gh` (a PR-state adapter on a JSON file) and a fake `git`, asserting PR state after candidate -> released -> stale candidate -> repeated released, the failed promotion, the no-diff close, the preview branch, and a missing variable. Part of npm run test:integrations (39 tests).
1 parent c887cc9 commit df0dd06

4 files changed

Lines changed: 289 additions & 50 deletions

File tree

‎.github/workflows/sdk-reference-sync.yml‎

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -95,52 +95,7 @@ jobs:
9595
STAGE: ${{ steps.release.outputs.stage }}
9696
PUBLISH: ${{ steps.release.outputs.publish }}
9797
SOURCE: ${{ github.event.client_payload.source || format('{0}/{1}/actions/runs/{2}', github.server_url, github.repository, github.run_id) }}
98-
run: |
99-
set -eu
100-
short=${SHA:0:12}
101-
sdk="https://github.com/future-agi/futureagi-sdk"
102-
number=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[0].number // empty')
103-
if git diff --quiet -- src/pages/docs/sdk/reference src/lib/sdk-reference.mjs; then
104-
if [ -z "$number" ]; then
105-
echo "main already carries the reference of futureagi-sdk@$short; nothing to open"
106-
exit 0
107-
fi
108-
gh pr close "$number" --comment "main already carries the reference generated by futureagi-sdk@$short; nothing left to merge." \
109-
--delete-branch
110-
exit 0
111-
fi
112-
git config user.name "futureagi-release-bot[bot]"
113-
git config user.email "futureagi-release-bot[bot]@users.noreply.github.com"
114-
git switch -c "$BRANCH"
115-
git add src/pages/docs/sdk/reference src/lib/sdk-reference.mjs
116-
git commit -q -m "docs(sdk): sync the platform SDK reference from futureagi-sdk@$short" \
117-
-m "Python $PY, TypeScript $TS, backend contract $BACKEND ($STAGE)."
118-
# One branch per release: a retry or the candidate→released transition rewrites it.
119-
git push --force origin "$BRANCH"
120-
case "$STAGE" in
121-
released) title="docs(sdk): platform SDK reference for python-v$PY / typescript-v$TS"
122-
stage_note="**Released.** \`futureagi==$PY\` is on [PyPI](https://pypi.org/project/futureagi/$PY/) and \`@future-agi/sdk@$TS\` on [npm](https://www.npmjs.com/package/@future-agi/sdk/v/$TS); this PR is ready for review." ;;
123-
candidate) title="docs(sdk): platform SDK reference for python-v$PY / typescript-v$TS (candidate)"
124-
stage_note="**Candidate (draft).** The SDK release is prepared but \`futureagi==$PY\` and \`@future-agi/sdk@$TS\` are not both installable yet. The publish workflow re-dispatches once they are, and this PR is marked ready then. Do not merge before." ;;
125-
*) title="docs(sdk): platform SDK reference preview of futureagi-sdk@$short"
126-
stage_note="**Preview (draft).** Generated from \`$REF\`, which is not a published release. For looking only; the released PR for these versions is opened by the SDK publish workflow." ;;
127-
esac
128-
cat > "$RUNNER_TEMP/body.md" <<EOF
129-
Generated pages from [future-agi/futureagi-sdk@$short]($sdk/tree/$SHA/docs/sdk-reference): Python **$PY**, TypeScript **$TS**, backend contract **$BACKEND** (the SDK [sync PR]($sdk/pulls?q=is%3Apr+%22sync+with+backend+$BACKEND%22) names the backend release).
130-
131-
$stage_note
132-
133-
Copied by \`scripts/sync-sdk-reference.mjs\`; decided by \`scripts/sdk-reference-release.mjs\`. Do not edit the pages here: fix the generator in the SDK repository and re-run the sync. Source: $SOURCE
134-
EOF
135-
if [ -z "$number" ]; then
136-
draft=()
137-
[ "$PUBLISH" = draft ] && draft+=(--draft)
138-
gh pr create --base main --head "$BRANCH" --title "$title" --body-file "$RUNNER_TEMP/body.md" "${draft[@]}"
139-
number=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[0].number')
140-
else
141-
gh pr edit "$number" --title "$title" --body-file "$RUNNER_TEMP/body.md" >/dev/null
142-
fi
143-
if [ "$PUBLISH" = ready ]; then
144-
gh pr ready "$number" 2>/dev/null || true
145-
fi
146-
echo "future-agi/docs#$number ($STAGE, $PUBLISH)"
98+
# scripts/sdk-reference-pr.sh holds the state rules (a stale candidate event never
99+
# downgrades or rewrites a released PR; a ready decision is verified, not assumed)
100+
# and scripts/sdk-reference-pr.test.mjs runs it against a fake gh/git.
101+
run: bash scripts/sdk-reference-pr.sh

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"astro": "astro",
1212
"new-doc": "node scripts/new-doc.mjs",
1313
"audit-links": "node scripts/audit-links.mjs",
14-
"test:integrations": "node --test scripts/integrations.test.mjs scripts/new-doc.test.mjs scripts/sdk-reference-release.test.mjs",
14+
"test:integrations": "node --test scripts/integrations.test.mjs scripts/new-doc.test.mjs scripts/sdk-reference-release.test.mjs scripts/sdk-reference-pr.test.mjs",
1515
"test:integrations:browser": "node scripts/integrations.browser.cjs && node scripts/integrations.regression.cjs && node scripts/widget-regression.cjs && node scripts/sdk-reference-mobile.cjs",
1616
"check:integrations": "tsc --allowJs --checkJs --noEmit --strict --types node --target ES2022 --module nodenext src/lib/integrations.mjs"
1717
},

‎scripts/sdk-reference-pr.sh‎

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#!/usr/bin/env bash
2+
# Open, update, finish or skip the docs PR for one SDK release, from the synced working tree.
3+
#
4+
# Called by .github/workflows/sdk-reference-sync.yml after scripts/sync-sdk-reference.mjs has
5+
# written the pages, with the resolver's decision in the environment (see
6+
# scripts/sdk-reference-release.mjs): SHA REF PY TS BACKEND BRANCH STAGE PUBLISH SOURCE.
7+
# Needs `gh` (GH_TOKEN set) and `git`; scripts/sdk-reference-pr.test.mjs runs it against fakes.
8+
#
9+
# State rules, so that reordered or retried dispatch events cannot leave a PR in the wrong state:
10+
# - PUBLISH=ready : the PR must end up ready for review. A draft is promoted; the promotion is
11+
# verified, and a failure to promote fails this run.
12+
# - PUBLISH=draft : a NEW PR is opened as a draft. An EXISTING PR that is already ready belongs
13+
# to a released revision that the registries confirmed; a later candidate
14+
# event is stale or reordered, so it is IGNORED: neither the branch, nor the
15+
# title/body, nor the state change. The run says so and exits 0.
16+
# - no diff vs main : nothing to open; an open PR for this release is closed (main carries it).
17+
# Every state the script reports is read back from GitHub after acting, never assumed.
18+
set -euo pipefail
19+
20+
for var in SHA PY TS BACKEND BRANCH STAGE PUBLISH; do
21+
[ -n "${!var:-}" ] || { echo "::error::$var is not set" >&2; exit 2; }
22+
done
23+
: "${REF:=$SHA}"
24+
: "${SOURCE:=manual run}"
25+
short=${SHA:0:12}
26+
sdk="https://github.com/future-agi/futureagi-sdk"
27+
pages="src/pages/docs/sdk/reference src/lib/sdk-reference.mjs"
28+
29+
# The open PR for this release, if any: "<number> <true|false>" (isDraft) or empty.
30+
existing() {
31+
gh pr list --head "$BRANCH" --base main --state open --json number,isDraft \
32+
--jq '.[0] | select(. != null) | "\(.number) \(.isDraft)"'
33+
}
34+
state_of() {
35+
gh pr view "$1" --json isDraft --jq '.isDraft'
36+
}
37+
38+
read -r number is_draft <<< "$(existing || true)"
39+
number=${number:-}
40+
is_draft=${is_draft:-}
41+
42+
# shellcheck disable=SC2086
43+
if git diff --quiet -- $pages; then
44+
if [ -z "$number" ]; then
45+
echo "main already carries the reference of futureagi-sdk@$short; nothing to open"
46+
exit 0
47+
fi
48+
gh pr close "$number" --delete-branch \
49+
--comment "main already carries the reference generated by futureagi-sdk@$short; nothing left to merge."
50+
echo "future-agi/docs#$number closed: main already carries this reference"
51+
exit 0
52+
fi
53+
54+
if [ "$PUBLISH" = draft ] && [ -n "$number" ] && [ "$is_draft" = false ]; then
55+
echo "::notice::future-agi/docs#$number for python-v$PY / typescript-v$TS is already ready for review" \
56+
"(a released revision the registries confirmed); ignoring this stale $STAGE event for $short." \
57+
"Neither the branch nor the PR was changed."
58+
echo "future-agi/docs#$number (unchanged: ready, stale $STAGE event ignored)"
59+
exit 0
60+
fi
61+
62+
git config user.name "futureagi-release-bot[bot]"
63+
git config user.email "futureagi-release-bot[bot]@users.noreply.github.com"
64+
git switch -c "$BRANCH"
65+
# shellcheck disable=SC2086
66+
git add $pages
67+
git commit -q -m "docs(sdk): sync the platform SDK reference from futureagi-sdk@$short" \
68+
-m "Python $PY, TypeScript $TS, backend contract $BACKEND ($STAGE)."
69+
# One branch per release: a retry or the candidate -> released transition rewrites it.
70+
git push --force origin "$BRANCH"
71+
72+
case "$STAGE" in
73+
released)
74+
title="docs(sdk): platform SDK reference for python-v$PY / typescript-v$TS"
75+
stage_note="**Released.** \`futureagi==$PY\` is on [PyPI](https://pypi.org/project/futureagi/$PY/) and \`@future-agi/sdk@$TS\` on [npm](https://www.npmjs.com/package/@future-agi/sdk/v/$TS); this PR is ready for review." ;;
76+
candidate)
77+
title="docs(sdk): platform SDK reference for python-v$PY / typescript-v$TS (candidate)"
78+
stage_note="**Candidate (draft).** The SDK release is prepared but \`futureagi==$PY\` and \`@future-agi/sdk@$TS\` are not both installable yet. The publish workflow re-dispatches once they are, and this PR is marked ready then. Do not merge before." ;;
79+
*)
80+
title="docs(sdk): platform SDK reference preview of futureagi-sdk@$short"
81+
stage_note="**Preview (draft).** Generated from \`$REF\`, which is not a published release. For looking only; the released PR for these versions is opened by the SDK publish workflow." ;;
82+
esac
83+
84+
body_file=$(mktemp)
85+
trap 'rm -f "$body_file"' EXIT
86+
cat > "$body_file" <<EOF
87+
Generated pages from [future-agi/futureagi-sdk@$short]($sdk/tree/$SHA/docs/sdk-reference): Python **$PY**, TypeScript **$TS**, backend contract **$BACKEND** (the SDK [sync PR]($sdk/pulls?q=is%3Apr+%22sync+with+backend+$BACKEND%22) names the backend release).
88+
89+
$stage_note
90+
91+
Copied by \`scripts/sync-sdk-reference.mjs\`; decided by \`scripts/sdk-reference-release.mjs\`; opened by \`scripts/sdk-reference-pr.sh\`. Do not edit the pages here: fix the generator in the SDK repository and re-run the sync. Source: $SOURCE
92+
EOF
93+
94+
if [ -z "$number" ]; then
95+
draft=""
96+
[ "$PUBLISH" = draft ] && draft="--draft"
97+
# shellcheck disable=SC2086
98+
gh pr create --base main --head "$BRANCH" --title "$title" --body-file "$body_file" $draft >/dev/null
99+
read -r number is_draft <<< "$(existing)"
100+
[ -n "$number" ] || { echo "::error::the PR for $BRANCH was not created" >&2; exit 1; }
101+
else
102+
gh pr edit "$number" --title "$title" --body-file "$body_file" >/dev/null
103+
fi
104+
105+
# Make the real PR state match the decision, and prove it.
106+
if [ "$PUBLISH" = ready ] && [ "$is_draft" = true ]; then
107+
gh pr ready "$number" || { echo "::error::could not mark future-agi/docs#$number ready for review" >&2; exit 1; }
108+
fi
109+
final=$(state_of "$number")
110+
want=false
111+
[ "$PUBLISH" = draft ] && want=true
112+
if [ "$final" != "$want" ]; then
113+
echo "::error::future-agi/docs#$number isDraft=$final after this run, expected $want ($STAGE, $PUBLISH)" >&2
114+
exit 1
115+
fi
116+
state=ready
117+
[ "$final" = true ] && state=draft
118+
echo "future-agi/docs#$number ($STAGE, $state)"

‎scripts/sdk-reference-pr.test.mjs‎

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
// @ts-check
2+
// Lifecycle tests for scripts/sdk-reference-pr.sh: the real script runs against a fake `gh`
3+
// (a PR-state adapter persisted in a JSON file) and a fake `git`, so the assertions are on the
4+
// PR state GitHub would hold after each event, not on the resolver's decision string.
5+
import assert from 'node:assert/strict';
6+
import { spawnSync } from 'node:child_process';
7+
import fs from 'node:fs';
8+
import os from 'node:os';
9+
import path from 'node:path';
10+
import { test } from 'node:test';
11+
import { fileURLToPath } from 'node:url';
12+
13+
const SCRIPT = path.join(path.dirname(fileURLToPath(import.meta.url)), 'sdk-reference-pr.sh');
14+
15+
/** The fake `gh`: every PR mutation the script may issue, on a JSON state file. */
16+
const FAKE_GH = `#!/usr/bin/env node
17+
const fs = require('node:fs');
18+
const file = process.env.FAKE_PR_STATE;
19+
const state = JSON.parse(fs.readFileSync(file, 'utf-8'));
20+
const save = () => fs.writeFileSync(file, JSON.stringify(state, null, 1));
21+
const args = process.argv.slice(2);
22+
const log = (line) => fs.appendFileSync(process.env.FAKE_LOG, line + '\\n');
23+
log('gh ' + args.join(' '));
24+
const [cmd, sub] = args;
25+
const flag = (name) => { const i = args.indexOf(name); return i === -1 ? undefined : args[i + 1]; };
26+
const open = () => state.prs.filter((p) => p.state === 'open');
27+
if (cmd === 'pr' && sub === 'list') {
28+
const head = flag('--head');
29+
const hits = open().filter((p) => p.head === head);
30+
const jq = flag('--jq');
31+
const first = hits[0];
32+
if (jq && jq.includes('select(. != null)')) { if (first) process.stdout.write(first.number + ' ' + first.isDraft + '\\n'); process.exit(0); }
33+
process.stdout.write(JSON.stringify(hits.map((p) => ({ number: p.number, isDraft: p.isDraft }))));
34+
process.exit(0);
35+
}
36+
if (cmd === 'pr' && sub === 'create') {
37+
const number = state.next++;
38+
state.prs.push({ number, head: flag('--head'), state: 'open', isDraft: args.includes('--draft'), title: flag('--title') });
39+
save(); process.stdout.write('https://github.com/future-agi/docs/pull/' + number + '\\n'); process.exit(0);
40+
}
41+
const pr = state.prs.find((p) => String(p.number) === args[2]);
42+
if (cmd === 'pr' && sub === 'view') { process.stdout.write(String(pr.isDraft) + '\\n'); process.exit(0); }
43+
if (cmd === 'pr' && sub === 'edit') { pr.title = flag('--title'); pr.edits = (pr.edits || 0) + 1; save(); process.exit(0); }
44+
if (cmd === 'pr' && sub === 'ready') {
45+
if (process.env.FAKE_READY_FAILS === '1') { process.stderr.write('GraphQL: forbidden\\n'); process.exit(1); }
46+
pr.isDraft = false; save(); process.exit(0);
47+
}
48+
if (cmd === 'pr' && sub === 'close') { pr.state = 'closed'; save(); process.exit(0); }
49+
process.stderr.write('fake gh: unexpected ' + args.join(' ') + '\\n'); process.exit(64);
50+
`;
51+
52+
/** The fake `git`: `diff --quiet` answers from FAKE_DIFF, pushes are recorded, the rest is a no-op. */
53+
const FAKE_GIT = `#!/usr/bin/env node
54+
const fs = require('node:fs');
55+
const args = process.argv.slice(2);
56+
fs.appendFileSync(process.env.FAKE_LOG, 'git ' + args.join(' ') + '\\n');
57+
if (args[0] === 'diff' && args.includes('--quiet')) process.exit(process.env.FAKE_DIFF === '0' ? 0 : 1);
58+
process.exit(0);
59+
`;
60+
61+
function harness() {
62+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'sdk-ref-pr-'));
63+
const bin = path.join(dir, 'bin');
64+
fs.mkdirSync(bin);
65+
fs.writeFileSync(path.join(bin, 'gh'), FAKE_GH, { mode: 0o755 });
66+
fs.writeFileSync(path.join(bin, 'git'), FAKE_GIT, { mode: 0o755 });
67+
const stateFile = path.join(dir, 'prs.json');
68+
const logFile = path.join(dir, 'calls.log');
69+
fs.writeFileSync(stateFile, JSON.stringify({ next: 100, prs: [] }));
70+
fs.writeFileSync(logFile, '');
71+
const base = { SHA: 'a'.repeat(40), REF: 'python-v0.7.0', PY: '0.7.0', TS: '0.2.0', BACKEND: 'v1.58.0', SOURCE: 'test' };
72+
/** @param {{STAGE: string, PUBLISH: string, BRANCH?: string, SHA?: string, diff?: boolean, readyFails?: boolean}} ev */
73+
const run = (ev) => {
74+
const env = {
75+
...process.env, ...base, SHA: ev.SHA ?? base.SHA,
76+
BRANCH: ev.BRANCH ?? 'sdk-reference/python-v0.7.0-typescript-v0.2.0',
77+
STAGE: ev.STAGE, PUBLISH: ev.PUBLISH,
78+
PATH: `${bin}:${process.env.PATH}`, FAKE_PR_STATE: stateFile, FAKE_LOG: logFile,
79+
FAKE_DIFF: ev.diff === false ? '0' : '1', FAKE_READY_FAILS: ev.readyFails ? '1' : '0', GH_TOKEN: 'fake',
80+
};
81+
const result = spawnSync('bash', [SCRIPT], { env, encoding: 'utf-8' });
82+
return { status: result.status, out: result.stdout + result.stderr };
83+
};
84+
const prs = () => JSON.parse(fs.readFileSync(stateFile, 'utf-8')).prs;
85+
const calls = () => fs.readFileSync(logFile, 'utf-8').trim().split('\n').filter(Boolean);
86+
const resetLog = () => fs.writeFileSync(logFile, '');
87+
return { run, prs, calls, resetLog };
88+
}
89+
90+
test('candidate opens a draft; released promotes the same PR and verifies it; repeats are idempotent', () => {
91+
const h = harness();
92+
let r = h.run({ STAGE: 'candidate', PUBLISH: 'draft' });
93+
assert.equal(r.status, 0, r.out);
94+
assert.deepEqual(h.prs().map((p) => [p.number, p.isDraft, p.state]), [[100, true, 'open']]);
95+
assert.match(r.out, /#100 \(candidate, draft\)/);
96+
97+
r = h.run({ STAGE: 'released', PUBLISH: 'ready' });
98+
assert.equal(r.status, 0, r.out);
99+
assert.deepEqual(h.prs().map((p) => [p.number, p.isDraft, p.state]), [[100, false, 'open']], 'same PR, now ready');
100+
assert.match(r.out, /#100 \(released, ready\)/);
101+
assert.ok(h.calls().some((c) => c === 'gh pr ready 100'), 'the promotion was issued');
102+
103+
h.resetLog();
104+
r = h.run({ STAGE: 'released', PUBLISH: 'ready' });
105+
assert.equal(r.status, 0, r.out);
106+
assert.equal(h.prs().length, 1, 'a repeated released event opens no second PR');
107+
assert.ok(!h.calls().some((c) => c.startsWith('gh pr create')), 'no create on repeat');
108+
assert.ok(!h.calls().some((c) => c === 'gh pr ready 100'), 'no redundant promotion of a ready PR');
109+
});
110+
111+
test('a stale candidate after released is ignored: the ready PR keeps its state, branch and body', () => {
112+
const h = harness();
113+
assert.equal(h.run({ STAGE: 'candidate', PUBLISH: 'draft' }).status, 0);
114+
assert.equal(h.run({ STAGE: 'released', PUBLISH: 'ready' }).status, 0);
115+
h.resetLog();
116+
const r = h.run({ STAGE: 'candidate', PUBLISH: 'draft', SHA: 'b'.repeat(40) });
117+
assert.equal(r.status, 0, r.out);
118+
assert.deepEqual(h.prs().map((p) => [p.number, p.isDraft]), [[100, false]], 'still ready');
119+
assert.match(r.out, /stale candidate event ignored/);
120+
assert.match(r.out, /::notice::/);
121+
const calls = h.calls();
122+
assert.ok(!calls.some((c) => c.startsWith('git push')), 'the released branch was not rewritten');
123+
assert.ok(!calls.some((c) => c.startsWith('gh pr edit')), 'the released title/body were not rewritten');
124+
assert.ok(!calls.some((c) => c.startsWith('gh pr ready') || c.startsWith('gh pr create')));
125+
});
126+
127+
test('a failed promotion fails the run instead of reporting ready', () => {
128+
const h = harness();
129+
assert.equal(h.run({ STAGE: 'candidate', PUBLISH: 'draft' }).status, 0);
130+
const r = h.run({ STAGE: 'released', PUBLISH: 'ready', readyFails: true });
131+
assert.notEqual(r.status, 0, 'must not exit 0');
132+
assert.match(r.out, /could not mark future-agi\/docs#100 ready/);
133+
assert.deepEqual(h.prs().map((p) => p.isDraft), [true], 'the PR is honestly still a draft');
134+
});
135+
136+
test('no diff against main: nothing is opened, and an open PR for the release is closed', () => {
137+
const h = harness();
138+
let r = h.run({ STAGE: 'released', PUBLISH: 'ready', diff: false });
139+
assert.equal(r.status, 0, r.out);
140+
assert.equal(h.prs().length, 0);
141+
assert.match(r.out, /nothing to open/);
142+
assert.equal(h.run({ STAGE: 'candidate', PUBLISH: 'draft' }).status, 0);
143+
r = h.run({ STAGE: 'released', PUBLISH: 'ready', diff: false });
144+
assert.equal(r.status, 0, r.out);
145+
assert.deepEqual(h.prs().map((p) => p.state), ['closed']);
146+
});
147+
148+
test('a preview is its own draft PR on its own branch and never touches a release PR', () => {
149+
const h = harness();
150+
assert.equal(h.run({ STAGE: 'released', PUBLISH: 'ready' }).status, 0);
151+
const r = h.run({ STAGE: 'preview', PUBLISH: 'draft', BRANCH: 'sdk-reference/preview-bbbbbbbbbbbb', SHA: 'b'.repeat(40) });
152+
assert.equal(r.status, 0, r.out);
153+
assert.deepEqual(h.prs().map((p) => [p.head, p.isDraft]), [
154+
['sdk-reference/python-v0.7.0-typescript-v0.2.0', false],
155+
['sdk-reference/preview-bbbbbbbbbbbb', true],
156+
]);
157+
assert.match(r.out, /#101 \(preview, draft\)/);
158+
});
159+
160+
test('a missing decision variable is a usage error, not a half-run', () => {
161+
const h = harness();
162+
const r = h.run({ STAGE: 'released', PUBLISH: '' });
163+
assert.equal(r.status, 2);
164+
assert.match(r.out, /PUBLISH is not set/);
165+
assert.equal(h.prs().length, 0);
166+
});

0 commit comments

Comments
 (0)