Skip to content

ci: Port the zccache installer to Python (#962) - #2606

Merged
zackees merged 3 commits into
masterfrom
infra/962-gen-005-install-zccache-python
Oct 27, 2026
Merged

zackees merged 3 commits into
masterfrom
infra/962-gen-005-install-zccache-python

Conversation

@zackees

@zackees zackees commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Part of the #962 GEN-005 burn-down: port one shell script per PR to Python and delete its ci.toml exception.

Refs #962 (one unit of a burn-down; no user-visible change, so no docs/features.md line).

Unit

rust/tools/linux-validate/install-zccache.sh (38 lines) -> rust/tools/linux-validate/install_zccache.py.

The installer downloads the pinned zccache 1.15.5 static-musl release into a destination dir (default ~/.local/bin), mapping uname -m x86_64/amd64 and aarch64/arm64 to their pinned SHA-256, returns early when $dest/zccache already reports zccache 1.15.5, and fails on any other arch. The Python port keeps the same pinned version, the same two digests, the same messages and exit codes (unsupported arch -> stderr + exit 1; a bad digest -> stderr + exit 1), keeps curl --retry 3's retry, checks the digest before installing, installs at mode 0755 and prints --version last.

RED

test: Point the zccache installer test at the Python port (#962) — 5cdc40d85083cde79b99923fcacf5ca852aa9e48.

ci/test_zccache.py is repointed at the Python module and its wiring, and a new PortTest exercises the port offline (arch map, unsupported arch, digest, the already-installed early return). At that commit:

$ uv run python -m unittest ci/test_zccache.py
Ran 22 tests in 0.037s
FAILED (failures=9, errors=8)

The errors are FileNotFoundError/load_module (install_zccache.py does not exist yet); the failures are the Dockerfile COPY install_zccache.py assertion and the wiring checks, because the Tier 2 Dockerfile, the manylinux Dockerfile, .dockerignore, setup_zccache, build-project.yaml, sanitize.sh and ci.toml still name install-zccache.sh.

GREEN

ci: Port the zccache installer to Python (#962) — 849e15c4ec3f3834a15b77e71bbdee96d55c684c.

$ uv run python -m unittest ci/test_zccache.py
Ran 22 tests in 0.316s
OK

$ uv run python -m unittest ci.test_uv_run ci.test_dockerignore_copies ci.test_tool_guard
Ran 31 tests in 8.321s
OK

$ uv run ruff check rust/tools/linux-validate/install_zccache.py ci/test_zccache.py
All checks passed!

$ ./lint            # with this shell's empty CARGO_TARGET_DIR unset
== lane lint: ok (53.1s)

Callers now run the Python through uv (TOOL-003): rust/tools/linux-validate/Dockerfile (uv run --no-project --python /usr/bin/python3) and .github/scripts/utils.zsh/setup_zccache, both build-project.yaml steps and rust/tools/sanitize/sanitize.sh (uv run --no-project). The manylinux Dockerfile installs uv after that step, so it runs the script with the image's own /opt/python/cp312-cp312/bin/python3. .dockerignore lists the .py; the GEN-005 exception for the .sh is deleted from ci.toml; docs/ci-tooling.md names install_zccache.py. The .sh is deleted, not left as a shim.

Runner note: the first ./lint in my shell failed only on ci/test_local_gate_probe and ci/test_gate_dylint, both from a CARGO_TARGET_DIR='' this environment exports; with it unset ./lint is fully green.

Rebased onto origin/master (c2a9d135e, after #2596-#2598 landed) so the PR is conflict-free; the ci.toml conflict was resolved by keeping master's exception list minus the install-zccache.sh block. The RED/GREEN SHAs above are the rebased ones.

@zackees
zackees force-pushed the infra/962-gen-005-install-zccache-python branch from 9865f0d to 849e15c Compare October 27, 2026 10:59
@zackees
zackees marked this pull request as ready for review October 27, 2026 11:01
@zackees
zackees enabled auto-merge October 27, 2026 11:01
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
@zackees
zackees removed this pull request from the merge queue due to a manual request Oct 27, 2026
@zackees
zackees force-pushed the infra/962-gen-005-install-zccache-python branch from 849e15c to 070817d Compare October 27, 2026 11:25
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Rebased onto master as the coordinator. It was queued behind #2599/#2600/#2601/#2605, which each removed a GEN-005 exception and so kept moving the same ci.toml block; I dequeued it rather than let it sit UNMERGEABLE at position 3 and hold up the two PRs behind it.

Conflicts: ci.toml only — the stanzas for install-zccache.sh (yours) and for build-errors.sh / stale-build.sh (already removed by #2599/#2601) are all gone now. The resolution keeps every removal.

Adapted to #2605 (sanitize.sh → sanitize.py, merged while this PR was open):

  • rust/tools/sanitize/sanitize.py:prepare_toolchain() ran install-zccache.sh, which this PR deletes. It now runs install_zccache.py through uv run --no-project, the same way your shell did, so the sanitizer lane keeps a compiler launcher after the merge.
  • ci/test_zccache.py::test_the_sanitizers_run_the_python_through_uv read sanitize.sh; it now asserts the uv invocation in sanitize.py and that no install-zccache.sh reference is left. It is a separate commit so it is easy to review or drop.

Verified after the rebase (master 81f7d266e, worktree):

  • uv run python -m unittest ci.test_zccache ci.test_dockerignore_copies ci.test_ported_sources ci.test_ci_toml ci.test_uv_run ci.test_sanitize_harness → 62 tests OK.
  • ruff check rust/tools/sanitize/sanitize.py ci/test_zccache.py: clean.
  • git diff origin/master --stat: this PR's files plus the sanitize.py / test_zccache.py adaptation above, nothing else.

Re-queued. PR CI runs fresh against 81f7d266e.

@zackees
zackees enabled auto-merge October 27, 2026 11:26

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of the rebased head 070817dbd.

Verdict: correct, and it now survives the rebase's neighbours.

  • The port itself is a straight translation of install-zccache.sh: pinned version + SHA-256 check, --version verification, install into the given bin dir. ci/test_zccache.py pins the SHA mismatch, the missing-binary and the success paths, which is the RED→GREEN pair the policy asks for.
  • Every call site is updated in the same PR: .github/workflows/build-project.yaml (both sites), .github/scripts/utils.zsh/setup_zccache, build-aux/appimage/manylinux/Dockerfile, rust/tools/linux-validate/Dockerfile, .dockerignore and docs/ci-tooling.md. git grep install-zccache.sh returns only test assertions that its absence is the point.
  • The GEN-005 exception is removed, so this burns down a unit rather than adding a second exception.
  • No docs/features.md line: CI tooling, not user-visible.
  • The one thing the author could not have seen when writing this — #2605 ported sanitize.sh to sanitize.py and its prepare_toolchain() still ran install-zccache.sh — is fixed in the rebase (see my comment above): sanitize.py now runs install_zccache.py through uv run --no-project, and the wiring test asserts that instead of reading a file that no longer exists.

Verified on the rebased head: uv run python -m unittest ci.test_zccache ci.test_dockerignore_copies ci.test_ported_sources ci.test_ci_toml ci.test_uv_run ci.test_sanitize_harness → 62 tests OK; ruff check clean on both touched Python files; git diff origin/master --stat holds only this PR's files.

Queued. PR CI is the gate for the container/AppImage lanes I cannot run here.

@zackees
zackees added this pull request to the merge queue Oct 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 27, 2026
The zccache installer is being ported from install-zccache.sh to
install_zccache.py. This changes ci/test_zccache.py to read the Python
module, to assert the Python port's shapes (a pinned ZCCACHE_VERSION, two
SHA-256 digests, hashlib.sha256) and to pin the wiring: the shell script
is gone, ci.toml keeps no GEN-005 exception for it, and every caller
(Dockerfiles, .dockerignore, setup_zccache, build-project.yaml,
sanitize.sh) runs the Python through uv run. A new PortTest exercises the
port offline: the arch map (and the unsupported-arch failure), the
archive digest, and the already-installed early return.

RED: uv run python -m unittest ci/test_zccache.py -> 9 failures, 8 errors
(install_zccache.py does not exist yet; the Dockerfile and the other
callers still name install-zccache.sh).
install-zccache.sh (38 lines) installs the pinned zccache 1.15.5 static-musl
release into a destination dir, mapping uname -m x86_64/amd64 and
aarch64/arm64 to their pinned SHA-256, returning early when the installed
binary already reports the version, and failing on any other arch.

install_zccache.py is a faithful port: same version, same two digests,
same messages and exit codes. The download keeps curl's retry, the digest
is checked before install, the binary lands at mode 0755, and the final
step prints --version. The arch map, digest and installed-check are
exercised offline by ci/test_zccache.py.

Every caller now runs the Python through uv (TOOL-003):
- rust/tools/linux-validate/Dockerfile (uv run --no-project --python
  /usr/bin/python3, uv is already in the image)
- build-aux/appimage/manylinux/Dockerfile (uv arrives later in that
  Dockerfile, so the manylinux interpreter runs it)
- .github/scripts/utils.zsh/setup_zccache and both build-project.yaml
  steps (uv run --no-project)
- rust/tools/sanitize/sanitize.sh (uv run --no-project)
- .dockerignore lists the .py; the GEN-005 exception for the .sh is gone
  from ci.toml, and docs/ci-tooling.md names install_zccache.py.

No docs/features.md line: a pure tooling port with no user-visible change.

GREEN: uv run python -m unittest ci/test_zccache.py -> 22 tests, OK;
ci.test_uv_run, ci.test_dockerignore_copies and ci.test_tool_guard -> OK;
./lint -> ok (its ci/test_local_gate_probe and test_gate_dylint failures
were this shell's empty CARGO_TARGET_DIR, gone with it unset).
@zackees
zackees force-pushed the infra/962-gen-005-install-zccache-python branch from 070817d to bf8777f Compare October 27, 2026 11:44
@zackees
zackees enabled auto-merge October 27, 2026 11:44
@zackees
zackees added this pull request to the merge queue Oct 27, 2026
Merged via the queue into master with commit 1bbe385 Oct 27, 2026
36 checks passed
@zackees
zackees deleted the infra/962-gen-005-install-zccache-python branch October 27, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant