Skip to content

setup-environment: fix standard-mode conda caching + validation (#33)#78

Merged
mmcky merged 2 commits into
mainfrom
fix/setup-env-standard-cache
Jun 16, 2026
Merged

setup-environment: fix standard-mode conda caching + validation (#33)#78
mmcky merged 2 commits into
mainfrom
fix/setup-env-standard-cache

Conversation

@mmcky

@mmcky mmcky commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Closes #33 (C3, L19, L23) — makes the non-container (standard-mode) Conda cache actually save time, plus two smaller hardening/doc fixes.

C3 — the cache was a no-op

Before, standard mode restored the Conda cache and then ran setup-miniconda with environment-file: set, which recreates the env every run — so the cache never helped (the README's "~3-4 min cached" was aspirational).

Restructured to the documented setup-miniconda caching recipe:

  1. setup-miniconda runs without environment-file (installs conda + the named env shell, doesn't rebuild from the file);
  2. actions/cache restores the env at ${CONDA}/envs;
  3. a new step runs conda env update only on a cache miss (cache-hit != 'true', which also covers prefix-matched restores when the env file changed).

Also:

  • dropped the deprecated use-only-tar-bz2;
  • dropped miniconda-version: latest so the env lives at a stable ${CONDA}/envs path (the runner's pre-installed conda, kept current by auto-update-conda) — this is what makes the cache path reliable.

L19 — fail loudly on missing LaTeX requirements

install-latex: true with a missing requirements file now errors and exits instead of warning + skipping (which produced an env that failed ~an hour later in the build).

L23 — cache-version doc

Documented that cache-version only affects the standard-mode Conda cache (no effect in container mode, which has no Conda cache).

⚠️ Validation note

Standard mode is a fallback (the templates are container-first), and conda env caching is finicky and can't be verified locally. Worth confirming on a real CI run: the second run on an unchanged environment.yml should log a cache hit and skip the "Create/update environment" step. If the ${CONDA}/envs path turns out wrong on the hosted runner, the fix is a one-line path tweak.

Closes #33

🤖 Generated with Claude Code

- C3: in standard (non-container) mode the conda cache was restored and then
  setup-miniconda recreated the env unconditionally (environment-file set), so
  the cache never saved time. Restructured to the documented setup-miniconda
  caching recipe: setup-miniconda runs without environment-file, the env is
  restored from cache (${CONDA}/envs), and `conda env update` runs only on a
  cache miss. Dropped the deprecated use-only-tar-bz2; dropped miniconda-version
  so the env lives at a stable ${CONDA}/envs path (kept current via
  auto-update-conda).
- L19: install-latex with a missing requirements file now errors and exits
  instead of warning and silently producing a broken env.
- L23: cache-version input documents it is standard-mode only (no effect in
  container mode).

Standard mode is a fallback (templates are container-first); the cache hit
should be confirmed on a real CI run (second run should log a hit and skip
env creation).

Closes #33

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 16, 2026 07:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the setup-environment composite action to make standard (non-container) Conda caching effective, hardens LaTeX requirements handling, and documents the cache-version input’s scope.

Changes:

  • Reworks standard-mode Conda setup to restore ${CONDA}/envs from cache and only update/create the env when the primary cache key doesn’t hit.
  • Fails fast when install-latex: true but the LaTeX requirements file is missing.
  • Documents that cache-version only affects the standard-mode Conda cache (no effect in container mode) and records the behavior in the changelog.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
setup-environment/action.yml Reorders standard-mode Conda setup and caching; adds cache-miss update step; makes missing LaTeX requirements an error; clarifies cache-version input description.
CHANGELOG.md Adds an Unreleased entry describing the setup-environment caching/validation/doc changes.

Comment thread setup-environment/action.yml
Comment thread setup-environment/action.yml Outdated
Comment thread CHANGELOG.md Outdated
- Cache key now includes environment-name + python-version (changing either
  no longer reuses a cache built for a different env/Python); restore-keys
  tightened to the same name+python (dropped the too-broad conda-{os}- fallback).
- Validate environment.yml exists in standard mode (fail fast) so a missing
  file can't be masked by a cache hit.
- Renamed the update step ('no exact cache hit' — it also runs on a restore-keys
  partial match, not only a true miss) and added --prune so deps dropped from
  environment.yml don't linger in an updated cached env.
- CHANGELOG wording corrected to match (no exact cache hit, not 'cache miss').

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mmcky
mmcky merged commit 2997df3 into main Jun 16, 2026
@mmcky
mmcky deleted the fix/setup-env-standard-cache branch June 16, 2026 09:31
mmcky added a commit that referenced this pull request Jun 16, 2026
Pin third-party actions to full commit SHAs (with a `# vN` comment) so a
hijacked upstream tag can't inject code into our workflows (cf. the
tj-actions/changed-files compromise):
- docker/login-action, docker/setup-buildx-action, docker/metadata-action,
  docker/build-push-action  (build-containers.yml, test-container.yml)
- softprops/action-gh-release  (publish-gh-pages)
- conda-incubator/setup-miniconda  (setup-environment)

First-party actions/* are left on major tags (GitHub-maintained, per GitHub's
guidance). Dependabot's github-actions ecosystem keeps the SHA pins current.

Note: conda-incubator/setup-miniconda is in setup-environment/action.yml, which
open PR #78 (#33) also edits — whichever merges second needs a trivial rebase.

Closes #39

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mmcky added a commit that referenced this pull request Jun 16, 2026
Pin third-party actions to full commit SHAs (with a `# vN` comment) so a
hijacked upstream tag can't inject code into our workflows (cf. the
tj-actions/changed-files compromise):
- docker/login-action, docker/setup-buildx-action, docker/metadata-action,
  docker/build-push-action  (build-containers.yml, test-container.yml)
- softprops/action-gh-release  (publish-gh-pages)
- conda-incubator/setup-miniconda  (setup-environment)

First-party actions/* are left on major tags (GitHub-maintained, per GitHub's
guidance). Dependabot's github-actions ecosystem keeps the SHA pins current.

Note: conda-incubator/setup-miniconda is in setup-environment/action.yml, which
open PR #78 (#33) also edits — whichever merges second needs a trivial rebase.

Closes #39

Co-authored-by: Claude Opus 4.8 <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.

setup-environment: fix standard-mode conda caching and validation

2 participants