Skip to content

Key the linters' venv cache on the exact Python version - #941

Merged
bzaczynski merged 1 commit into
masterfrom
ci-cache-key-python-version
Nov 10, 2026
Merged

bzaczynski merged 1 commit into
masterfrom
ci-cache-key-python-version

Conversation

@lpozo

@lpozo lpozo commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Every PR since about Nov 6 fails Linux314 with:

/opt/hostedtoolcache/Python/3.14.10/x64/bin/python: No module named ruff

Cause

The ./venv cache key only hashes requirements.txt. Since #917, python: '3.14' resolves to the latest patch release. The last green run (Nov 4, master) built and cached the venv on 3.14.9. The runners now have 3.14.10, so PRs get a cache hit on the same key (Linux314-v2-pip-c27cd8f7…), the install step is skipped, and the restored venv/bin/python links to a 3.14.9 interpreter that no longer exists. The shell falls through to the toolcache's 3.14.10 python, which has no Ruff.

#917 bumped the key from v1 to v2 for exactly this reason, as did #438 earlier. But with '3.14' the patch version now changes on its own, so a manual bump only fixes it until the next release.

Fix

  • Add id: setup-python and put steps.setup-python.outputs.python-version (for example, 3.14.10) in the cache key and restore-keys. Each patch release then builds a fresh venv, with no manual bumps.
  • Update actions/checkout v2 → v4, actions/setup-python v2 → v5, and actions/cache v3 → v4, the same bumps Update GitHub Actions to Latest Versions #717 proposes. The old versions run on deprecated Node runtimes.

Once this merges, rerunning the failed checks on #935–#940 should turn them green.

🤖 Generated with Claude Code

The cached ./venv links to the interpreter it was built with. Since #917
resolves '3.14' to the latest patch, a new patch release (3.14.9 to
3.14.10) leaves the cached venv pointing at a missing interpreter, and
the cache hit skips the install, so 'python -m ruff' runs without Ruff.

Include setup-python's resolved python-version in the cache key, so each
patch release builds a fresh venv, and update checkout, setup-python, and
cache to their current major versions (as proposed in #717).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@lpozo
lpozo requested a review from bzaczynski November 10, 2026 14:39
@bzaczynski
bzaczynski merged commit 5093d33 into master Nov 10, 2026
1 check passed
@bzaczynski
bzaczynski deleted the ci-cache-key-python-version branch November 10, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants