Skip to content

ci(book): build the book on pull requests, deploy only from main - #744

Merged
nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:fix/book-validated-on-prs
Aug 10, 2026
Merged

nihalpasham merged 3 commits into
NVIDIA:mainfrom
vyncint:fix/book-validated-on-prs

Conversation

@vyncint

@vyncint vyncint commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Closes #743.

Stacked on #733 — please review only the second commit (fix the book build on Sphinx warnings is that PR). The two are halves of the same thing: #733 makes
a warning fail the build, and this makes that build actually run before merge.

The gap

book.yml had no pull_request trigger, so the book was built only after
merge
. Every other content gate runs on PRs:

workflow pull_request?
ci.yml, docs.yml, examples-compile.yml, codeql.yml, naming-guard.yml, status-guard.yml yes
book.yml no

A PR that broke a cross-reference reached main unchallenged, and the first
signal was a failure on the branch everyone builds from. Combined with the
missing -W, the post-merge run would not have failed either.

Why this isn't just adding the trigger

book.yml is a deployment workflow — pages: write, id-token: write, and a
deploy job — which is presumably why it was push-only. A naive trigger would
attempt a Pages deploy from every pull request.

So deploy is gated on github.event_name != 'pull_request'. A PR builds the
book and stops; it never touches the Pages environment, and those write
permissions go unused on that path.

The workflow-level concurrency: group: pages needed the same care. It exists to
serialise deploys; left workflow-wide it would queue unrelated PR builds behind
each other. It moves onto the deploy job where the constraint belongs, and the
workflow-level group becomes ref-scoped with cancel-in-progress only for pull
requests — so superseded PR runs are cancelled, while a publish in flight on
main is never interrupted.

Verified

Parsed the workflow and checked the resulting shape rather than eyeballing it:

triggers: ['pull_request', 'push', 'workflow_dispatch']
workflow concurrency: group=${{ github.workflow }}-${{ github.ref }}
                      cancel-in-progress=${{ github.event_name == 'pull_request' }}
job build:  if=None                                    <- runs on PRs
job deploy: if="github.event_name != 'pull_request'"   <- never on PRs
            concurrency={'group': 'pages', 'cancel-in-progress': False}

No GPU needed.

vyncint and others added 3 commits August 8, 2026 21:17
The book was the only documentation surface without warnings-as-errors. The Rust
docs gate builds under RUSTDOCFLAGS="-D warnings" and says why -- to keep broken
intra-doc links from accumulating silently -- while sphinx-build ran bare, so a
broken cross-reference, a malformed directive, or a page dropped from a toctree
exited 0 and published.

Appending one dangling link to index.md shows the gap:

    $ sphinx-build -b html cuda-oxide-book _build          # before
    build succeeded.                                        # exit 0, publishes

    $ sphinx-build -W --keep-going -b html cuda-oxide-book _build
    WARNING: 'myst' cross-reference target not found: 'does-not-exist.md'
                                                            # exit 1

`--keep-going` reports every warning in one run rather than stopping at the
first, which matters when a rename breaks several references at once.

The book is already clean, so this costs nothing now: with the pinned
requirements the flagged build exits 0 on main with zero warnings. The Makefile
gets the same default so `make html` catches locally what CI would catch, and it
stays overridable for a draft build with `SPHINXOPTS= make html`.

Note requirements.txt uses `>=`, so CI floats to the newest Sphinx and a release
that adds a deprecation warning would fail this. Pinning the Sphinx major would
remove that exposure if it is unwanted.

Closes NVIDIA#732

Signed-off-by: Vyncint Ng <[email protected]>
book.yml had no `pull_request` trigger, so the book was built only after merge.
Every other content gate -- ci, docs, examples-compile, codeql, naming-guard,
status-guard -- runs on PRs. A pull request that broke a cross-reference, a
directive or a toctree entry therefore reached main unchallenged, and the first
signal was a failure on the branch everyone builds from.

Adding the trigger is not sufficient on its own. This is a deployment workflow:
it holds `pages: write` / `id-token: write` and a deploy job, which is presumably
why it was push-only, and a naive trigger would attempt a Pages deploy from every
pull request. So `deploy` is gated on `github.event_name != 'pull_request'`: a PR
builds the book to prove it is sound and stops there, never touching the Pages
environment.

The workflow-level `concurrency: group: pages` needed the same care. It exists to
serialise deploys, and leaving it workflow-wide would queue unrelated PR builds
behind each other. It moves onto the deploy job, where the constraint actually
applies, and the workflow-level group becomes ref-scoped. Superseded PR runs are
cancelled; pushes to main are not, so a publish in flight is never interrupted.

Stacked on NVIDIA#733: with `-W` in place a PR build now fails on a warning instead of
publishing one, which is the half that makes this trigger worth having.

Closes NVIDIA#743

Signed-off-by: Vyncint Ng <[email protected]>
… major

Pull requests now run the build job, so the workflow-level token they
receive should hold checkout rights only; `pages: write` and
`id-token: write` move onto the deploy job, the only place they are
used. With `-W` gating every PR, an unbounded `sphinx>=7.0` float lets
a new Sphinx major redden every PR and the main-branch deploy
overnight; bound it below 10 so majors are adopted deliberately.
@nihalpasham nihalpasham added enhancement New feature or request documentation Improvements or additions to documentation build-related Build scripts, toolchain discovery, or compilation setup labels Aug 10, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

The trigger, deploy gating, and concurrency logic all checked out line by line, and the -W build passes with today's Sphinx (9.1.0).

I pushed a follow-up moving pages:

  • write / id-token: write onto the deploy job so PR runs hold a read-only token, and bounding sphinx below the next major, the pin you offered, since -W now gates every PR.

This closes #743 and #732 together; #733 (whose commit this carries) will be closed as already-fixed.

@nihalpasham
nihalpasham merged commit 8e98dfd into NVIDIA:main Aug 10, 2026
38 checks passed
nihalpasham pushed a commit that referenced this pull request Aug 12, 2026
Every job in every other workflow carries `timeout-minutes`; `book.yml`'s
two were the only unbounded ones in the repo. An unbounded job that hangs
-- a wedged `pip install`, a `sphinx-build` that never returns, a Pages
deployment waiting on an API that never answers -- runs to GitHub's 6-hour
default instead of failing, holding a runner and telling nobody.

`build` is 15 minutes: a pip install and one sphinx-build, which settles in
about two today, so the bound is generous enough not to trip on a slow
runner. `deploy` is 10, since it is one `deploy-pages` action waiting on
the Pages API.

The `build` job is the one I added in #744 and I left the bound off it,
so this is mine to tidy. `deploy` predates that.

Verified: with these two, no job in any workflow lacks a bound
(`uses:` calls excepted, where the timeout belongs to the callee), and
book.yml still parses as YAML.

Signed-off-by: Vyncint Ng <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build-related Build scripts, toolchain discovery, or compilation setup documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The book is never built on a pull request, so a PR that breaks it cannot be caught before merge

2 participants