8000
Skip to content

CI: cache Poetry tool venv and project venv across jobs - #1560

Open
mithr4ndir wants to merge 1 commit into
lightkurve:mainfrom
mithr4ndir:ci-cache-poetry-1553
Open

CI: cache Poetry tool venv and project venv across jobs#1560
mithr4ndir wants to merge 1 commit into
lightkurve:mainfrom
mithr4ndir:ci-cache-poetry-1553

Conversation

@mithr4ndir
Copy link
Copy Markdown

Adds actions/cache@v4 to all four CI jobs (pytest-linux, pytest-windows,
pytest-osx, flake8-linter) to cache both the Poetry tool venv (./poetry)
and the in-project dependency venv (./.venv) between runs.

What changed

  • POETRY_VIRTUALENVS_IN_PROJECT: "true" added as a job-level env var so
    Poetry always places .venv at the project root, making the cache path
    uniform across all runners.
  • The mkdir poetry + unconditional venv setup is replaced with a
    conditional that skips recreating the tool venv when a cached one is
    restored. poetry install --with dev still runs on every job to verify
    the lockfile is satisfied.
  • Cache key: poetry-<OS>-py<python-version>-<sha256(pyproject.toml)>
  • Restore key: poetry-<OS>-py<python-version>- (partial match seeds the
    venv, poetry install updates only what changed)

Why

On a cache miss the install step runs roughly 2 minutes on GitHub runners
(resolving and downloading ~280 MB of packages). On a cache hit it drops to
a fast lockfile verify pass. With 8 job instances per push this compounds
across the matrix.

Testing

Verified locally using act with its built-in cache server across Python
3.10, 3.11, 3.12, and 3.13:

  • Cache miss: full venv build, ~280 MB saved
  • Cache hit: cache-hit=true, install reports "No dependencies to install
    or update", cache not re-saved on primary key match
  • 271 tests passed on all four versions

Refs #1553.

Adds actions/cache@v4 to all four CI jobs in lightkurve-tests.yml,
keyed on runner OS, Python version, and the pyproject.toml hash.
Both the Poetry tool venv (./poetry) and the project venv (./.venv)
are cached so reruns reuse resolved dependencies.

POETRY_VIRTUALENVS_IN_PROJECT=true is set at the job level so Poetry
installs project dependencies into ./.venv at the project root,
making the cache path uniform across Linux, macOS, and Windows.

The Install dependencies step now skips recreating ./poetry when a
working tool venv was restored from cache.

Refs lightkurve#1553.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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

0