Skip to content

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

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#1019
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:50

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 where the first jb build (the only build that actually executes notebooks due to execute_notebooks: "cache") could fail but still allow the workflow step to exit successfully because subsequent mkdir/cp commands overwrite the step exit code under shell: bash -l {0}.

Changes:

  • Add set -eo pipefail to ensure the “Build Download Notebooks (sphinx-tojupyter)” step fails immediately if jb build fails.
  • Add an in-step comment explaining why this step is the gating point and why set -eo pipefail is necessary with a custom shell spec.

@github-actions

Copy link
Copy Markdown

📖 Netlify Preview Ready!

Preview URL: https://pr-1019--sunny-cactus-210e3e.netlify.app

Commit: e40cf61


Build Info

@mmcky
mmcky merged commit ff82ff8 into main Jul 30, 2026
2 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