Skip to content

ci: reuse the previous venv when the lockfile changes - #38

Merged
notdodo merged 2 commits into
mainfrom
ci/venv-cache-fallback
Nov 15, 2026
Merged

notdodo merged 2 commits into
mainfrom
ci/venv-cache-fallback

Conversation

@notdodo

@notdodo notdodo commented Nov 15, 2026

Copy link
Copy Markdown
Member

Problem

Python 3.15 CI takes about 14 minutes whenever uv.lock changes, which includes every Dependabot PR and #37:

  • The venv cache key and setup-uv's own cache key both include the lockfile hash, and neither has a fallback. A changed lockfile misses both.
  • There are no 3.15 wheels yet for numpy, pydantic-core, thinc and others, so a miss means compiling all of them from source.
  • setup-uv's Python cache misses too. A restored venv whose interpreter is missing gets deleted and rebuilt, which is the same failure ci: keep the venv cache valid across runners #36 fixed for exact hits.

Fix

  • restore-keys: python-<ver>-venv- on the venv cache. A lockfile change now restores the latest venv for that Python version, task install applies only the changed packages, and the result is saved under the new key.
  • uv python install <ver> runs before task install, so the restored venv always has its interpreter.

Validation

🤖 Generated with Claude Code

Every lockfile change missed both caches, so Python 3.15 rebuilt its
source-only dependencies from scratch (about 14 minutes). Fall back to
the latest venv for the same Python version and let task install apply
only the delta. Install the interpreter first, so a restored venv never
points at a missing Python and gets recreated.
@github-actions

Copy link
Copy Markdown

kics-logo

KICS version: v2.2.1

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 3
Files parsed placeholder 3
Files failed to scan placeholder 0
Total executed queries placeholder 4
Queries failed to execute placeholder 0
Execution time placeholder 0

Queries Results

|
|

@notdodo
notdodo merged commit ce1dc1a into main Nov 15, 2026
5 checks passed
@notdodo
notdodo deleted the ci/venv-cache-fallback branch November 15, 2026 11:08
notdodo added a commit that referenced this pull request Nov 15, 2026
## Release 0.5.0
- Version bumped to 0.5.0 in `pyproject.toml` and `uv.lock`.
- CHANGELOG: `[Unreleased]` becomes `[0.5.0] - 2026-11-15`, and the
README install command points at `v0.5.0`.
- It's a minor release because the Langfuse requirement changed from
`==5.2.0` to `>=5.2.0,<5.3`.

## Python 3.15 CI
After #38, 3.15 still spent about 85 s in `test_packaging.py`:
- That test installed the wheel with `uv run --with`, which resolves the
newest releases instead of `uv.lock`.
- setup-uv's cache is keyed on the lockfile with no fallback, so after
any lockfile change the test compiled pydantic-core, regex, zstandard
and others from source.

The fix:
- **Test:** installs the wheel into a fresh venv constrained to `uv
export --locked`. Its checks are unchanged: `py.typed` is in the wheel,
and a base install has no `redaction` extra.
- **CI:** setup-uv's cache is off. One `actions/cache` entry holds
`.venv`, `.mypy_cache` and the uv cache, with `restore-keys` fallback to
the latest entry for the same Python version. `uv cache prune --ci`
keeps only locally built wheels.

## After merge
Push a signed `v0.5.0` tag, and `.github/workflows/release.yml` checks,
builds, attests and publishes.

## Validation
- `task format check test`: 154 passed. The packaging test takes 1.5 s
on 3.15 locally.
- actionlint and zizmor are clean.
- The wheel METADATA shows `Version: 0.5.0` and `Requires-Dist:
langfuse<5.3,>=5.2.0`.
- This PR's own 3.15 run starts cold, because the new `-deps-` cache key
has no earlier entry. Later runs, including lockfile changes, should
restore it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

1 participant