diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml index dc4589a3..eb798bdf 100644 --- a/.github/workflows/publish-packages.yml +++ b/.github/workflows/publish-packages.yml @@ -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/') diff --git a/docs/semver-policy.md b/docs/semver-policy.md index d1d9a3ed..9a2ce559 100644 --- a/docs/semver-policy.md +++ b/docs/semver-policy.md @@ -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 diff --git a/scripts/check-changelog-semver.test.mjs b/scripts/check-changelog-semver.test.mjs index 9d8424e0..39c07799 100644 --- a/scripts/check-changelog-semver.test.mjs +++ b/scripts/check-changelog-semver.test.mjs @@ -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"/);