Skip to content

CI: align build safety with lecture-python.zh-cn and the source repos - #270

Merged
mmcky merged 1 commit into
mainfrom
ci/align-build-safety
Jul 20, 2026
Merged

mmcky merged 1 commit into
mainfrom
ci/align-build-safety

Conversation

@mmcky

@mmcky mmcky commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Ports QuantEcon/lecture-python.zh-cn#185 to this edition, closing the QuantEcon/meta#340 gap here. This is the follow-up flagged in #269.

Why now

prob_dist was broken on main for two days (resync in #256 → fixed in #269) and this repo's CI never caught it. The sphinx-tojupyter step ran with no flags, so notebook execution errors did not fail it. The break surfaced only because #268 happened to trigger a build, and was independently confirmed by the scheduled cache run at 04:14 today, which failed on the same FileNotFoundError.

The weekly cron is real protection, but it is a week wide. This closes the gap to per-PR.

What changes

ci.yml

Step Before After
Clear stale Sphinx environment absent (commented note) added
Build Download Notebooks (sphinx-tojupyter) no flags set -eo pipefail + -n -W --keep-going
Upload Execution Reports (Download Notebooks) absent added, if: failure()
Build HTML -nW --keep-going unchanged

cache.yml-W --keep-going-n -W --keep-going, so the weekly cold build is strict on missing references as well as warnings. Without this, "green" means something weaker here than on lecture-python.zh-cn, which is a confusing property for two editions that are meant to be verified the same way.

Two non-obvious points

The flag alone would not have worked. shell: bash -l {0} is a custom shell spec, so GitHub injects no -eo pipefail — it only does that for the bare shell: bash shorthand. The step's trailing mkdir/cp become its exit code, and --keep-going guarantees the .ipynb files exist for cp to succeed on, so a failing build still reports green. This was caught by Copilot review on zh-cn#185 and is the reason set -eo pipefail is here. Verified: bash -l -c 'false; echo hi' exits 0.

The HTML artifact rename is required, not cosmetic. upload-artifact runs with overwrite: false, so adding a second upload under the existing execution-reports name would collide whenever both steps fail in the same run.

Deliberately unchanged

ci-cn.yml has no sphinx-tojupyter step, and its HTML build is a single command — so its exit code is already the build's and it fails correctly. That is precisely why it, and not ci.yml, caught the prob_dist break. Its execution-reports artifact name is also left alone: it is the only upload in that workflow, so there is nothing for it to collide with.

The PDF/LaTeX build in ci.yml stays commented out. CJK under LaTeX is hard (see #25), so this looks like a considered choice rather than an oversight and needs a human decision, not mechanical alignment.

Expected result

Unlike the equivalent PR next door, this one should go green: a cold build of main passed 20 minutes ago (run 29720229050) — the first cold verification of this edition since 2026-07-16, which predates the 41-PR resync wave. So the corpus is known-clean going in.

Verification

  • All three workflows parse; ci.yml 13 steps, cache.yml 7, ci-cn.yml 9.
  • Artifact names unique within each workflow.
  • set -eo pipefail behaviour confirmed empirically.

Related: QuantEcon/meta#340 — note the amendment recorded there, that the same masking is still live in lecture-python.myst and lecture-python-programming, the two repos that issue treats as already aligned.

🤖 Generated with Claude Code

Ports QuantEcon/lecture-python.zh-cn#185 to this edition, closing the
QuantEcon/meta#340 gap here.

ci.yml
- `-n -W --keep-going` on the sphinx-tojupyter build. It previously ran
  with no flags, so a notebook whose cells raised still exited zero.
- `set -eo pipefail` in that same block. The flag alone is insufficient:
  `shell: bash -l {0}` is a custom shell spec, so GitHub injects no
  `-eo pipefail`, and the trailing mkdir/cp become the step's exit code.
  `--keep-going` makes it worse, guaranteeing the .ipynb files exist for
  `cp` to succeed on. Found by Copilot review on zh-cn#185.
- Upload Execution Reports (Download Notebooks), so a failure in that
  step leaves a traceback artifact.
- Clear stale Sphinx environment before the builds.
- HTML artifact renamed execution-reports -> execution-reports-html.
  Required, not cosmetic: upload-artifact runs with `overwrite: false`,
  so a second upload under the same name would collide when both steps
  fail in one run.

cache.yml
- `-W --keep-going` -> `-n -W --keep-going`, so the weekly cold build is
  strict on missing references as well as warnings, matching
  lecture-python.zh-cn.

ci-cn.yml is deliberately unchanged: it has no sphinx-tojupyter step and
its HTML build is a single command, so its exit code is already the
build's. That is why it — and not ci.yml — caught the prob_dist break
in #269.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 20, 2026 06:17
@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for playful-platypus-17d3bb ready!

Name Link
🔨 Latest commit 3dd9e3a
🔍 Latest deploy log https://app.netlify.com/projects/playful-platypus-17d3bb/deploys/6a5dbd701426a1000aa5292d
😎 Deploy Preview https://deploy-preview-270--playful-platypus-17d3bb.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request tightens CI correctness for this edition by making the sphinx-tojupyter (download notebooks) build fail on execution/warning errors the same way the upstream/peer editions do, and by exposing execution reports when failures occur.

Changes:

  • Clear cached Sphinx doctrees before building, avoiding stale-environment artifacts affecting builds.
  • Make the notebook build strict and failure-propagating (set -eo pipefail + -n -W --keep-going) and upload its execution reports on failure.
  • Align the weekly cache workflow to also run with -n -W --keep-going so scheduled “green” is meaningfully strict.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.github/workflows/ci.yml Ensures notebook builds fail correctly under bash -l {0}, clears stale doctrees, and uploads distinct execution-report artifacts on failure.
.github/workflows/cache.yml Makes the scheduled cache build strict on missing refs (-n) in addition to warnings (-W).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 20, 2026 06:22 Inactive
@mmcky
mmcky merged commit 2bf870c into main Jul 20, 2026
9 checks passed
@mmcky
mmcky deleted the ci/align-build-safety branch July 20, 2026 08:39
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