Skip to content

testing: publish/preview/cache action logic has no automated tests #100

Closed

Description

@mmcky

Surfaced by the v0.8.0 validation study.

Problem

Containers are covered end-to-end (build-containers.yml → test-container.yml / test-containers-lectures.yml), and since v0.10.0 so are the cache and environment actions, on the PR's own code. Untested: the publish and preview layer, plus the @v0 sibling-pin chain only a released ref can reach.

Coverage — harness (.github/workflows/test-actions.yml, via uses: ./; bare :N are its lines) / canary (QuantEcon/test-actions-lecture-intro, pinned @v0):

  • restore-jupyter-cache ✅ both cache types × both modes, fail-on-miss firing and staying quiet (:195, :234, :268, :301, :332, :362, :394) / ✅ ci.yml:23
  • setup-environment ✅ standard-mode conda cache, two-run miss→hit chain (:431, :461) / ✅ via build-jupyter-cache
  • build-lectures ✅ real executed HTML build, both directions (:461, :508) / ✅ six call sites in ci.yml, publish.yml
  • build-jupyter-cache ⚠️ runs (:591, :638, :698, :784, :818) but its internal calls execute @v0, not the PR / ✅ cache.yml:27
  • preview-netlify ❌ needs a real deploy target / ⚠️ ci.yml:54, fires only on a PR opened there — no successful deploy between 2026-02-10 and 2026-08-05
  • preview-cloudflare ❌ / ❌ called nowhere — no harness job, no canary call site
  • publish-gh-pages ❌ would publish this repo's own Pages / ⚠️ publish.yml:56, fires only on a publish* tag pushed there — last run 2026-02-10, so v0.7.0–v0.11.1 never went through it

Behind the ❌s: uses: takes no expressions and build-jupyter-cache pins siblings hardcoded (setup-environment@v0 at build-jupyter-cache/action.yml:149; build-lectures@v0 at :164, :174, :184), so that chain is untestable pre-release; the previews and publish-gh-pages need real deploy targets end to end, hence TESTING.md:37 assigns them to the canary — but see stage 1.5 below, which that framing has been writing off. The relevance gate is blind too — the IGNORED list at test-actions.yml:112 misses preview-*/action.yml, so a preview-only PR runs all 15 substantive jobs and reports the required check Action harness: all checks green without running a line of preview code. Publish/preview confidence rests on code review plus production publishes in the lecture repos, which is where this issue started.

Why it matters

A publish or cache regression surfaces only when a real build fails — the layer whose gaps hid #28 (see #83). preview-cloudflare, uncovered everywhere, shipped PR comments linking the per-deployment hash rather than the stable pr-N alias, and a deploy-url returning the alias on one wrangler release and the hash on another; both caught by reading, fixed in v0.11.1 (#131). #105 (preview deploy errors swallowed) is the same shape, still open. Canaries also decay untended: the weekly cache.yml build ran every Sunday to 2026-04-12, missed 16 consecutive Sundays, resumed 2026-08-09 — the first Sunday after activity returned 2026-08-05, the signature of GitHub disabling a schedule after 60 days of repository inactivity. v0.7.0, v0.8.0 and v0.9.0 all shipped in that window, unnoticed.

Stage 1 — shipped

17 jobs: a relevance gate (:75), 15 substantive jobs, and harness-summary (:854), whose job name Action harness: all checks is the required check on main. Fixtures are salted per run, jobs assert on outputs and filesystem, and negative jobs unit-build-miss-guard (:301), build-fail-guard (:508), bjc-fail-guard (:638), bjc-abort-guard (:698) stop a swallowed failure passing green. TESTING.md:25 documents it as stage 1. #29's env-test half landed with it — env-seed (:431), env-hit-build (:461), the two-run standard-mode conda miss→hit chain, done under PLAN.md backlog item 9; #29's docs half remains.

  • Make the harness's green honest about what it did not run — naming the un-exercised actions in harness-summary's output is enough.

Stage 2 — make the canary consume the shipped templates

The canary — named in PLAN.md's "Consumers in production" table and TESTING.md:47, superseding QuantEcon/test-lectures from the design proposal comment below — is live, pinned @v0 and runs the full chain, but does not consume templates/ verbatim, so what we ship consumers is validated nowhere.

Stage 3 — coverage needing a real deploy target

  • preview-netlify — a call site on a real deploy target — the canary deploys real Netlify previews at ci.yml:54, with the tokens it needs.
  • publish-gh-pages — a call site on a real Pages target — the canary publishes at publish.yml:56; that it has not run since 2026-02-10 is a trigger problem, and belongs to Release gating: a gate.yml in the canary tests the candidate before v0 moves #135.
  • preview-cloudflare — the only action with zero coverage in either harness. Needs a Cloudflare Pages project and an API token on the canary, plus a call site: a second preview job in its ci.yml, or a dedicated workflow. Also the action most recently found broken by reading, which argues for doing it first.

