Skip to content

[Experimental] Use jupyter-book 2.0 for building the lectures #1529

[Experimental] Use jupyter-book 2.0 for building the lectures

[Experimental] Use jupyter-book 2.0 for building the lectures #1529

Workflow file for this run

name: Build Project [using QuantEcon/mystmd]
on: [pull_request]
jobs:
preview:
runs-on: "runs-on=${{ github.run_id }}/family=g4dn.2xlarge/image=quantecon_ubuntu2404/volume=80gb/spot=false"
steps:
- uses: actions/checkout@v7
- name: Cache Notebook Execution
uses: actions/cache@v6
id: cache-execution
with:
path: ./lectures/_build/execute
key: ${{ runner.os }}-execute-cache-${{ hashFiles('lectures/**/*.md') }}
# Node 24 matches the theme's .nvmrc (quantecon-theme.mystmd), which runs
# as a Remix server during `myst build --html`.
- uses: actions/setup-node@v7
with:
node-version: '24'
- uses: oven-sh/setup-bun@v2
- name: Install Python
if: steps.cache-execution.outputs.cache-hit != 'true'
uses: actions/setup-python@v7
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'myst_requirements.txt'
- name: Install execution requirements
if: steps.cache-execution.outputs.cache-hit != 'true'
run: python -m pip install -r myst_requirements.txt
# The GPU lectures (jax_intro, autodiff, numpy_vs_numba_vs_jax) need JAX
# on the g4dn runner — same install as the jupyter-book 1.x workflow on
# main. Without it those notebooks execute to ModuleNotFoundError cells.
- name: Install JAX
if: steps.cache-execution.outputs.cache-hit != 'true'
run: |
pip install -U "jax[cuda13]"
python scripts/test-jax-install.py
- name: Install mystmd (QuantEcon fork)
run: |
git clone --branch main --depth 1 \
https://github.com/QuantEcon/mystmd.git /tmp/qe-mystmd
cd /tmp/qe-mystmd
bun install
bun run build
npm install -g /tmp/qe-mystmd/packages/mystmd
- name: Log QuantEcon/mystmd build identifier
run: cat /tmp/qe-mystmd/quantecon/VERSION.yml
- name: Verify mystmd version
run: myst --version
# Built with the fork's `myst` CLI rather than `jupyter book build`.
# jupyter-book 2.x is a Python shim that execs a mystmd bundle vendored
# inside its own wheel (jupyter_book/dist/jupyter-book.cjs) and offers no
# way to point it at another CLI — so `jupyter book build` silently
# ignored the fork we install above and built with upstream mystmd.
- name: Build HTML
working-directory: ./lectures
run: myst build --html --execute
- name: Upload build output
uses: actions/upload-artifact@v7
with:
path: './lectures/_build/html'
- name: Preview Deploy to Netlify
uses: nwtgck/actions-netlify@v4
with:
publish-dir: './lectures/_build/html'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Preview Deploy from GitHub Actions"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}