From 919398e096f936e174509ef81eb1b80df82b00b3 Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 16 Nov 2026 09:14:44 -0800 Subject: [PATCH 1/2] fix(release): the composed computers' state folder is the compose step's, since a job's env can't read the runner GitHub refused publish-pypi.yml since #705, as a job's own env named runner.temp, so v0.9.1542's tag started no release. The folder is set on the step that composes, and a test checks every workflow's job env reads only what a job can. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/publish-pypi.yml | 4 +++- tst/unit/test_release_infra_images.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 804bfc30b..03105df22 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -384,7 +384,6 @@ jobs: contents: read env: ARCH: ${{ matrix.arch }} - XDG_STATE_HOME: ${{ runner.temp }}/state AGENT_ENV_DOCUMENT_STORE: local AGENT_ENV_OBJECT_STORE: local steps: @@ -414,7 +413,10 @@ jobs: docker run --detach --name registry --publish 5000:5000 \ --volume "$RUNNER_TEMP/computers/registry:/var/lib/registry" mirror.gcr.io/library/registry:2 timeout 30 sh -c 'until curl -sf http://localhost:5000/v2/ >/dev/null; do sleep 1; done' + # The runner context is a step's, not a job's. - name: Compose and probe + env: + XDG_STATE_HOME: ${{ runner.temp }}/state run: | "$RUNNER_TEMP/venv/bin/python" .github/scripts/release_computers.py compose "$ARCH" \ "$RUNNER_TEMP/computers/composed" diff --git a/tst/unit/test_release_infra_images.py b/tst/unit/test_release_infra_images.py index db7f189a2..4c88bb045 100644 --- a/tst/unit/test_release_infra_images.py +++ b/tst/unit/test_release_infra_images.py @@ -50,6 +50,20 @@ def _finished(job: str) -> str: return f"""contains(fromJSON('["success", "skipped"]'), needs.{job}.result)""" +# What a job's own env can read; a step's can read the runner too (docs.github.com, "Context availability"). +_JOB_ENV_CONTEXTS = {"github", "inputs", "matrix", "needs", "secrets", "strategy", "vars"} + + +@pytest.mark.parametrize("path", sorted((REPO / ".github" / "workflows").glob("*.yml")), ids=lambda path: path.name) +def test_a_jobs_own_env_reads_only_the_contexts_a_job_has(path): + """GitHub refuses the whole workflow file otherwise, so a release tag starts no run at all.""" + jobs = yaml.safe_load(path.read_text()).get("jobs", {}) + read = {(name, context) for name, body in jobs.items() for value in (body.get("env") or {}).values() + for context in re.findall(r"\$\{\{[^}]*?\b([a-z_]+)\.", str(value))} + + assert {(name, context) for name, context in read if context not in _JOB_ENV_CONTEXTS} == set() + + @pytest.mark.parametrize("job", sorted(JOBS)) def test_a_job_that_installs_agent_env_holds_no_token_that_writes(job): """Then a dependency's code never runs where a token can push an image, publish to PyPI or edit the repository.""" From bdb371c52eb8a5221193758189c207f092094b9e Mon Sep 17 00:00:00 2001 From: Edgar Arakelyan Date: Mon, 16 Nov 2026 09:19:31 -0800 Subject: [PATCH 2/2] test(release): every context a job env's expression reads is checked, not only its first Co-Authored-By: Claude Opus 5.5 --- tst/unit/test_release_infra_images.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tst/unit/test_release_infra_images.py b/tst/unit/test_release_infra_images.py index 4c88bb045..b8c092359 100644 --- a/tst/unit/test_release_infra_images.py +++ b/tst/unit/test_release_infra_images.py @@ -54,12 +54,25 @@ def _finished(job: str) -> str: _JOB_ENV_CONTEXTS = {"github", "inputs", "matrix", "needs", "secrets", "strategy", "vars"} +def _job_env_contexts(jobs: dict) -> set[tuple[str, str]]: + """Each (job, context) a job's own env reads: in each of its expressions, with their quoted strings left out, every + name that opens a property path, not one that follows a dot or is part of a hyphened id (``needs.infra-plan``).""" + return {(name, context) for name, body in jobs.items() for value in (body.get("env") or {}).values() + for expression in re.findall(r"\$\{\{(.*?)\}\}", str(value)) + for context in re.findall(r"(?