Skip to content

feat(build-lectures): an engine input, jb1 or mystmd (#337) - #365

Open
mmcky wants to merge 2 commits into
mainfrom
feat/337-engine-mystmd
Open

mmcky wants to merge 2 commits into
mainfrom
feat/337-engine-mystmd

Conversation

@mmcky

@mmcky mmcky commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Adds an engine input to build-lectures: jb1, the default, builds with jb build as before, and mystmd runs mystmd's myst build. This is the design agreed on #337, with the maintainer's seven decisions of 2026-11-28 recorded in the check comment.

Why. QuantEcon/lectures builds its sites from one pool of lectures, and wants the engine as a matrix axis: Jupyter Book 1 publishes until the engine switch, and a mystmd leg runs beside it, non-publishing (QuantEcon/project-monorepo#77, the design note .qe/dev/log/2026-11-16-product-builds-design.md). Its site-build.yml is Jupyter Book 1 only today, and puts mystmd in its second phase, after the cutovers.

A myst build with only the builder's flag passes where a jb1 build fails, so the input does more than swap the command. I checked with upstream mystmd 1.13.0, the QuantEcon/mystmd fork's base: --html builds of a two-page project, and the CLI's source at the fork's 39cda14 for the rest.

Case --html --pdf, --ipynb
No --execute executes nothing the same
A cell that raises exits 0, and 1 only with --strict exits 0, with or without --strict
A Jupyter server that does not start exits 1 only with --strict exits 0
An error raised while a result is displayed (#247) exits 0, even with --strict exits 0
Nothing to build: no site:, or no exports exits 0 exits 0
A page that fails to render logs Error fetching <url>, exits 0 —
jb's -W, the old extra-args default exits 1: unknown option '-W' the same

Changes

File Change
build-lectures/action.yml engine, jb1 by default. Empty means jb1; myst and any other value are refused. extra-args defaults to empty, the engine's own: -W --keep-going on jb1, --strict on mystmd, resolved in the first step with the other defaults. On a mystmd-based engine the first step refuses another builder, the two copy inputs, an output-dir other than ., a source-dir with no myst.yml, and jb build's flags in extra-args, and logs that nitpick and error-outputs are not used. The jb1 build step is unchanged but for its if: and the resolved extra-args. A new step, "Build lectures with mystmd": fails early without myst, logs command -v myst and myst --version, and for jupyter checks for --ipynb; sets NODE_OPTIONS=…--dns-result-order=ipv4first and, as root, Jupyter's allow_root through JUPYTER_CONFIG_PATH from $RUNNER_TEMP; runs myst build <flag> --execute <extra-args> from source-dir; and after an exit 0 checks what was written. The failure summary names the engine, and a separate upload step takes mystmd's logs, temp and execute. The error-output check runs on jb1 only
build-lectures/check-myst-exports.py New. For pdflatex and jupyter on mystmd: reads _build/logs/myst.build.json, which lists the exports myst collected before it ran them, and fails unless it lists one of the builder's formats (pdf, pdf+tex, typst; or ipynb) and each one's output was written by this build
docs/user/actions/build-lectures.md The opening and Requirements per engine; a mystmd example that builds the fork at a pin and caches it packed; the downloads and extra-args on mystmd; "With engine: mystmd" under Behaviour, with the command table and a table of what applies on each engine, which cites #364; what fails the job; a Troubleshooting entry for each new error. Inputs and Outputs regenerated
build-lectures/README.md, docs/user/README.md Regenerated: the action's description names both engines
.github/workflows/test-actions.yml Two jobs beside build-html-copy, and in harness-summary's needs: beside it: build-engine-inputs and build-mystmd (below)
.github/fixtures/mini-mystmd/ New: a myst.yml with a site:, an intro and an executed lecture
.github/fixtures/myst-stand-in/ New: the stand-in myst and jb that build-engine-inputs puts on PATH
.github/fixtures/bjc-alert/test.cjs Its check that build-jupyter-cache's extra-args default is build-lectures' own now compares with build-lectures' jb1 default, read from the one line in its check step that sets it, when the declared default is empty
build-jupyter-cache/action.yml The comment on its extra-args default, which said an explicit '' would drop -W. It now says why the default is spelled out: the failure issue's repro commands are written from it
docs/dev/TESTING.md build-lectures' row covers the two jobs
CHANGELOG.md ### Added for the engine and ### Changed for extra-args' default, under [Unreleased]

Outside my usual scope, with the organiser's OK: the comment in build-jupyter-cache/action.yml, which became false, and bjc-alert/test.cjs, whose check would otherwise go red: it compared the two actions' declared extra-args defaults, and build-lectures' is now empty. Neither changes what build-jupyter-cache does.

The harness jobs

  • build-engine-inputs runs the action 21 times against a stand-in myst that records its folder, arguments, NODE_OPTIONS and BASE_URL, and writes what a build would, or what a failure leaves:
    • html, pdflatex and jupyter pass, each running build <flag> --execute --strict in source-dir, with NODE_OPTIONS set and a step's BASE_URL reaching myst, the right build-path, and an empty error-output-count. The records show the command lines only: --strict does nothing on the exports (build-lectures on mystmd: fail on execution errors in pdflatex and jupyter builds, and on error outputs in every build #364);
    • the step fails after the build for no index.html (with the html case's still there), an Error fetching line for one of the site's own pages, no export, a listed export not written (with the jupyter case's still there), and myst exiting 1;
    • an Error fetching line for an external address, as --check-links gives for a dead link, passes: only myst's own content server, http://localhost:<port>, serves the site's pages;
    • it fails before calling myst for no myst on PATH, a myst with no --ipynb, another builder, html-copy-pdf, html-copy-notebooks given as True, an output-dir, a source-dir with no myst.yml, -W --keep-going, engine: myst and engine: bogus;
    • with a stand-in jb, jb1 by default, and with engine and extra-args both empty, runs jb build harness-jb --path-output . -n -W --keep-going, the command before this change.
  • build-mystmd is a real html build in ghcr.io/quantecon/quantecon-build:latest, as root, with upstream [email protected] from npm (one package) and the book-theme template pinned by commit and cached, so myst fetches no template. The executed cell's output is on its page, and a copy with a cell that raises fails the step: its traceback is in the page's content, and no site was written. Running as root in the image exercises both container settings: without them Jupyter does not start, which --strict fails, and the pages fail to render. PDF and notebooks are covered by the stand-in only: a real --pdf fetches a LaTeX template, and --ipynb needs the fork.

They fail on the code before this change. scratch/337-engine-red held main's build-lectures (3b70eda), these fixtures and a throwaway workflow with the two jobs as they are here, without the gate. In run 46139194026 both failed, each case for the expected reason:

  • in build-engine-inputs, the runner warned Unexpected input(s) 'engine' and the action ran jb build, so 16 of the 17 mystmd cases failed, each showing the stand-in jb ran where myst should have, as in ran with [build harness-myst --path-output . -n -W --keep-going], expected [build --html --execute --strict]. Every input that is now refused went through. no-myst fails either way;
  • jb1 passed: its command is the same;
  • jb1-empty failed with ran with [build harness-jb --path-output . -n]: on main an explicit extra-args: '' drops -W, which is the ### Changed entry;
  • build-mystmd failed in "Build the site", where jb build found no _config.yml in the mystmd project.

scratch/337-engine-green, this branch plus the same workflow, passed both jobs in run 46139197018. There, in the lean image as root, myst 1.13.0 built the site with the cell's output on its page, and the raising cell's build ended with "Site has 1 error and 0 warning, stopping build". An earlier pair, 46138604935 and 46138623247, gave the same verdicts. The red one also showed that the assertion step stopped at its first failing case under set -e, so it now reports each one. Both branches are deleted.

What I checked

  • The issue first. The check on #337, reviewed fresh by another session before the questions went to the maintainer, re-read every fact the issue cites against main and QuantEcon/lectures, and the mystmd CLI's source at the fork's 39cda14, upstream 1.13.0 and 1.14.0. It found the command alone was not enough (the table above), and that --ipynb is the fork's. Every caller of build-lectures@ in the QuantEcon organisation (lecture-dp, QuantEcon/lectures, the canary, test-lecture-theme-sphinx, build-jupyter-cache) passes neither engine nor extra-args: '', so none changes.
  • The action's two scripts, the first step's and the mystmd build step's, run locally against the stand-in myst over 19 cases, and the first step on jb1 with an empty, explicit, whitespace-only and two-line extra-args.
  • bjc-alert's test, run locally with the harness's own Python: it passes against this branch and against main's build-lectures, and fails, naming build-lectures' value, when the jb1 default in the check step is changed.
  • generate-docs.py --check --check-examples --actionlint (actionlint 1.7.12): the generated docs are current (24 files), and the 21 complete workflows in the docs, the new mystmd example among them, pass actionlint with shellcheck. actionlint and scripts/lint-shell.py: clean. shellcheck on the stand-ins: clean.

What to watch after merge

  • At release the release gate and the canary build with jb1. Their "Build Command" groups should match v0.22.0's, jb build lectures --path-output . -n -W --keep-going, for publish.yml's three builds and ci.yml's. That is the canary's whole part: there is no mystmd canary for now.
  • build-mystmd pulls the lean image and installs mystmd from npm on each run. If npm or the image pull is unavailable, it goes red with no change here. It needs MYSTMD_VERSION and BOOK_THEME_SHA bumped together, by hand.
  • The first real mystmd caller is QuantEcon/lectures' mystmd leg, in its second phase.

Not in this PR

Closes #337

🤖 Generated with Claude Code

https://claude.ai/code/session_01WT8bMaCAew38BRvFFUUn3G

engine: jb1, the default, builds with jb build as before. engine: mystmd
runs mystmd's myst build from source-dir, the folder that holds myst.yml,
with --html, --pdf or --ipynb (the QuantEcon/mystmd fork's) for the html,
pdflatex and jupyter builders, --execute always, and --strict when
extra-args is empty, which is now its default: the engine's own
arguments, -W --keep-going on jb1.

myst build exits 0 when it builds nothing, so after a build that exits 0
the step checks what was written: the site's index.html and its pages, or
each export myst listed. For the myst command it prefers IPv4 in Node and,
as root, lets jupyter_server start, which a QuantEcon container needs.
Inputs with no mystmd meaning, and jb build's flags, are refused before
the build. Only an html build fails on a cell that raises, and the
error-output check has no mystmd version yet: both are #364.

Harness: build-engine-inputs, against a stand-in myst, and build-mystmd, a
real html build with upstream mystmd in the lean image as root.
bjc-alert's test reads build-lectures' jb1 default from its check step.

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

mmcky commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

The first harness run, 46139725822, was red on four known flakes, not on this change. I've re-run all its jobs once.

  • The artifact race (publish-gh-pages: mode all can fail its deploy when the artifact listing lags the upload (actions/deploy-pages#451) #359), in publish-modes, build-fail-guard and bjc-fail-guard: an artifact uploaded earlier in the job wasn't found when the job downloaded it. In build-fail-guard, the one of the three that runs this branch's build-lectures, the action's upload reported build-fail-guard-reports uploaded at 11:25:52.17, and the download 0.26 s later found no artifact by that name. bjc-fail-guard runs build-lectures@v0, not this branch.
  • env-latex-hit: latex-cache-hit came back false where it expected true, with apt mirrors answering 503 in the same job. This PR doesn't touch setup-environment or setup-latex.

I used "Re-run all jobs" rather than "Re-run failed jobs", because the setup-latex seed's cache key carries the run attempt. The two new jobs, build-engine-inputs and build-mystmd, passed on the first attempt.

Claude Code (on behalf of mmcky)

@mmcky

mmcky commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Attempt 2 of 46139725822 was red on one job, the same flake, so I've re-run all jobs once more (attempt 3). The three artifact-race jobs and both new jobs passed. setup-latex: an exact hit installs from the cache and contacts no mirror failed with cache-hit: expected [true] … got [false]. Its seed and hit ran on one runner image, ubuntu-26.04 20261122.9.1, but the host hashes in their cache keys differ (7f3bafd56d01fd88 against c194940003556d4e). That hash covers every installed package at its version, so two runners of one image version had different packages installed. It's the same failure as attempt 1's env-latex-hit, which passed on attempt 2. This PR doesn't touch setup-latex or setup-environment, and the organiser is recording the exact-hit tests' assumption as a harness follow-up.

Claude Code (on behalf of mmcky)

- The html check counts only "Error fetching" lines for myst's own
  content server (http://localhost:<port>), so a dead external link that
  --check-links reports no longer fails the build as a page not rendered.
- html-copy-pdf and html-copy-notebooks are refused on mystmd whatever
  their case, as the stage steps' if: compares without case.
- jb build's -v, -q, --verbose, --quiet, --freshenv and --individualpages
  are refused on mystmd too, with the fix named.
- The CHANGELOG's Changed entry covers a whitespace-only extra-args, and
  says an empty one gave no flags beyond -n.
- The chapter: source-dir is the folder that holds myst.yml, and
  build-path apart from where an export with its own output goes.

Harness: build-engine-inputs adds an external address that failed to
load, which passes, and html-copy-notebooks given as True, refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMaCAew38BRvFFUUn3G
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.

build-lectures: an engine input, jb1 or myst

1 participant