Repository navigation
fix(setup-environment): bumping cache-version builds a fresh Conda environment (#205) - #206
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
By design this WIP commit adds only the failing test and omits the setup-environment key-layout fix, so the required harness check stays red and it is not mergeable until the follow-up fix lands.
Review effort: Balanced
Findings: None
What changed in this PR
This is a work-in-progress, test-first (TDD) PR that adds a single new harness job, env-version-bump, to the action-level PR harness (.github/workflows/test-actions.yml). It targets issue #205: bumping setup-environment's cache-version currently restores the previous Conda environment via a restore-keys fallback (because cache-version sits only in the exact key), so a bump never yields a fresh environment. The new job reproduces that bug by running setup-environment with a salted cache-version on env-seed's salted fixture and asserting that conda-cache-hit is empty (a true miss). On the current key layout the fallback restores env-seed's cache and reports 'false', so the job is expected to fail until the behavioural fix (moving cache-version ahead of the hash in setup-environment/action.yml) lands in a follow-up commit.
Changes:
- Add the
env-version-bumpjob that recreatesenv-seed's salted fixture, runssetup-environmentwithcache-version: bump-${{ env.SALT }}, and assertsconda-cache-hitis empty plus a fresh-env smoke check (import myst_nb). - Register
env-version-bumpin theharness-summary(Action harness: all checks)needslist so it is covered by the single required status check.
| File | Description |
|---|---|
.github/workflows/test-actions.yml |
Adds the env-version-bump harness job (reuses the env-seed salt/fixture and asserts an empty conda-cache-hit after a cache-version bump) and wires it into the harness-summary aggregation gate. |
The test logic itself is sound: the salt (run_id-run_attempt) keeps keys unique per run, env-seed is a needs: dependency so its cache is saved before this job runs, the hardcoded quantecon env name matches environment-name's default, $CONDA is a runner-default variable, and the fixture's jupyter-book dependency provides myst_nb. The harness-summary wiring is consistent with both the relevant (all-success) and not-relevant (all-skipped) branches. I found no concrete code defects to flag, so I have not stored any comments.
The one substantive point is inherent to the PR's own design rather than a code error: as it stands, this commit intentionally leaves the required Action harness: all checks job red because the corresponding setup-environment/action.yml key-layout fix is deferred to a later commit, and the branch is stacked on the unmerged #204.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ronment (#205) A new harness job, env-version-bump, runs after env-seed on the same salted fixture with a salted cache-version, and asserts that conda-cache-hit is empty: nothing restored. On the current key layout it fails by design. Fallback 1, conda-<os>-<name>-py<ver>-<hash>-, omits cache-version, so it restores env-seed's cache and the output is 'false'. The fix follows in the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb
…vironment (#205) cache-version was in the exact cache key but in neither restore-keys fallback, and the first fallback matched the same environment file under any version. So a bump restored the previous version's environment and ran `conda env update` on it, never a fresh build. The previous commit's harness job shows it: the bumped key missed, fallback 1 restored env-seed's ...-v1 cache, and conda-cache-hit was 'false'. cache-version now comes before the Python version and the file hash, and the key has one fallback, which includes it: key: conda-<os>-<name>-<cache-version>-py<python>-<hash> fallback: conda-<os>-<name>-<cache-version>-py<python>- An edit to the environment file still restores the latest environment of the same version and updates it; a bump, a Python change or a name change restores nothing. The key format changes, so the first standard-mode run after the release builds from scratch once. No current consumer runs setup-environment in standard mode. - cache-version and conda-cache-hit descriptions, and the chapter's generated table, cache-key table and troubleshooting, follow. - QUICK-REFERENCE's advice to bump cache-version is right again, so #204's notes against it are reverted; only its key format changes. - CHANGELOG: a Fixed entry, and #204's Documentation entry no longer describes the old behaviour. TESTING's coverage row and PLAN follow. - The bjc-smoke comment no longer assumes @v0 shares the key format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb
4e99c16 to
f644af9
Compare
…idy up after #206 (#208) #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. Claude-Session: https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb Co-authored-by: Claude <noreply@anthropic.com>
Move [Unreleased] into a dated 0.13.0 section (decision 11, 2026-11-04), and record the deploy-CLI moves since v0.12.0 (#207, #219), which Dependabot made without a CHANGELOG entry. The release carries #198, #206 and #210 to @v0 consumers, so it is staged on the canary before v0 moves. This commit changes only CHANGELOG.md, and the harness has no @v0 workaround for this release to drop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WT8bMbMmeUUEj8EjiweB6S
Fixes #205. It was stacked on #204, whose chapter and descriptions it changes. Since #204's squash merge it is rebased onto
main, with both commits unchanged in content.The bug
cache-versionwas in the exact Conda cache key but in neitherrestore-keysfallback. The first fallback,conda-<os>-<name>-py<python>-<hash>-, matches the same environment file under any version. So a bump restored the previous version's environment and ranconda env updateon it, and never built a fresh one.The fix
cache-versionmoves ahead of the Python version and the hash, and the key has one fallback, which includes it:cache-versionenvironment.ymlpython-versionorenvironment-nameEvidence: red, then green
The two runs linked below ran on the same commits before the rebase,
ac7d10dand4e99c16, whose trees are identical to these.390f7c0adds only the new harness job,env-version-bump, against the old key layout. It runs afterenv-seedon the same salted fixture, with a saltedcache-version, and asserts thatconda-cache-hitis empty. It failed exactly as setup-environment: bumping cache-version does not give a fresh Conda environment #205 describes:f644af9is the fix. The same job passes, and the whole harness is green.env-hit-buildstill gets its exact hit under the new format.Also in this PR
cache-versionandconda-cache-hitdescriptions, and so the chapter's generated tables. The chapter's cache-key table and its "restored environment is broken" entry now say to bumpcache-version.docs/QUICK-REFERENCE.md: its advice to bumpcache-versionis right again, so docs(manual): doc generator and drift checks, the chapter template, and the setup-environment chapter (#178 PR 2) #204's notes against it are reverted. Relative tomain, only its key format changes.bjc-smokecomment no longer assumes@v0shares the key format.Rollout
setup-environmentrun it in thequantecon-buildcontainer, where there is no Conda cache.bjc-*harness jobs untilv0moves. Their innersetup-environment@v0keeps the old layout, so it missesenv-seed's cache and solves fresh or from an older run's cache. That's slower but correct, and it resolves itself oncev0moves. There is no workaround to remove at release.setup-environmentin standard mode, soenv-seed,env-hit-buildandenv-version-bumpare its coverage.🤖 Generated with Claude Code
https://claude.ai/code/session_01FeKTxWtkzVMyPbqeSgM2Tb