Skip to content

CI: gate the first jb build so notebook errors cannot pass green - #588

Merged
mmcky merged 1 commit into
mainfrom
ci/gate-first-jb-build
Jul 30, 2026
Merged

CI: gate the first jb build so notebook errors cannot pass green#588
mmcky merged 1 commit into
mainfrom
ci/gate-first-jb-build

Conversation

@mmcky

@mmcky mmcky commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Part of QuantEcon/meta#340.

The problem

The Build Download Notebooks (sphinx-tojupyter) step is the first jb build in this workflow, and lectures/_config.yml sets execute_notebooks: "cache" — so it is the only build that actually executes notebooks; the later HTML build reads the cache. That makes it the step where a CellExecutionError surfaces.

It could not fail.

The flags were already correct (-n -W --keep-going), but inert. The step runs three commands under shell: bash -l {0}, and GitHub only injects -eo pipefail for the bare shell: bash shorthand — an explicit custom shell spec gets neither -e nor -o pipefail. So a failing jb build was followed by mkdir and cp, and the step exited with cp's status. --keep-going makes this worse rather than better: it forces Sphinx to emit output despite the errors, guaranteeing the .ipynb files exist for cp to succeed on.

The change

One line — set -eo pipefail — plus a comment recording why it is needed and why this step is the one that matters. No flag changes, no _config.yml change.

Note on which step

The rule is "gate the first jb build", not "gate a particular step name". Where a repo's Build PDF from LaTeX step is active it runs first and is the one to gate (see QuantEcon/lecture-python-intro#809); here the LaTeX step comes later, so the notebooks step is first. The audit table in QuantEcon/meta#340 records which step applies per repo.

Verified before the change

This repo already uses raises-exception tags where cells are meant to error, so nothing is relying on an error being tolerated silently.

Refs QuantEcon/meta#340

🤖 Generated with Claude Code

The sphinx-tojupyter step is the first `jb build` in this workflow, and
`execute_notebooks: "cache"` means only the first build executes notebooks
— the later HTML build reads the cache. So this step is where a
CellExecutionError surfaces, and it could not fail.

It already carried `-n -W`, but that was inert: the step runs three
commands under `shell: bash -l {0}`, and GitHub only injects `-eo pipefail`
for the bare `shell: bash` shorthand. An explicit custom shell spec gets
neither `-e` nor `-o pipefail`, so a failing `jb build` was followed by
`mkdir` and `cp`, and the step exited with `cp`'s status. `--keep-going`
makes that worse rather than better, since it forces Sphinx to emit output
despite the errors, guaranteeing the .ipynb files exist for `cp`.

One line fixes it. The flags were already right.

Refs QuantEcon/meta#340

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 30, 2026 04:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a CI reliability gap in the Jupyter Book workflow by ensuring the first jb build (the one that executes notebooks due to execute_notebooks: "cache") properly fails the job when notebook execution errors occur, instead of being masked by subsequent commands in the same step.

Changes:

  • Add set -eo pipefail to the first notebook-building step so jb build failures cannot be hidden by later mkdir/cp commands.
  • Document why this is required specifically under shell: bash -l {0} and why the first build is the gating build.

Comment thread .github/workflows/ci.yml
Comment on lines +63 to +67
# `set -eo pipefail` is required as well as `-W`: `shell: bash -l {0}` is a
# custom shell spec, so GitHub does not inject `-eo pipefail` (it only does
# that for the bare `shell: bash` shorthand). Without it a failing `jb build`
# would be masked by the trailing mkdir/cp, whose exit code becomes the
# step's — and `--keep-going` guarantees the .ipynb files exist for `cp`
@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 30, 2026 04:57 Inactive
@mmcky
mmcky merged commit 11122d7 into main Jul 30, 2026
6 checks passed
@mmcky
mmcky deleted the ci/gate-first-jb-build branch July 30, 2026 05:40
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.

2 participants