Scope boundary

Stage 1.5 — the deploy-action logic that needs no deploy target

"Needs real deploy targets and secrets" is true of the deploy itself and false of most of what these three actions actually do. The following are pure functions of their inputs, testable in this harness today with no Cloudflare project, no Netlify account, no canary and no #136 fixture repo — and they are the parts that have silently shipped wrong before:

  • Extract the duplicated ~87-line PR-comment renderer from preview-netlify and preview-cloudflare into a shared script (PLAN item 6) and assert the rendered URL paths, including the strip-lectures-dir variants
  • Extract publish-gh-pages' release-asset packaging and assert the tarball, its SHA256 checksum, and the JSON manifest fields against a fixture directory
  • Assert CNAME injection and build-directory validation against a fixture
  • Correct the "needs real deploy targets and secrets" line here and at TESTING.md:37, which currently writes off work that needs neither

This matters more now than when this issue was filed: #135/#136 have moved the real-deploy route behind a new fixture repo that does not exist yet, so the pure-logic half is the only preview/publish coverage reachable in the near term. It also removes the duplication PLAN item 6 tracks, so the extraction pays for itself twice.

Activity

  1. mmcky commented on Jul 23, 2026

    @mmcky
    ContributorAuthor

    Design proposal: a two-part harness, not one

    This issue's suggested fix is "a minimal fixture repo/workflow". This is a concrete proposal for its shape, prompted by the v0.9.0 release — where the only consumer-facing change (#104) had to be verified with a throwaway harness on a branch, because nothing in CI exercises the cache actions at all.

    The short version: one harness can't do this job, because of a structural constraint in how our own actions call each other. Two cheap harnesses can, and they catch different things.

    The constraint that shapes everything

    GitHub does not allow expressions in uses:. A ref cannot be parameterised, ever.

    That matters because build-jupyter-cache calls its siblings at a pinned ref — setup-environment@v0 at action.yml:132, and build-lectures@v0 at :147, :156 and :165. That pinning is correct and deliberate — it's the H8 fix from v0.8.0, and it exists because relative ./ paths in a composite action resolve against the consumer's workspace, not this repo.

    The consequence: a test repo pinned at @main still executes @v0 for everything build-jupyter-cache calls internally. That chain cannot be tested before release, by construction. No harness design gets around it, so the design should stop trying and split the work instead.

    The proposal

    A. A PR-time harness, in this repo, using ./ local paths. Fast, synthetic, runs on every PR that touches an action. This is a generalisation of the throwaway harness used to verify #104: seed a fixture, invoke the action, assert on its outputs and on the filesystem, fail the job on any mismatch. It caught the #104 defect and a control run against the pre-fix code proved it detects it rather than merely passing.

    B. A post-release canary, in a separate QuantEcon/test-lectures repo pinned at @v0. Runs on a schedule and immediately after each tag move. This is the only thing that exercises the real consumer path, including the sibling-pinned chain that A structurally cannot reach.

    Action A: PR harness B: canary
    setup-environment ✅ ✅
    build-lectures ✅ ✅
    restore-jupyter-cache ✅ both modes, both cache-types ✅ real branch/PR cache scoping
    build-jupyter-cache ⚠️ runs, but its internal calls execute @v0, not the PR ✅
    preview-netlify, preview-cloudflare ❌ needs a real deploy target ✅
    publish-gh-pages ❌ would publish this repo's own Pages ✅

    Why B has to be a separate repo

    The decisive reason is the one above: in this repo the workspace is the actions repo, so the exact condition that breaks for consumers is the condition that works in an in-repo test. The bug class is invisible here.

    Two practical reasons follow. publish-gh-pages needs a real gh-pages branch and the preview actions need real deploy targets — neither of which should point at the actions repo. And the cache actions' semantics that matter most (branch-scoped caches, main→PR inheritance) only exist where there is a real main branch and real PRs.

    The fixture is where the current gap is worst

    The existing minimal fixture at containers/quantecon/tests/minimal-jupyter-book/_config.yml cannot fail in the ways that matter — already noted in #108:

    Setting Effect
    execute_notebooks: "off" No code cell ever runs, so the kaleido/Chrome stack is never exercised — the exact failure mode behind the v0.9.0 kaleido<1.0 pin
    html_theme: sphinx_book_theme The pinned quantecon-book-theme is never imported
    fontpkg: "" Suppresses the FreeSerif path that the .otf-symlink workaround in the Dockerfile exists for

    A fixture worth having deliberately exercises the three things that have actually broken in production: a plotly cell that forces static-image export, a matplotlib cell, and the real quantecon_book_theme under xelatex. Keep it to roughly five lectures so a build is 2–3 minutes rather than the 107 minutes the real-repo matrix takes.

    If the canary consumes templates/cache.yml, templates/ci.yml and templates/publish.yml verbatim, it also validates the shipped templates — which #109 flags as having drifted from the shipped code. Two birds.

    Suggested staging

    Each stage is independently useful, so this doesn't have to land as one lift.

    1. PR harness for the cache actions — no new repo, no secrets, generalises what already exists as a throwaway. Closes the largest gap for the least work.
    2. Create test-lectures with the fixture and the templates verbatim, wiring cache.yml on main and ci.yml on PR. Covers the build-jupyter-cache chain and real cache scoping.
    3. Add preview and publish coverage — this is the stage that needs secrets (Netlify token and site, Cloudflare token, a gh-pages branch).
    4. Trigger the canary on tag push, so every release is smoke-tested against a real consumer before the lecture repos see it.

    What this still won't cover

    Worth stating plainly so the harness isn't over-trusted. It won't cover pre-release testing of the build-jupyter-cache sibling chain — that's the structural constraint, and stage 4 mitigates it by shortening the window rather than closing it. It won't cover real-scale performance or content diversity, so test-containers-lectures.yml against the three real lecture repos stays as-is. And the lecture-jax GPU path remains out of scope while QuantEcon/lecture-jax#284 is open.

    Why this is worth the maintenance

    The evidence is specific rather than general. restore-jupyter-cache's save-cache: true mode shipped dead on arrival in v0.8.0 — every output empty, fail-on-miss failing unconditionally — and survived until a maintenance audit found it eight months later (#104). A canary running the save-cache path would have caught it the same day. #105 (preview deploy errors swallowed) and #34/H4 are the same shape: bugs in the layer with no tests, found by reading rather than by failing.

    A secondary benefit worth noting: a canary makes the "repin consumers" step safe. Repin the canary first, watch one real build, then repin the lecture repos — instead of lecture-dp being the thing that discovers a regression.

  2. mmcky commented on Aug 11, 2026

    @mmcky
    ContributorAuthor

    Assessed this from the consumer side while auditing quantecon/actions adoption across the Python lecture family (QuantEcon/workspace-lectures#31), where it decides whether the lecture repos float on @v0 or carry exact pins. Two things worth feeding back.

    This issue's body now understates the coverage

    The body predates the harness that answers most of it, and it is the first thing a reader finds when asking "is the action logic tested?" — so it currently reads as a much larger gap than exists. What has actually shipped:

    Layer State
    test-actions.yml (stage 1) 15 jobs exercising restore-jupyter-cache (7), build-jupyter-cache (4), setup-environment (3), build-lectures (3) through uses: ./, asserting on outputs and filesystem, with deliberate fail-guard and abort-guard jobs. Enforced as the required check Action harness: all checks on main, so it is a gate rather than a signal
    test-actions-lecture-intro (stage 2/3) Live, pinned @v0, running the real chain including publish-gh-pages and preview-netlify — the two this repo structurally cannot test

    A note in the body pointing at the shipped state would stop the next reader drawing the conclusion I nearly did.

    The remaining gap is lead time, not coverage

    The premise of a canary is that it meets a bad release before production does. Checking the triggers, it does that on one of the three consumer paths:

    Path Canary trigger Lecture-repo trigger Lead time
    Weekly cache build schedule, Sunday 03:00 UTC Monday 02:00 UTC (lecture-dp), 03:00 UTC (other six) 23–24 hours
    PR preview pull_request in the canary every PR in every lecture repo none
    Publish tag push in the canary tag push in each lecture repo none

    The cache ordering is real and looks deliberate — Sunday ahead of Monday is not an accident, and that is the path where the two-month silent-alerting failure happened.

    The other two have no lead at all. The canary's ci.yml fires only when a human opens a PR there, which is sporadic in practice (2026-08-05, and before that 2026-07-15), and its publish.yml fires on a tag push in the canary rather than on a release here. Nothing dispatches the canary when v0 moves, and there is no release automation in this repo — the tag is moved by hand.

    So on the highest-consequence path, the first real consumer of every release is a published lecture site.

    Why that makes stage 4 the priority

    Stage 4 is listed last in the staging plan, but it is what converts the canary from a detector into a gate, and it is the smallest of the four. Coverage work — more assertions, more fixtures — does not change the ordering; only triggers do.

    Concretely, two small changes would close it:

    • put the canary's ci.yml and publish.yml on a schedule ahead of the Monday cache builds, so both paths are exercised on the same weekly cadence the cache path already enjoys;
    • repository_dispatch the canary when v0 moves, so a release is smoke-tested against a real consumer before any lecture repo picks it up.

    The second also makes the repin step safe in the way the closing argument of the design comment above anticipated: repin the canary, watch one real build, then repin consumers — rather than lecture-dp discovering a regression.

    Consumer-side stake

    Worth stating plainly since it is not visible from inside this repo. The lecture family is currently split three ways — @v0 (2 repos), v0.8.0 (3), v0.9.0 (2) — and QuantEcon/workspace-lectures#31 settles that on floating @v0, on the strength of the harness and canary above. It sequences the sweep behind this gap, because all six exactly-pinned call sites are on publish-gh-pages, which is precisely the least-gated action today.

    Separately, PLAN.md's "Consumers in production" table lists only lecture-dp, lecture-python.myst and the canary, and states "no exact pins left". The audit found six exactly-pinned call sites across five lecture repos it does not list (lecture-jax ×2, lecture-python-intro, lecture-python-advanced.myst, lecture-python-programming, continuous_time_mcs). Flagging it here rather than opening a second issue, since the versioning argument in that section was reasoned partly from that table.

  3. mmcky commented on Aug 11, 2026

    @mmcky
    ContributorAuthor

    Followed up on the lead-time finding above with a concrete gating proposal: #135.

    The short version of what turned up while designing it — the canary cannot gate a release as built, for a reason that is structural rather than a scheduling oversight. All ten of its action references are @v0, which is the tag a release moves, so it always exercises the previous release. It is a post-release regression detector; no change to its triggers makes it a gate.

    #135 proposes a v0-next staging tag as the fix, since it sidesteps the "no expressions in uses:" constraint without needing parameterised refs. It also records what that still would not cover: a build-jupyter-cache@v0-next run executes setup-environment@v0 and build-lectures@v0, so the candidate's cache action is tested against the previous release's siblings — the structural limit this issue already names, narrowed to one action's internal chain rather than removed.

  4. added
    infrastructure
    and removed on Aug 11, 2026
  5. mmcky commented on Aug 11, 2026

    @mmcky
    ContributorAuthor

    Stage 4 now has a tracking issue of its own: #138, with the design split across #135 (the v0-next gate mechanism) and #136 (the fixture the gate needs).

    Worth recording here, since this issue is where people look first for the state of testing: stages 1–3 have landed and this issue's body understates them. test-actions.yml is 15 jobs across restore-jupyter-cache, build-jupyter-cache, setup-environment and build-lectures, enforced as the required check Action harness: all checks; test-actions-lecture-intro runs the real chain including publish-gh-pages and preview-netlify. A reader arriving cold currently concludes there is no action-level testing at all.

    What is left is not coverage — it is that the canary pins @v0, so it can only ever exercise a published release, never a candidate. That is what #138 sets out to close.

  6. mmcky commented on Nov 4, 2026

    @mmcky
    ContributorAuthor

    From the 2026-10-06 codebase review (finding M5; record: .qe/dev/log/2026-10-06-codebase-review.md, #220).

    Two static checks for this coverage issue that nothing tracks yet:

    • actionlint over this repository's own workflows. The harness gate installs and verifies actionlint, but scripts/generate-docs.py --check-examples gives it only templates/ and the manual's examples. So .github/workflows/*.yml is never linted: about 2,400 lines, including the relevance gate whose self-test the required check depends on. Expect the first run to need a few fixes or documented -ignore flags.
    • shellcheck over the composite actions' run: blocks. actionlint does not read action.yml, so nothing checks the 50 run: blocks in the eight actions. Extract them with PyYAML, replacing each ${{ … }} with a placeholder word, then run shellcheck. A trial on 4550f69 at shellcheck -S warning found only constant-comparison hits (SC2050/SC2157), all at expression sites that docs/dev/PLAN.md backlog item 18 covers. At that severity the check should go green once those sites are handled. Default severity also reports info-level SC2086 hits, mostly unquoted $GITHUB_OUTPUT.

    The rest of the finding is already filed:

  7. mmcky commented on Nov 10, 2026

    @mmcky
    ContributorAuthor

    Closing. What this issue asked for is covered, apart from two items carried elsewhere.

    Carried forward: detecting a canary that silently stops running is now on #302, and bringing the canary's workflows back in line with templates/ is #310.

    Claude Code (on behalf of mmcky)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions