From 1079f48febac65f3cc12bf38d1b738c5348f975b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 21:30:48 +0200 Subject: [PATCH 1/8] fix(env): derive the image and container names from the distro under test A compose deploy job labelled centos or arch built its stack image from pkgmgr-debian and ran it as infinito_nexus_debian (#794). distros.sh exports INFINITO_DISTRO per iteration and sources load.sh again, but the loader returned early because INFINITO_ENV_LOADED and the .env mtime were unchanged. A full reload would not have helped either: the debian values were already exported, so the restore step kept them as caller intent. load.sh now records the distro it loaded for. Another INFINITO_DISTRO defeats the early return and drops INFINITO_CONTAINER, INFINITO_PARENT_IMAGE and INFINITO_IMAGE, the three keys the env handlers derive from the distro. When the requested distro also differs from the one .env was generated for, the loader sources a set that `python -m cli.meta.env --output` generates for it in a private temp directory and leaves .env untouched, so a local multi-distro run does not switch the checkout's distro. A caller value set for the loaded distro still wins. Verified: tests/unit/python/scripts/meta/env/test_load.py and the new distros.sh case pass. Against main's loader both fail with the symptom of the issue: INFINITO_DISTRO=centos next to infinito_nexus_debian and pkgmgr-debian:stable, and distros.sh handing debian, arch and centos the same debian parent. shellcheck is clean. Consequence: CI jobs labelled arch, ubuntu, fedora or centos now build and deploy that distro, so a failure that shows up there was masked before. feature/store-i18n carries 3f973eb137, which resolves the parent image for scripts/image/push.sh on its own, and 05e4dbafcb, which inserts the INFINITO_INSTANCE slot check into the block this commit restructures. The merge keeps the slot check ahead of the distro check. Closes #794 Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/meta/env/__main__.py | 35 +++-- docs/contributing/environment/variables.md | 1 + scripts/meta/env/load.sh | 30 +++- tests/unit/python/cli/meta/env/test_main.py | 20 ++- .../unit/python/scripts/meta/env/__init__.py | 0 .../unit/python/scripts/meta/env/test_load.py | 131 ++++++++++++++++++ .../scripts/tests/deploy/test_distros.py | 11 ++ 7 files changed, 211 insertions(+), 17 deletions(-) create mode 100644 tests/unit/python/scripts/meta/env/__init__.py create mode 100644 tests/unit/python/scripts/meta/env/test_load.py diff --git a/cli/meta/env/__main__.py b/cli/meta/env/__main__.py index d4f7e3764f..d1abfe9c6f 100644 --- a/cli/meta/env/__main__.py +++ b/cli/meta/env/__main__.py @@ -2,8 +2,10 @@ from __future__ import annotations +import argparse import os import sys +from pathlib import Path from utils.env.builder import build_env from utils.env.parser import parse_static_env_with_comments @@ -14,18 +16,34 @@ from . import PROJECT_ROOT as REPO_ROOT HOST_OWNED_KEY = "INFINITO_DOTENV_HOST_OWNED" # nocheck: dotenv-host-owned-marker Reason: set only by compose.yml inside the runner container; not a configuration key, a .env entry could freeze the host .env -def main() -> int: +def main(argv: list[str] | None = None) -> int: + """Generate the env set from default.env and the runtime context. + + Args: + argv: command-line arguments; ``--output PATH`` writes the set to PATH + instead of the repository's ``.env``, which then stays untouched. + + Returns: + 0 on success, 2 when default.env is missing. + """ + parser = argparse.ArgumentParser(prog="python -m cli.meta.env") + parser.add_argument("--output", type=Path) + args = parser.parse_args([] if argv is None else argv) static_path = REPO_ROOT / "default.env" - out_path = REPO_ROOT / ".env" + out_path = args.output or REPO_ROOT / ".env" + out_name = args.output or ".env" if not static_path.is_file(): print(f"ERROR: missing {static_path}", file=sys.stderr) return 2 - if out_path.is_file() and os.environ.get(HOST_OWNED_KEY) == "true": + if ( + args.output is None + and out_path.is_file() + and os.environ.get(HOST_OWNED_KEY) == "true" + ): print( - f"Kept {out_path.relative_to(REPO_ROOT)}: the host checkout owns it " - f"({HOST_OWNED_KEY})", + f"Kept {out_name}: the host checkout owns it ({HOST_OWNED_KEY})", file=sys.stderr, ) return 0 @@ -33,12 +51,9 @@ def main() -> int: static, static_comments = parse_static_env_with_comments(static_path) eb = build_env(static, repo_root=REPO_ROOT, comments=static_comments) write_dotenv(eb, out_path) - print( - f"Wrote {out_path.relative_to(REPO_ROOT)} ({len(eb.values)} variables)", - file=sys.stderr, - ) + print(f"Wrote {out_name} ({len(eb.values)} variables)", file=sys.stderr) return 0 if __name__ == "__main__": - sys.exit(main()) + sys.exit(main(sys.argv[1:])) diff --git a/docs/contributing/environment/variables.md b/docs/contributing/environment/variables.md index a14e12cd88..6b47e34511 100644 --- a/docs/contributing/environment/variables.md +++ b/docs/contributing/environment/variables.md @@ -27,6 +27,7 @@ Already-set env vars take precedence over `default.env` defaults. - [`env/`](../../../utils/env/) (under `utils/`) holds the parser, runtime helpers, writer, and one handler module per dynamically-computed variable under [`handlers/`](../../../utils/env/handlers/). - [`env/`](../../../cli/meta/env/) (under `cli/meta/`) provides the CLI entry point invoked as `python -m cli.meta.env`. - [`load.sh`](../../../scripts/meta/env/load.sh) is the shell loader; it sources `.env` and auto-generates it on a cold clone. + When the exported `INFINITO_DISTRO` differs from the one `.env` was generated for, it loads a set generated for that distro through `python -m cli.meta.env --output ` and leaves `.env` as it is. ## Variables NOT in `default.env` diff --git a/scripts/meta/env/load.sh b/scripts/meta/env/load.sh index b1dff51f4c..1de27c5e2b 100755 --- a/scripts/meta/env/load.sh +++ b/scripts/meta/env/load.sh @@ -7,6 +7,9 @@ # re-entry from generator subshells (BASH_ENV would otherwise recurse). # PYTHON/PATH are re-resolved on every source so a venv created mid-chain wins; # caller-set values are snapshotted and restored after the bulk .env source. +# INFINITO_CONTAINER, INFINITO_PARENT_IMAGE and INFINITO_IMAGE derive from the +# distro: a caller INFINITO_DISTRO other than the one `.env` was generated for +# loads a set generated for that distro instead, and `.env` stays untouched. # zsh cannot run this loader's bash-isms (BASH_SOURCE, ${!indirect}, assoc-array # key expansion). When sourced from zsh, delegate to bash and import the @@ -44,7 +47,7 @@ if [[ -n "${VENV:-}" && -d "${VENV%/}/bin" ]]; then fi _infinito_env_mtime="$(stat -c %Y "${_infinito_env_dotenv}" 2>/dev/null || echo 0)" -if [[ "${INFINITO_ENV_LOADED:-}" == "1" && "${INFINITO_ENV_LOADED_MTIME:-}" == "${_infinito_env_mtime}" ]]; then # nocheck: env-loader-internal-guard +if [[ "${INFINITO_ENV_LOADED:-}" == "1" && "${INFINITO_ENV_LOADED_MTIME:-}" == "${_infinito_env_mtime}" && "${INFINITO_ENV_LOADED_DISTRO:-}" == "${INFINITO_DISTRO:-}" ]]; then # nocheck: env-loader-internal-guard unset _infinito_env_repo_root _infinito_env_dotenv _infinito_env_mtime return 0 fi @@ -53,11 +56,22 @@ if [[ "${INFINITO_ENV_GENERATING:-}" == "1" ]]; then # nocheck: env-loader-inter return 0 fi -if [[ ! -f "${_infinito_env_dotenv}" ]]; then +if [[ -n "${INFINITO_ENV_LOADED_DISTRO:-}" && "${INFINITO_ENV_LOADED_DISTRO}" != "${INFINITO_DISTRO:-}" ]]; then # nocheck: env-loader-internal-guard + unset INFINITO_CONTAINER INFINITO_PARENT_IMAGE INFINITO_IMAGE +fi + +_infinito_env_source="${_infinito_env_dotenv}" +_infinito_env_scratch="" +if [[ -f "${_infinito_env_dotenv}" && -n "${INFINITO_DISTRO:-}" && "${INFINITO_DISTRO}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then + _infinito_env_scratch="$(mktemp -d)" + _infinito_env_source="${_infinito_env_scratch}/env" +fi + +if [[ ! -f "${_infinito_env_source}" ]]; then ( cd "${_infinito_env_repo_root}" || exit 1 export INFINITO_ENV_GENERATING=1 - "${PYTHON}" -m cli.meta.env + "${PYTHON}" -m cli.meta.env --output "${_infinito_env_source}" ) >&2 fi @@ -73,14 +87,19 @@ while IFS= read -r _infinito_env_line; do if [[ -n "${!_infinito_env_key:-}" ]]; then _infinito_env_preserved["${_infinito_env_key}"]="${!_infinito_env_key}" fi -done <"${_infinito_env_dotenv}" +done <"${_infinito_env_source}" unset _infinito_env_line _infinito_env_key set -a # shellcheck disable=SC1090 -source "${_infinito_env_dotenv}" +source "${_infinito_env_source}" set +a +if [[ -n "${_infinito_env_scratch}" ]]; then + rm -rf "${_infinito_env_scratch}" +fi +unset _infinito_env_source _infinito_env_scratch + for _infinito_env_key in "${!_infinito_env_preserved[@]}"; do declare -gx "${_infinito_env_key}=${_infinito_env_preserved[${_infinito_env_key}]}" done @@ -100,4 +119,5 @@ fi export INFINITO_ENV_LOADED="1" _infinito_env_mtime="$(stat -c %Y "${_infinito_env_dotenv}" 2>/dev/null || echo 0)" export INFINITO_ENV_LOADED_MTIME="${_infinito_env_mtime}" +export INFINITO_ENV_LOADED_DISTRO="${INFINITO_DISTRO:-}" unset _infinito_env_repo_root _infinito_env_dotenv _infinito_env_mtime diff --git a/tests/unit/python/cli/meta/env/test_main.py b/tests/unit/python/cli/meta/env/test_main.py index d2cc44c42f..261857a54e 100644 --- a/tests/unit/python/cli/meta/env/test_main.py +++ b/tests/unit/python/cli/meta/env/test_main.py @@ -9,7 +9,13 @@ import cli.meta.env.__main__ as env_main class TestDotenvHostOwned(unittest.TestCase): - def _run(self, *, dotenv_exists: bool, host_owned: str | None) -> tuple[int, bool]: + def _run( + self, + *, + dotenv_exists: bool, + host_owned: str | None, + argv: list[str] | None = None, + ) -> tuple[int, bool]: with tempfile.TemporaryDirectory() as tmp: root = Path(tmp) (root / "default.env").write_text("INFINITO_DISTRO=debian\n") @@ -28,7 +34,7 @@ class TestDotenvHostOwned(unittest.TestCase): patch.object(env_main, "write_dotenv") as write_dotenv, ): build_env.return_value.values = {} - rc = env_main.main() + rc = env_main.main(argv) return rc, write_dotenv.called def test_a_host_owned_dotenv_is_kept(self) -> None: @@ -40,6 +46,16 @@ class TestDotenvHostOwned(unittest.TestCase): def test_without_the_marker_the_dotenv_is_regenerated(self) -> None: self.assertEqual(self._run(dotenv_exists=True, host_owned=None), (0, True)) + def test_an_explicit_output_is_written_even_when_host_owned(self) -> None: + self.assertEqual( + self._run( + dotenv_exists=True, + host_owned="true", + argv=["--output", "/nonexistent/distro.env"], + ), + (0, True), + ) + if __name__ == "__main__": # pragma: no cover unittest.main() diff --git a/tests/unit/python/scripts/meta/env/__init__.py b/tests/unit/python/scripts/meta/env/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/meta/env/test_load.py b/tests/unit/python/scripts/meta/env/test_load.py new file mode 100644 index 0000000000..af61434b78 --- /dev/null +++ b/tests/unit/python/scripts/meta/env/test_load.py @@ -0,0 +1,131 @@ +"""The distro-derived keys follow the distro the caller asks for. + +``scripts/tests/deploy/distros.sh`` exports ``INFINITO_DISTRO`` per iteration +and sources the loader again. The keys composed from the distro must then name +that distro, not the one ``.env`` was generated for, and ``.env`` itself must +stay as it was. +""" + +from __future__ import annotations + +import os +import shutil +import subprocess +import sys +import tempfile +import unittest +from pathlib import Path +from typing import ClassVar + +from utils.cache.files import PROJECT_ROOT + +LOADER_DIR = Path(PROJECT_ROOT) / "scripts" / "meta" / "env" +SHOWN = ( + "INFINITO_DISTRO", + "INFINITO_CONTAINER", + "INFINITO_PARENT_IMAGE", + "INFINITO_IMAGE", +) +SHOW = "printf '%s\\n' " + " ".join(f'"{key}=${{{key}:-}}"' for key in SHOWN) + + +def clean_env(**overrides: str) -> dict[str, str]: + env = { + k: v + for k, v in os.environ.items() + if not k.startswith("INFINITO_") + and k not in ("BASH_ENV", "PYTHONPATH", "VENV", "PYTHON", "VIRTUAL_ENV") + } + env["PYTHONPATH"] = str(PROJECT_ROOT) + env.update(overrides) + return env + + +def bash(script: str, cwd: Path) -> dict[str, str]: + proc = subprocess.run( + ["bash", "-c", f"{script}\n{SHOW}"], + env=clean_env(), + cwd=cwd, + capture_output=True, + text=True, + check=True, + ) + return dict(line.split("=", 1) for line in proc.stdout.splitlines()) + + +class TestDistroDerivedKeys(unittest.TestCase): + scratch: ClassVar[Path] + expected: ClassVar[dict[str, dict[str, str]]] + + @classmethod + def setUpClass(cls) -> None: + cls.scratch = Path(tempfile.mkdtemp()) + cls.expected = {} + for distro in ("debian", "centos"): + path = cls.scratch / f"{distro}.env" + subprocess.run( + [sys.executable, "-m", "cli.meta.env", "--output", str(path)], + env=clean_env(INFINITO_DISTRO=distro), + cwd=PROJECT_ROOT, + capture_output=True, + check=True, + ) + cls.expected[distro] = bash(f'set -a; source "{path}"', cls.scratch) + + @classmethod + def tearDownClass(cls) -> None: + shutil.rmtree(cls.scratch) + + def run_loader(self, steps: str) -> dict[str, str]: + """Source a copy of the loader in a checkout whose ``.env`` is debian's. + + Args: + steps: bash run before the keys are shown; ``load`` sources the + loader. + + Returns: + The keys as the steps leave them. + """ + checkout = Path(tempfile.mkdtemp()) + self.addCleanup(shutil.rmtree, checkout) + (checkout / "scripts" / "meta" / "env").mkdir(parents=True) + for name in ("load.sh", "python.sh"): + shutil.copy(LOADER_DIR / name, checkout / "scripts" / "meta" / "env") + dotenv = checkout / ".env" + shutil.copy(self.scratch / "debian.env", dotenv) + before = dotenv.read_bytes() + shown = bash(f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout) + self.assertEqual(dotenv.read_bytes(), before, ".env was rewritten") + return shown + + def test_the_two_distros_derive_different_keys(self): + self.assertNotEqual( + self.expected["debian"]["INFINITO_PARENT_IMAGE"], + self.expected["centos"]["INFINITO_PARENT_IMAGE"], + ) + + def test_a_distro_exported_after_the_first_load_gets_its_own_keys(self): + shown = self.run_loader("load\nexport INFINITO_DISTRO=centos\nload") + self.assertEqual(shown, self.expected["centos"]) + + def test_a_distro_exported_before_the_first_load_gets_its_own_keys(self): + shown = self.run_loader("export INFINITO_DISTRO=centos\nload") + self.assertEqual(shown, self.expected["centos"]) + + def test_switching_back_restores_the_keys_of_the_dotenv(self): + shown = self.run_loader( + "load\nexport INFINITO_DISTRO=centos\nload\n" + "export INFINITO_DISTRO=debian\nload" + ) + self.assertEqual(shown, self.expected["debian"]) + + def test_a_caller_value_for_the_loaded_distro_still_wins(self): + shown = self.run_loader( + "load\nexport INFINITO_PARENT_IMAGE=caller/image:pinned\n" + "touch -d '+1 minute' .env\nload" + ) + self.assertEqual(shown["INFINITO_PARENT_IMAGE"], "caller/image:pinned") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/unit/python/scripts/tests/deploy/test_distros.py b/tests/unit/python/scripts/tests/deploy/test_distros.py index 4b6cb76aee..fd9cc2b499 100644 --- a/tests/unit/python/scripts/tests/deploy/test_distros.py +++ b/tests/unit/python/scripts/tests/deploy/test_distros.py @@ -76,6 +76,17 @@ class TestDistrosLoop(unittest.TestCase): self.assertEqual(proc.returncode, 0, proc.stderr) self.assertEqual(sorted(record.split()), sorted(DISTROS.split())) + def test_every_distro_runs_with_a_parent_image_of_its_own(self) -> None: + proc, record = self._run( + DISTROS, + 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}" >> "${RECORD}"', + INFINITO_CI_DISTRO_BUDGET_SECONDS="600", + ) + self.assertEqual(proc.returncode, 0, proc.stderr) + images = dict(line.split() for line in record.splitlines()) + self.assertEqual(sorted(images), sorted(DISTROS.split())) + self.assertEqual(len(set(images.values())), len(images), images) + def test_the_command_inherits_the_env_layer(self) -> None: proc, record = self._run( "debian", From 1d970fe5bd611f538f721fc83b0337e2505e23fe Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:24 +0200 Subject: [PATCH 2/8] fix(env): keep shellcheck and the cache-read lint green on the distro switch The loader copies INFINITO_DISTRO into a loader-local variable before it compares the value with the one in .env. With INFINITO_DISTRO read directly in that condition, `shellcheck -x scripts/meta/resolve/apps.sh` reported SC2153 for INFINITO_DISTROS, which apps.sh takes from the sourced .env; with the copy it reports nothing, as on main. The loader test checks that .env is unchanged with filecmp against the file it was copied from, instead of reading it twice with Path.read_bytes, which test_no_uncached_file_reads rejects. Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/meta/env/load.sh | 5 +++-- tests/unit/python/scripts/meta/env/test_load.py | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/meta/env/load.sh b/scripts/meta/env/load.sh index 1de27c5e2b..dfb67daf3a 100755 --- a/scripts/meta/env/load.sh +++ b/scripts/meta/env/load.sh @@ -62,7 +62,8 @@ fi _infinito_env_source="${_infinito_env_dotenv}" _infinito_env_scratch="" -if [[ -f "${_infinito_env_dotenv}" && -n "${INFINITO_DISTRO:-}" && "${INFINITO_DISTRO}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then +_infinito_env_distro="${INFINITO_DISTRO:-}" +if [[ -f "${_infinito_env_dotenv}" && -n "${_infinito_env_distro}" && "${_infinito_env_distro}" != "$(sed -n 's/^INFINITO_DISTRO=//p' "${_infinito_env_dotenv}")" ]]; then _infinito_env_scratch="$(mktemp -d)" _infinito_env_source="${_infinito_env_scratch}/env" fi @@ -98,7 +99,7 @@ set +a if [[ -n "${_infinito_env_scratch}" ]]; then rm -rf "${_infinito_env_scratch}" fi -unset _infinito_env_source _infinito_env_scratch +unset _infinito_env_source _infinito_env_scratch _infinito_env_distro for _infinito_env_key in "${!_infinito_env_preserved[@]}"; do declare -gx "${_infinito_env_key}=${_infinito_env_preserved[${_infinito_env_key}]}" diff --git a/tests/unit/python/scripts/meta/env/test_load.py b/tests/unit/python/scripts/meta/env/test_load.py index af61434b78..1fa719719d 100644 --- a/tests/unit/python/scripts/meta/env/test_load.py +++ b/tests/unit/python/scripts/meta/env/test_load.py @@ -8,6 +8,7 @@ stay as it was. from __future__ import annotations +import filecmp import os import shutil import subprocess @@ -93,9 +94,13 @@ class TestDistroDerivedKeys(unittest.TestCase): shutil.copy(LOADER_DIR / name, checkout / "scripts" / "meta" / "env") dotenv = checkout / ".env" shutil.copy(self.scratch / "debian.env", dotenv) - before = dotenv.read_bytes() - shown = bash(f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout) - self.assertEqual(dotenv.read_bytes(), before, ".env was rewritten") + shown = bash( + f"load() {{ source scripts/meta/env/load.sh; }}\n{steps}", checkout + ) + self.assertTrue( + filecmp.cmp(dotenv, self.scratch / "debian.env", shallow=False), + ".env was rewritten", + ) return shown def test_the_two_distros_derive_different_keys(self): From ee8d2bd983ddef7a399e2eb79695c4f8ce189b70 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 01:32:24 +0200 Subject: [PATCH 3/8] test(env): check each distro's parent image against its own reference The loop test only required three different parent images for three distros, which a swap between two of them would still pass. Each iteration now also records the owner and tag it sees, and its image must equal pkgmgr_image(distro, owner, tag). With the loader of main the test fails on arch with pkgmgr-debian:stable. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../unit/python/scripts/tests/deploy/test_distros.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/unit/python/scripts/tests/deploy/test_distros.py b/tests/unit/python/scripts/tests/deploy/test_distros.py index fd9cc2b499..80c4d7903f 100644 --- a/tests/unit/python/scripts/tests/deploy/test_distros.py +++ b/tests/unit/python/scripts/tests/deploy/test_distros.py @@ -20,6 +20,7 @@ import unittest from pathlib import Path from utils.cache.files import PROJECT_ROOT, read_text +from utils.distros import pkgmgr_image from utils.env.parser import parse_static_env LOOP = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "distros.sh" @@ -79,13 +80,15 @@ class TestDistrosLoop(unittest.TestCase): def test_every_distro_runs_with_a_parent_image_of_its_own(self) -> None: proc, record = self._run( DISTROS, - 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}" >> "${RECORD}"', + 'echo "${INFINITO_DISTRO} ${INFINITO_PARENT_IMAGE}' + ' ${INFINITO_PARENT_IMAGE_OWNER} ${INFINITO_PARENT_IMAGE_TAG}" >> "${RECORD}"', INFINITO_CI_DISTRO_BUDGET_SECONDS="600", ) self.assertEqual(proc.returncode, 0, proc.stderr) - images = dict(line.split() for line in record.splitlines()) - self.assertEqual(sorted(images), sorted(DISTROS.split())) - self.assertEqual(len(set(images.values())), len(images), images) + rows = [line.split() for line in record.splitlines()] + self.assertEqual(sorted(row[0] for row in rows), sorted(DISTROS.split())) + for distro, image, owner, tag in rows: + self.assertEqual(image, pkgmgr_image(distro, owner=owner, tag=tag)) def test_the_command_inherits_the_env_layer(self) -> None: proc, record = self._run( From 4e5c01676c9e493412cc0ae6ea6e6bdfde0bf86b Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 13:35:15 +0200 Subject: [PATCH 4/8] fix(web-app-bridgy-fed): build on python 3.14 until cbor2 ships cp315 The updater moved the build image from python 3.14-slim to 3.15-slim (39d57d953b). Upstream's requirements.pinned.txt pins cbor2 6.1.4, which ships wheels up to cp314 only, so pip builds it from source, and its Rust extension needs a compiler the image does not have. The build failed with "can't find Rust compiler", was retried until the job's budget ran out, and killed Bridgy Fed#0 on #915 after 20460 s. Installing Debian's cargo does not help: cbor2 6.1.4 uses let chains, stable only from Rust 1.88, and trixie ships an older rustc. The image stays on 3.14-slim, with the docker-version marker so the updater leaves it there. Bridgy Fed#0 passed on 3.14-slim in run 38318560960, and the build stage builds on it with the cp314 wheel. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-bridgy-fed/meta/services.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/roles/web-app-bridgy-fed/meta/services.yml b/roles/web-app-bridgy-fed/meta/services.yml index fd40548d63..0575fca712 100644 --- a/roles/web-app-bridgy-fed/meta/services.yml +++ b/roles/web-app-bridgy-fed/meta/services.yml @@ -48,7 +48,8 @@ bridgy-fed: swarm: enabled: true image: python - version: 3.15-slim + # nocheck: docker-version upstream's requirements.pinned.txt pins cbor2 6.1.4, which ships wheels up to cp314 and needs Rust >= 1.88 to build from source + version: 3.14-slim name: web-app-bridgy-fed repository: https://github.com/snarfed/bridgy-fed.git # nocheck: repository-version -- upstream publishes no tags, so the pin is a commit From 46373c1ba32bdfd39d36c096373ff620dabf980e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 14 Oct 2026 13:50:07 +0200 Subject: [PATCH 5/8] fix(act): remove only the own worktree's act containers down_act_outer.sh removed every container named act-*, so starting or releasing a swarm drill in one worktree killed the act container of a drill another worktree had running. workflow.sh now labels act's job containers with infinito.worktree=${INFINITO_CONTAINER} through the default ACT_CONTAINER_OPTIONS, and down_act_outer.sh removes only containers carrying the own label. Both scripts refuse to run without INFINITO_CONTAINER, so the filter never widens to every act container; make exports BASH_ENV, which loads it from .env. Worktrees without a custom.env share the default container name and therefore still share one label among themselves. Closes #933 Co-Authored-By: Claude Opus 5.5 (1M context) --- scripts/tests/deploy/act/down_act_outer.sh | 7 +- scripts/tests/deploy/act/workflow.sh | 3 +- .../scripts/tests/deploy/act/__init__.py | 0 .../tests/deploy/act/test_down_act_outer.py | 74 +++++++++++++++++++ 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 tests/unit/python/scripts/tests/deploy/act/__init__.py create mode 100644 tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py diff --git a/scripts/tests/deploy/act/down_act_outer.sh b/scripts/tests/deploy/act/down_act_outer.sh index af792d57f2..f8d0340ae2 100755 --- a/scripts/tests/deploy/act/down_act_outer.sh +++ b/scripts/tests/deploy/act/down_act_outer.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash set +e -# Match act's outer-runner name prefix, not the image: ACT_PLATFORM_IMAGE varies the ancestor. -ids="$(docker ps -aq --filter "name=^act-")" +: "${INFINITO_CONTAINER:?INFINITO_CONTAINER is not set; source scripts/meta/env/load.sh or invoke via make}" + +ids="$(docker ps -aq --filter "name=^act-" --filter "label=infinito.worktree=${INFINITO_CONTAINER}")" if [ -n "${ids}" ]; then - echo "→ removing act outer container(s): ${ids}" + echo "→ removing act outer container(s) of ${INFINITO_CONTAINER}: ${ids}" # shellcheck disable=SC2086 docker rm -f ${ids} >/dev/null 2>&1 else diff --git a/scripts/tests/deploy/act/workflow.sh b/scripts/tests/deploy/act/workflow.sh index 2d5e126a9a..7be72c21a6 100755 --- a/scripts/tests/deploy/act/workflow.sh +++ b/scripts/tests/deploy/act/workflow.sh @@ -5,7 +5,8 @@ set -euo pipefail : "${ACT_EVENT:=workflow_dispatch}" : "${ACT_JOB:=}" : "${ACT_MATRIX:=}" -: "${ACT_CONTAINER_OPTIONS:=--privileged}" +: "${INFINITO_CONTAINER:?INFINITO_CONTAINER is not set; source scripts/meta/env/load.sh or invoke via make}" +: "${ACT_CONTAINER_OPTIONS:=--privileged --label infinito.worktree=${INFINITO_CONTAINER}}" : "${ACT_NETWORK:=host}" : "${ACT_PULL:=false}" : "${ACT_RM:=true}" diff --git a/tests/unit/python/scripts/tests/deploy/act/__init__.py b/tests/unit/python/scripts/tests/deploy/act/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py new file mode 100644 index 0000000000..425e7566c2 --- /dev/null +++ b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py @@ -0,0 +1,74 @@ +from __future__ import annotations + +import os +import subprocess +import tempfile +import unittest +from pathlib import Path + +from utils.cache.files import PROJECT_ROOT + +SCRIPT = PROJECT_ROOT / "scripts" / "tests" / "deploy" / "act" / "down_act_outer.sh" +DOCKER_STUB = ( + "#!/usr/bin/env bash\n" + 'printf "%s\\n" "$*" >>"${STUB_LOG}"\n' + 'if [ "$1" = ps ]; then\n' + ' case "$*" in *"label=infinito.worktree=own"*) echo own-id ;; esac\n' + "fi\n" +) + + +def teardown(container: str | None) -> tuple[subprocess.CompletedProcess, list[str]]: + """Run the teardown against a ``docker`` stub that only knows ``own-id``. + + Args: + container: value of ``INFINITO_CONTAINER``, or None to leave it unset. + + Returns: + The finished process and the docker invocations it made. + """ + with tempfile.TemporaryDirectory() as tmp: + stub = Path(tmp) / "docker" + stub.write_text(DOCKER_STUB) + stub.chmod(0o755) + log = Path(tmp) / "docker.log" + log.touch() + env = { + k: v + for k, v in os.environ.items() + if k not in ("BASH_ENV", "INFINITO_CONTAINER") + } + env.update(PATH=f"{tmp}{os.pathsep}{os.environ['PATH']}", STUB_LOG=str(log)) + if container is not None: + env["INFINITO_CONTAINER"] = container + done = subprocess.run( + ["bash", str(SCRIPT)], + env=env, + capture_output=True, + text=True, + check=False, + ) + return done, log.read_text().splitlines() + + +class TestDownActOuter(unittest.TestCase): + def test_only_the_own_worktrees_act_containers_are_listed(self) -> None: + _, calls = teardown("own") + self.assertIn("label=infinito.worktree=own", calls[0]) + + def test_the_own_act_container_is_removed(self) -> None: + _, calls = teardown("own") + self.assertEqual(calls[1], "rm -f own-id") + + def test_a_foreign_worktrees_act_container_is_left_alone(self) -> None: + _, calls = teardown("foreign") + self.assertEqual(len(calls), 1) + + def test_an_unset_container_name_removes_nothing(self) -> None: + done, calls = teardown(None) + self.assertNotEqual(done.returncode, 0) + self.assertEqual(calls, []) + + +if __name__ == "__main__": + unittest.main() From 87c9a5f41b34c9259eadf59af0a4c9dd2c1b976f Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 15 Oct 2026 01:07:50 +0200 Subject: [PATCH 6/8] test(act): mark the docker stub log read as outside the file cache The teardown test reads the call log its docker stub writes into a temporary directory. test_no_uncached_file_reads flagged that read in CI; the path-keyed read cache does not fit a file written per run, so the read keeps Path.read_text with the cache-read opt-out, as the other stub-log tests do. Co-Authored-By: Claude Opus 5.5 (1M context) --- .../unit/python/scripts/tests/deploy/act/test_down_act_outer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py index 425e7566c2..8082bf8f20 100644 --- a/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py +++ b/tests/unit/python/scripts/tests/deploy/act/test_down_act_outer.py @@ -48,7 +48,7 @@ def teardown(container: str | None) -> tuple[subprocess.CompletedProcess, list[s text=True, check=False, ) - return done, log.read_text().splitlines() + return done, log.read_text().splitlines() # nocheck: cache-read stub call log class TestDownActOuter(unittest.TestCase): From e7e9bfe989d01a94dd1238b023ee465ea76fdcbb Mon Sep 17 00:00:00 2001 From: "infinito-nexus-updater[bot]" <286144613+infinito-nexus-updater[bot]@users.noreply.github.com> Date: Thu, 15 Oct 2026 08:54:21 +0000 Subject: [PATCH 7/8] update(versions): update pins with a declared source (web-app-n8n) --- roles/web-app-n8n/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-n8n/meta/services.yml b/roles/web-app-n8n/meta/services.yml index 46bb83d1b1..e1899e35c4 100644 --- a/roles/web-app-n8n/meta/services.yml +++ b/roles/web-app-n8n/meta/services.yml @@ -67,7 +67,7 @@ n8n: backup: no_stop_required: false image: docker.n8n.io/n8nio/n8n - version: "2.44.1" + version: "2.44.2" update: type: registry_tags image: docker.n8n.io/n8nio/n8n From 4aa6f54f4e1774060d12b57bdb03e71faa76245c Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 15 Oct 2026 11:01:47 +0200 Subject: [PATCH 8/8] docs(web-app-bridgy-fed): name the exit condition of the python 3.14 pin cbor2 6.1.5 ships cp315 wheels; the pin can return to 3.15-slim once the pinned upstream ref carries it. Co-Authored-By: Claude Opus 5.5 (1M context) --- roles/web-app-bridgy-fed/meta/services.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/web-app-bridgy-fed/meta/services.yml b/roles/web-app-bridgy-fed/meta/services.yml index 0575fca712..c47b937e41 100644 --- a/roles/web-app-bridgy-fed/meta/services.yml +++ b/roles/web-app-bridgy-fed/meta/services.yml @@ -48,7 +48,7 @@ bridgy-fed: swarm: enabled: true image: python - # nocheck: docker-version upstream's requirements.pinned.txt pins cbor2 6.1.4, which ships wheels up to cp314 and needs Rust >= 1.88 to build from source + # nocheck: docker-version upstream's requirements.pinned.txt pins cbor2 6.1.4, which ships wheels up to cp314 and needs Rust >= 1.88 to build from source. TODO: return to 3.15-slim once the pinned upstream ref carries cbor2 >= 6.1.5 (cp315 wheels) version: 3.14-slim name: web-app-bridgy-fed repository: https://github.com/snarfed/bridgy-fed.git