Release guard tidy: the Python build guard starts without NODE_OPTIONS too
The python-build step runs the same guard whose output is the dist PyPI uploads, so a NODE_OPTIONS preload in the workflow or job env could stub its checks exactly as it could on the npm Publish line. It now starts under env -u NODE_OPTIONS; the pin's exact text and semver-policy.md say so. The pin test's if: always() edit matched the npm line's old text and had become a no-op; it now matches the pinned line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
49a5526ede
commit
a126914efc
3 changed files with 10 additions and 8 deletions
5
.github/workflows/publish-packages.yml
vendored
5
.github/workflows/publish-packages.yml
vendored
|
|
@ -146,10 +146,11 @@ jobs:
|
|||
# the release-checks suite, on a tag the semver policy check
|
||||
# (docs/semver-policy.md), and the package's unit tests, and only then
|
||||
# builds the sdist and wheel. Publish uploads only what this step built,
|
||||
# so it has nothing to upload unless every check passed.
|
||||
# so it has nothing to upload unless every check passed. It starts without
|
||||
# NODE_OPTIONS, so no preloaded module runs inside it.
|
||||
- name: Build sdist and wheel
|
||||
if: steps.selected.outputs.run == 'true'
|
||||
run: node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} "$GITHUB_REF"
|
||||
run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} "$GITHUB_REF"
|
||||
|
||||
- name: Publish
|
||||
if: steps.selected.outputs.run == 'true' && startsWith(github.ref, 'refs/tags/')
|
||||
|
|
|
|||
|
|
@ -312,9 +312,10 @@ removed (`NODE_OPTIONS`, `NODE_TEST_CONTEXT`, any other `NODE_TEST_*` variable,
|
|||
and `NODE_AUTH_TOKEN`), so none of those can make the tests run nothing and
|
||||
pass, and only the release action receives the token. That list names known
|
||||
variables; it does not prove that no other inherited variable can affect a
|
||||
check. The npm Publish step starts the guard under `env -u NODE_OPTIONS`, so a
|
||||
`NODE_OPTIONS` preload set in the workflow's or job's `env:` cannot run code
|
||||
inside the guard before its first line.
|
||||
check. The npm Publish step and the Python sdist and wheel build step start the
|
||||
guard under `env -u NODE_OPTIONS`, so a `NODE_OPTIONS` preload set in the
|
||||
workflow's or job's `env:` cannot run code inside the guard before its first
|
||||
line.
|
||||
The gate is that call, not a step condition, so no `if:` or `continue-on-error`
|
||||
can release what a check refused. The tests compare each job's release steps
|
||||
with their expected text exactly, less the steps' `if:` lines. Removing the call
|
||||
|
|
|
|||
|
|
@ -772,7 +772,7 @@ const RELEASE_STEPS = {
|
|||
],
|
||||
// Publish uploads only the dist the guarded step built, so it has nothing to upload unless the suite passed.
|
||||
python: [
|
||||
["- name: Build sdist and wheel", " run: node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} \"$GITHUB_REF\""],
|
||||
["- name: Build sdist and wheel", " run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} \"$GITHUB_REF\""],
|
||||
["- name: Publish", " uses: pypa/gh-action-pypi-publish@release/v1", " with:", " packages-dir: packages/${{ matrix.package }}/dist"],
|
||||
],
|
||||
};
|
||||
|
|
@ -831,7 +831,7 @@ test("workflow: each job releases only through release-after-suite.mjs", () => {
|
|||
const workflow = workflowText();
|
||||
assert.deepEqual(workflowReleaseProblems(workflow), []);
|
||||
const npmRun = 'run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs npm-publish packages/cultcache-ts "$GITHUB_REF"';
|
||||
const pythonRun = 'run: node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} "$GITHUB_REF"';
|
||||
const pythonRun = 'run: env -u NODE_OPTIONS node scripts/release-after-suite.mjs python-build packages/${{ matrix.package }} "$GITHUB_REF"';
|
||||
const exact = /is not exactly the release call/;
|
||||
for (const run of [npmRun, pythonRun]) {
|
||||
assert.equal(workflow.split(run).length, 2, run);
|
||||
|
|
@ -847,7 +847,7 @@ test("workflow: each job releases only through release-after-suite.mjs", () => {
|
|||
}
|
||||
// the guard runs every release check itself, so neither the release steps' conditions nor a job allowed
|
||||
// to fail can release what a check refused
|
||||
assert.deepEqual(workflowReleaseProblems(workflow.replace(/if: startsWith\(github\.ref, 'refs\/tags\/cultcache-ts-v'\)(\r?\n\s+run: node)/, "if: always()$1")), []);
|
||||
assert.deepEqual(workflowReleaseProblems(workflow.replace(/if: startsWith\(github\.ref, 'refs\/tags\/cultcache-ts-v'\)(\r?\n\s+run: env -u NODE_OPTIONS node)/, "if: always()$1")), []);
|
||||
assert.deepEqual(workflowReleaseProblems(workflow.replace(/( runs-on: ubuntu-latest\r?\n)/, "$1 continue-on-error: true\n")), []);
|
||||
// a release step removed, renamed or doubled, a Publish that uploads another dist, an unknown job
|
||||
assert.match(workflowReleaseProblems(workflow.replace("- name: Build sdist and wheel", "- name: Build")).join("\n"), /needs exactly one step "- name: Build sdist and wheel"/);
|
||||
|
|
|
|||
Loading…
Reference in a new issue