ci: make dependency cache keys job-unique and poetry-aware#1032
Conversation
Improve the actions/cache keys in CI: - include the poetry version (env.POETRY_VERSION) so a poetry upgrade doesn't reuse a venv built by a different poetry - make keys unique per job (github.job) so unit-tests and e2e-tests no longer share/contend on one key - fix a latent bug: the keys referenced steps.setup_python.outputs.python-version but no step had that id, so the python version expanded to empty. Add id: setup_python to the setup-python steps so the version actually enters the key - add job-scoped restore-keys for better hit rates when only the lock changes Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1032 +/- ##
=======================================
Coverage 98.02% 98.02%
=======================================
Files 32 32
Lines 1725 1725
Branches 177 177
=======================================
Hits 1691 1691
Misses 18 18
Partials 16 16 🚀 New features to boost your workflow:
|
Not sure I understand this point. Both |
There was a problem hiding this comment.
Pull request overview
Updates the CI workflow’s dependency caching strategy to avoid cross-job cache contamination and to make cache keys sensitive to Poetry and Python versions, improving correctness and reproducibility of CI runs.
Changes:
- Adds
id: setup_pythonto theactions/setup-pythonsteps sosteps.setup_python.outputs.python-versionis actually populated. - Makes dependency cache keys job-unique (
${{ github.job }}) and includes Poetry version (${{ env.POETRY_VERSION }}) to prevent reusing incompatible.venvcaches. - Adds job-scoped
restore-keysprefixes so caches can still be restored across lockfile changes, withmake dev-depsreconciling afterward.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # .github/workflows/ci.yaml
Related Tickets & Documents
Changes
Improve the
actions/cachekeys in.github/workflows/ci.yaml:env.POETRY_VERSION) in every cache key, so upgrading poetry no longer reuses a.venvbuilt by a different poetry.${{ github.job }}, sounit-testsande2e-testsno longer share the same.venvkey (previously only the first job to finish could save it, and they could cross-contaminate).${{ steps.setup_python.outputs.python-version }}, but no step definedid: setup_python— so it expanded to an empty string and the Python version was effectively absent from the key. Addedid: setup_pythonto thesetup-pythonsteps inunit-testsande2e-tests.restore-keysso a lockfile change still restores the latest matching cache (same job/os/python/poetry);make dev-depsreconciles afterward.Notes
unit-tests.venv+ pre-commit, ande2e-tests.venv. Thebuild/release_dev*jobs have no dependency cache (unchanged), andrelease.yamlhas no caches.poetry<version>.