Skip to content

test(setup-environment): check the cache fallback within a version; tidy up after #206 - #208

Merged
mmcky merged 1 commit into
mainfrom
claude/stoic-newton-u867m9
Sep 28, 2026
Merged

mmcky merged 1 commit into
mainfrom
claude/stoic-newton-u867m9

Conversation

@quantecon-services

Copy link
Copy Markdown
Collaborator

Follow-up to #206 (#205), and tidy-up before #190.

The missing half of #205's test

#206's env-version-bump proves a cache-version bump restores nothing. Nothing checked the other half: that an edited environment file under the same version still restores through the fallback and is then updated. That fallback is why #206 kept a fallback at all, instead of dropping restore-keys. A change that dropped it would have left the harness green while every edit to environment.yml cost a full build.

New job, env-file-edit:

  • It uses env-seed's salted fixture plus one extra line, so the file's hash differs from every cache and only the fallback can match.
  • It asserts that conda-cache-hit is 'false' and that the environment works.
  • env-seed has already saved a cache under the same cache-version, so the result is deterministic.
  • If the fallback is missing, the output is empty and the job fails. If the fallback crossed versions, env-version-bump would fail instead.

Log accuracy

  • setup-environment's closing summary said "Installed fresh" whenever there was no exact hit, including after a fallback restore. It now says "Restored from an earlier cache, then updated from the environment file" in that case.
  • env-seed's success line claimed "environment created fresh". Its log shows it usually restores another run's cache through the fallback, so the line now says so.

Docs

Testing

  • scripts/generate-docs.py --check --check-examples --actionlint passes.
  • actionlint on the harness shows only the existing SC2086 note in the gate.
  • shellcheck passes on the changed summary script, and running it with conda-cache-hit as true, false and empty prints each of the three lines.
  • CI runs the new job.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb


Generated by Claude Code

…idy up after #206

#206 tested one half of #205: a cache-version bump restores nothing.
Nothing checked the other half, that an edited environment file under
the same version still restores through the fallback. A change that
dropped the fallback would have left the harness green while every
edit cost a full build.

- New harness job, env-file-edit: env-seed's salted fixture plus one
  line, so only the fallback can match, and conda-cache-hit must be
  'false'. env-seed has saved a cache under the same version, so the
  result is deterministic.
- setup-environment's closing summary tells the fallback case apart
  ("Restored from an earlier cache, then updated from the environment
  file") instead of reporting it as "Installed fresh".
- env-seed's success line no longer claims the environment was created
  fresh: it usually comes from another run's cache through the
  fallback.
- TESTING.md: the stale cache-key debug snippet becomes a pointer to
  the cache step's log and the chapter's key table; the coverage row
  gains the new job. CHANGELOG's #205 entry covers both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb

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.

Copilot review overview

🔵 Needs a closer look

Correctness hinges on GitHub Actions cross-job cache fallback semantics that cannot be executed or verified in this review environment, warranting a human's final confirmation.

Review effort: Balanced
Findings: None

What changed in this PR

This PR is a follow-up to #206/#205 that fills the missing half of the setup-environment Conda-cache test coverage. #206 proved that bumping cache-version restores nothing (a fresh build); this PR adds the complementary proof that an edited environment file within the same cache-version still restores the latest environment through the restore-keys fallback and then updates it, so an edit does not cost a full build. It also tightens two log messages that misreported a fallback restore as a fresh install, and refreshes the now-stale cache-key debug guidance in the testing docs.

Changes:

  • New harness job env-file-edit in test-actions.yml asserting conda-cache-hit == 'false' after editing the salted environment file, with the job wired into the harness-summary anchor.
  • setup-environment's standard-mode summary now distinguishes a fallback restore (conda-cache-hit == 'false') from a true fresh install, and env-seed's success line no longer overclaims "created fresh".
  • Docs/CHANGELOG updates: the TESTING.md coverage row and debug snippet, plus a CHANGELOG note covering both new jobs and the summary wording.
File Description
.github/​workflows/​test-actions.yml Adds env-file-edit job (salted fixture + extra line so only the fallback matches), asserts conda-cache-hit=='false' and the env imports myst_nb; softens env-seed's success message; registers the job in harness-summary needs.
setup-environment/​action.yml Adds an elif for conda-cache-hit=='false' in the standard-mode summary to report a fallback-restore-then-update instead of "Installed fresh".
docs/​dev/​TESTING.md Updates the setup-environment coverage row to mention the new job and replaces the stale cache-key debug snippet with a pointer to the cache step log and the chapter's key table.
CHANGELOG.md Expands the #205 Fixed entry to cover env-file-edit and the summary wording change.

I verified the determinism argument: env-file-edit needs: env-seed, so env-seed's cache is saved (under a per-run-unique salted key sharing the default cache-version/environment-name/python-version prefix) before this job runs; the appended # harness-edit line changes only the file hash, so the exact key misses while the conda-<os>-<name>-<cache-version>-py<python>- fallback matches, yielding 'false'. The doc link anchor (#standard-mode) and target file both exist, and the summary elif is correctly scoped inside the standard-runner branch. No blocking issues found.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mmcky
mmcky merged commit 195a11b into main Sep 28, 2026
27 checks passed
@mmcky
mmcky deleted the claude/stoic-newton-u867m9 branch September 28, 2026 09:54
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.

4 participants