Repository navigation
site-build: build the PDF of a site that publishes one, and serve it at _pdf/ - #106
Conversation
…at _pdf/ Part of the rest of QuantEcon/project-monorepo#77. A site whose site.yml publishes pdf (intro, advanced, programming, intermediate and jax) gets its PDF as the series build theirs: the pdflatex builder, strict (-n -W), from the execution cache the HTML build filled, so it executes nothing. The PDF is copied into _build/html/_pdf/, which is made before the HTML build, as _notebooks/ is, so quantecon-book-theme shows each page's "Book (PDF)" link; the copy step then checks that every /_pdf/ link the pages carry names a file it copied. LaTeX comes with the full image (QuantEcon/actions' quantecon container) and with the GPU machine image, whose series build their PDFs on it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
From the organiser's review of #105: the line now leads with 3431f12, the pin in sync/state.yml, read 2026-11-27, and keeps the first read (7d8050c, 2026-11-17) after it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
The first run's jax leg failed its strict PDF on "Unable to run the image conversion command 'convert'": sphinx.ext.imgconverter, which Jupyter Book's PDF build turns on, converts the remote SVG logo that MyST's html_image makes an image of on three of jax's pages (inventory_dynamics_jax, kesten_processes_jax and jax's troubleshooting page). lecture-jax's own workflows install ImageMagick for this; neither the full image nor the GPU machine image has it. Every leg that builds a PDF now installs it (as root in a container, with sudo on the GPU machine), unless `convert` is there already. The other four PDF sites built theirs without it, intro's and advanced's strict included. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
|
Validation at The first run, at The build
Each PDF step read the cache the HTML build filled, and no notebook executed in the leg. The copy step found one PDF per site, and every Against each series' own PDF The baseline is each series' live PDF, from its last publish run: intro
No section is missing from either side or extra in one, and every word change falls into one of these classes:
Not compared: the figures, which are images in the PDF and were compared through the HTML for each site in its own PR. Each PDF is in its leg's |
- The copy step's "no page links to a PDF" error can print: under
pipefail a grep that found nothing failed the assignment before the
check, so the step failed with no reason given.
- On main the execution cache is saved when the HTML build succeeded,
whatever a later step did. It is the HTML build's alone, so a failed
notebooks or PDF build (a LaTeX error, an apt mirror down while
ImageMagick installs) no longer throws a cold build's execution away.
The header's step 11 says so.
- apt-get update waits for the dpkg lock too (DPkg::Lock::Timeout=600).
- The notebooks and PDF builds reuse the HTML build's Sphinx environment
("0 added, 0 changed, 0 removed"): the comments, README.md and
sites/README.md say that, not "from the cache the HTML build filled".
- The copy step's comment notes that the theme's link is from the domain's
root, right for the five PDF sites; a PDF site served under a path would
pass the check and 404.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
…#106 (#108) ## Why The reviews of #102 (`tools/stage-site --local-links`) and #106 (the PDF) left points to take after their merges. This PR takes them. None changes what any site builds or publishes today. ## tools/stage-site (from the reviews of #102) - **A left-over original that changes nothing.** An earlier `--clean` that kept an edited lecture leaves its original under `_build/stage-site-originals/`, and staging refused while it was there. It now refuses only when the original differs from the pool's lecture as it is now. Once the lecture has been put back by hand, replacing the original loses nothing. - **The originals folder.** Staging refuses when `_build/stage-site-originals` is a link or a file. It also refuses when a lecture's place in that folder holds a link, dangling ones included. A dangling link is not `.exists()`, so copying the original would have written through it. The confinement `--clean` uses refuses a folder that is itself a link, whose target it would otherwise confine to. - **The paragraph reading is main's.** This PR first changed how `tools/stage-site` reads paragraphs, so that inline literals are found as CommonMark finds them. After four review rounds, that hand-written reading still disagreed with markdown-it on 9 of 62 cases, against 21 for main's. The maintainer chose to split it out (Matt, 2026-11-27, in the project-monorepo session: "Split; markdown-it next (Recommended)"). So `prose_mask` is main's again, and a separate PR will read paragraphs and code spans with markdown-it and MyST's plugins, exact by construction. ## site-build.yml (from the review of #106) - **The cache save** runs on `always()` with the outcome of the HTML build and of its execution report. A job that times out or is cancelled in a later step, the PDF build say, still keeps a cold build's execution. The header's cache paragraph and `sites/README.md` no longer say "after a green build". - **The PDF copy step's grep:** finding nothing (exit 1) is reported by the check after it. A real error (exit 2, such as an unreadable folder) now fails the step with grep's own message. `|| true` had let that pass green. - `sites/README.md`'s `publishes` row no longer says "the same way" twice, and a comment left short by rewrapping is rewrapped. ## Checked - **On the pool** (at `aa281d3`): the reading is main's, so every pool lecture reads as on main (0 lines differ), and dp's `--local-links` plan is the same 31 links in 13 lectures, byte for byte. - **Tests:** 361 passed and 1 skipped (at `5498ef2`). Each fix has a test that fails without it: the left-over original that matches (put back and staged again), a dangling link where an original goes, a folder there, and an originals folder that is a link or a file, at staging and at `--clean`. - **The copy step**, its script taken from the workflow and run under `bash --noprofile --norc -eo pipefail` on local cases: - a good build passes; - a wrong name fails with its message; - no link fails with its message; - an unreadable folder fails with grep's "Permission denied" (with `|| true` it passed). - actionlint is clean; pool-check is clean. This PR's site build runs all six sites, since it touches `tools/stage-site`. Every leg restores main's cache. Copilot: not requested (Matt, 2026-11-22). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
## Why The last open part of QuantEcon/project-monorepo#77. Its acceptance criteria: - "A pull request that touches one shared lecture rebuilds every product that lists it and no other"; - "A planted broken lecture fails every product that holds it and no other product's build". Today every pull request and push to `main` that touches a build input builds all six sites. A fix to one intro lecture also rebuilds intermediate, programming and jax on the GPU machines. For pushes to `main` the owner chose the same narrowing on 2026-11-27, in the project-monorepo session: "Affected only (Recommended)". The schedule and a manual run still build every site. ## What it adds - **`tools/affected-sites`** reads the changed paths and prints the sites, of those named, that they reach: - a lecture, or its own `_static/<slug>/` files: the sites whose `_toc.yml` lists it, at any depth of parts, chapters and sections; - a `_static/_shared/` asset: the sites of the lectures the ledger records as using it, or every site when it records none; - a `_static/<dir>/` that is no pool lecture's folder: every site; - a site's own file: that site (`sites/README.md` reaches none); - `tools/sync` and `sync/state.yml`: the sites in the `series` environment, here or at the base, since only those run `tools/sync` (today dp). `sync.yml`'s near-daily pin refresh starts no run, but the next push takes it in, and it builds dp alone; - any other build input: every site. That covers the bibliography, any other pool file, a build tool, `_base/`, `sync/manifest.yml` (which `tools/stage-site` reads for every site) and the workflow. These are the workflow's path filter outside the pool and the sites, and a test keeps the two lists in step; - anything else (documentation, the tests, another workflow, the other sync records): none. With `--base`, the contents lists and the ledger are read at the base too. So a lecture a change drops still builds the sites that listed it, and a shared asset its old users' sites. Paths come NUL-separated with `-z`. The tool refuses a `--base` that is no commit, and a contents list or ledger it can't parse, with exit 2. Links between sites don't widen the set: intersphinx resolves them against the other site's published inventory, not this build. - **`site-build.yml`**'s first job chooses the sites: - **A pull request** is compared with its base. - **A push** is compared with the head of the last build on `main` that succeeded, not the commit before it. That build may be a push, scheduled or manual one, but never a pull request's. A run cancelled while it waits (the concurrency group keeps one waiting), cancelled by hand, or failed then leaves nothing unbuilt: the next push takes its change in. A step of its own reads that run through the API, with `actions: read`. It runs only on a push, and is the only step that holds the token. - **While a site stays red on `main`,** no build succeeds, so each push builds all that has changed since the last green build. The header says to mend a red site first. It also says to re-run an older push build's failed jobs, not all its jobs. - **The schedule and a manual run** take every site, and so does a base that can't be found or fetched. - The diff is `git diff --no-renames --name-only -z`. A renamed or moved file counts by its old path as well as its new one, and a name git would quote keeps its bytes. Only the base commit is fetched: a diff of two trees needs no history. - **A change to the rule itself** (the tool or this workflow) builds every site without asking the tool, so a broken tool can't skip its own build. - The job writes "Sites built: … " and the reason to the run summary. When a change reaches no site, the build job is skipped, since GitHub refuses an empty matrix. - **The header:** who builds what, and how a push is compared. "What it does not do" now puts mystmd and the shared cache in the second phase, after the cutovers, which takes in the note deferred from #110. - **Docs:** README's build paragraph and tools table, and `sites/README.md`'s "Building a site in CI". ## Checked - **Tests:** 501 passed and 1 skipped. They cover: - every rule (24 cases), including a section nested in a part and the series inputs; - a site moved out of the series environment, read at the base, and a site with no `site.yml`; - over a real git history: a dropped lecture, the ledger read at the base, a renamed lecture, an asset moved between two lectures' folders, and a name git would quote; - a key with no site, a base that is no commit, and a contents list that can't be parsed; - the workflow, read for its path filter (both events), its diff flags, the rule check, the push base's query step, and that only that step holds the token. Six of the new tests fail on the first version of the tool, and dropping the ledger's base reading fails one. actionlint and pool-check are clean. - **On the real pool,** with the workflow's own diff command: - `git mv lectures/os_stochastic.md lectures/os_stochastic_v2.md` builds dp and intermediate; - moving an `about_py` figure into `os_stochastic`'s folder builds dp, programming and intermediate; - a new `_static/lecture_specific/…` builds all six; - `about_py/café.png` builds programming; - the pin refresh `fc2ea1f` builds dp alone. - **On tonight's merges** (each squash commit against its parent): | Merge | Sites it would build | |---|---| | the refresh #107 (two intro lectures) | intro alone, instead of all six | | #101 (pool-check, its tests, `sites/README.md`) | none; it built all six | | #110 (the README) | none | | #106 (`site-build.yml`) | all six | | #109 (`tools/stage-site`) | all six | - **Real runs, each from a throwaway draft against this branch, now closed:** - #112 planted a failing cell in a lecture that dp and intermediate list. Only those two legs ran, and both failed in the strict build on the planted error. - #113 changed only `sites/README.md`. The matrix job reported no site, and the build job was skipped. The evidence comments below have the details. - **This PR's own build** changes the workflow, so it builds all six: the "rule itself" path. - **The push path** can't run before the merge. Its query, run now against this repository, returns 31f29fc (#101), the last build on `main` that succeeded. The first push after the merge carries this workflow, so it builds all six. The "Sites built" summaries of the first two push builds on `main` are to be read after the merge. The first should say it touches the rule, against 31f29fc. The second should be compared with the merge commit, if the first went green. The validation rule: this changes which sites build, not how. The legs that run are unchanged steps, so a full output comparison isn't needed. The planted test is the evidence. Copilot: not requested (Matt, 2026-11-22). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
Why
The rest of QuantEcon/project-monorepo#77 starts with the PDF. Five of the six sites publish one (
publishes: [html, pdf, notebooks]insite.yml: intro, advanced, programming, intermediate and jax; dp publishes none). Their series build it and serve it at_pdf/, where the theme's "Book (PDF)" link points. Until now the site build made the HTML and the notebooks only.What it adds
site.ymlpublishespdf, a step after the notebooks runsbuild-lectureswith thepdflatexbuilder and-W --keep-going.build-lecturesadds-n, so the build matches the HTML's-n -W. It reads the cache the HTML build filled, so it executes nothing. A failed build uploads its reports asexecution-reports-<key>-pdf. LaTeX comes with the full image and with the GPU machine image, which the GPU series' own PDF builds use._pdf/. quantecon-book-theme shows the "Book (PDF)" link only when_build/html/_pdf/is a folder as it renders the pages. The series build the PDF first and copy it in. Here, as for the notebooks, the folder is made before the HTML build, so the HTML build stays the one that executes the pages. The PDF is then copied in, as the series copy theirs (cp _build/latex/*.pdf _build/html/_pdf/).38c4d3a). Jupyter Book's PDF build turns onsphinx.ext.imgconverter, which needsconvertfor an image LaTeX can't take, an SVG or a GIF. Three jax pages have a remote SVG logo that MyST'shtml_imagemakes an image of, so jax's strict PDF failed without it in the first run. Every leg that builds a PDF now installs ImageMagick, as lecture-jax's workflows do, unlessconvertis already there: as root in a container, and withsudoon the GPU machine. It takes 6 to 22 seconds./_pdf/(the theme didn't see the folder), or when a page links to a PDF the build didn't make. The theme names the link afterlatex_documents'targetname. The HTML artefact then carries the PDF with the pages.README.md's build paragraph, andsites/README.md'spublishesrow and strictness note.sites/jax/site.yml's Sources line now leads with the pin it was last read at (3431f12, 2026-11-27).Checked
38c4d3a, green on every leg). Each PDF step read the cache and executed nothing. The steps took 71 s for jax, 102 s intro, 110 s programming, 182 s advanced and 631 s intermediate. intro's and advanced's PDFs build strict (-n -W), although their series build theirs with-nalone. Every content page links to the one PDF its site made; the only pages without the link areindex.html,index_toc.htmland the redirect pages.Not compared: the figures, which are images in the PDF and were validated through the HTML in each site's own PR.
Copilot: not requested (Matt, 2026-11-22).
🤖 Generated with Claude Code
https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG