Skip to content

site-build: build only the sites a change reaches - #111

Merged
mmcky merged 3 commits into
mainfrom
site-build/affected-sites
Nov 28, 2026
Merged

mmcky merged 3 commits into
mainfrom
site-build/affected-sites

Conversation

@mmcky

@mmcky mmcky commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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 README: Jupyter Book 1 for every cutover; mystmd a second phase after them #110.

  • Docs: README's build paragraph and tools table, and sites/README.md's "Building a site in CI".

Checked

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.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG

The last open part of QuantEcon/project-monorepo#77: "A pull request that
touches one shared lecture rebuilds every product that lists it and no
other." The owner, 2026-11-27, chose the same for pushes to main
("Affected only (Recommended)"); the schedule and a manual run still build
every site.

- tools/affected-sites reads the changed paths and prints the sites they
  reach. A lecture, or its own _static/<slug>/ files, reaches the sites
  whose _toc.yml lists it, and a _static/_shared/ asset the sites of the
  lectures the ledger records as using it. A site's own file reaches that
  site. Any other build input (the bibliography, another pool file, a
  build tool, _base/, the sync records, the workflow) reaches every site;
  anything else none. With --base, a lecture a change drops still reaches
  the sites that listed it.
- site-build.yml's first job compares a pull request with its base and a
  push with the commit before it (the base fetched alone), writes the
  sites and why to the run summary, and skips the build job when none is
  reached. tools/affected-sites joins the path filter. The header says
  so, and puts mystmd and the shared cache in the second phase.
- Tests: every rule, a dropped lecture with --base, a key with no site,
  and the tool's build inputs against the workflow's path filter.
  485 passed.
- On tonight's merges: the refresh #107 would have
  built intro alone, not all six; #101 and #110 none;
  #106 and #109 all six.

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

mmcky commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Validation at 8accedc

#77's criterion, run for real. A throwaway draft, #112, was opened against this branch (not main) and is now closed. It planted a failing code cell in lectures/os_stochastic.md, which dp and intermediate list. Its run, 46070997274 at 2e734b5 (a pull_request event):

  • The matrix job chose the sites from the change and wrote "dp intermediate: the sites the change reaches, from 1 changed path(s) against 8accedc".
  • Only dp and intermediate were built, and both failed in their strict HTML build (Build the site's HTML (strict)). These were the real build steps: the changed page missed the cache, executed, and failed with CellExecutionError on the planted ValueError. A traceback is in each leg's log.
  • Intro, advanced, programming and jax were not built.

This PR's own build, 46070955297, is green on all six legs. The PR changes site-build.yml and tools/affected-sites, both build inputs, so it took the "every site" path.

The rest, as the body says: 485 tests pass, including every rule, a dropped lecture read with --base, and the build inputs against the workflow's path filter. Tonight's merges, run through the tool, give intro alone for the refresh #107, none for #101 and #110, and all six for #106 and #109.

@mmcky
mmcky marked this pull request as ready for review November 27, 2026 21:54
From the fresh review of 8accedc:

- Renames: the diff runs with --no-renames, so a renamed or moved file
  counts by its old path as well as its new one. git's rename detection
  printed only the new name, and a renamed lecture built no site.
- A push is compared with the head of the last push build on main that
  succeeded (actions: read on the first job), not the commit before it.
  A run cancelled while it waits or by hand, or one that failed, no longer
  leaves its change unbuilt: the next push takes it in.
- A change to the rule itself (the tool or the workflow) builds every site
  without asking the tool, so a broken tool cannot skip its own build.
- Paths travel NUL-separated (-z), so a name git would quote still reaches
  its site. A base that cannot be fetched builds every site; the tool
  refuses a --base that is no commit, and a contents list or ledger it
  cannot parse, with exit 2.
- A _static/<dir>/ that is no pool lecture's folder reaches every site.
- Tests: nesting in a contents list, the ledger at the base, a rename, an
  asset moved between lectures' folders, a quoted name, the unreadable
  base and the unparsable list, and the workflow's diff flags, rule check
  and push base. 496 passed.
- The stale header lines go, and the docs say how a push is compared and
  which sync records reach a build.

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

mmcky commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Validation at 3ec6097, the fixes from the fresh review of 8accedc

The fixes, as the updated description has them:

  • git diff --no-renames --name-only -z;
  • a push compared with the head of the last push build on main that succeeded;
  • every site for a change to the tool or the workflow, and for a base that can't be fetched;
  • the tool refuses a bad --base or an unparsable list with exit 2;
  • a _static/<dir>/ that is no lecture's folder reaches every site;
  • the stale header lines are gone.

This PR's own build, 46075226621, is green on all six legs. Its matrix job wrote "every site: the change, 6 path(s) against 9efe41b, touches the rule itself": the new check, taking every site without asking the tool.

The empty set, run for real. A throwaway draft, #113, was opened against this branch and is now closed. It changed only sites/README.md. Its run, 46075234082 at a8f1cb2 (a pull_request event), shows:

  • the base 3ec6097 fetched alone;
  • "none: the sites the change reaches, from 1 changed path(s) against 3ec6097", and "No site is affected, so none is built.";
  • the build job skipped and the run concluded success.

GitHub lists the skipped job by its unexpanded name, ${{ matrix.site.key }}, since no matrix was made. That's cosmetic.

The review's scenarios, on the real pool, with the workflow's own diff command:

  • A rename: git mv lectures/os_stochastic.md lectures/os_stochastic_v2.md builds dp and intermediate (before: none).
  • A moved asset: an about_py figure moved into os_stochastic's folder builds dp, programming and intermediate (before: dp and intermediate).
  • A new _static/lecture_specific/…: builds all six (before: none).
  • A quoted name: about_py/café.png builds programming (before: none). git's default output quotes that name as "lectures/_static/about_py/caf\303\251.png".
  • A --base that is no commit: exits 2.

Tests: 496 passed and 1 skipped. Six of the new tests fail on 8accedc's tool, and dropping the ledger's base reading fails the new ledger test.

The push path can't run before the merge. Its query, run against this repository now, returns 31f29fc (#101), the last push build on main that succeeded. The first push after the merge carries this workflow, so it builds all six.

…iew's nits

From the review of 3ec6097:

- tools/sync and sync/state.yml reach only the sites in the series
  environment (site.yml's default), read here or at the base: only those
  run tools/sync, which alone reads the pins. sync.yml's near-daily pin
  refresh, which starts no run itself, now builds dp alone on the next
  push to main, not all six; sync/manifest.yml, which stage-site reads
  for every site, still reaches every site.
- The last build on main that succeeded is found in its own step, run only
  on a push and alone holding the token, and may be a push, scheduled or
  manual build (each a sound base); a pull request's run never is.
- The header says to mend a red site first, since it holds the base back,
  and to re-run an older push build's failed jobs, not all its jobs.
- Tests: the series rule, a site moved out of the series environment, a
  site with no site.yml, the two input lists against the path filter, the
  query step and that only it holds the token. 501 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WT8bMZxoF4m8xKRb8BcHnG
@mmcky
mmcky merged commit 5601d4c into main Nov 28, 2026
12 checks passed
@mmcky
mmcky deleted the site-build/affected-sites branch November 28, 2026 00:34
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.

1 participant