Skip to content

chore(ci): delegate notebook execution and caching to shared mkdocs-deploy composite action #185

Description

@MAfarrag

Context

Each docs CI job in .github/workflows/github-pages-mkdocs.yml previously carried a 4-step
preamble (setup-python → restore .jupyter_cachepip install jupyter nbconvert ipykernel
→ run scripts/prep_notebooks.py) before handing off to the shared mkdocs-deploy composite
action. That logic is now available directly inside the composite via a notebooks-path
input, so every serapeum-org repo using the composite gets the same cache semantics
without maintaining a local copy.

Tracks the work in PR #184 on branch ci/move-notebook-ci-to-github-actions.

Problem / Current Behaviour

  • Three jobs (deploy-pr, deploy-main, deploy-release) each duplicate ~15 lines of
    notebook-prep setup in the workflow file.
  • scripts/prep_notebooks.py (90 lines) is a repo-local re-implementation of the
    cache-aware notebook prep logic that now lives in the shared composite action.
  • Drift risk: any future improvement to the prep logic (e.g. cache-key strategy, exec
    timeouts) must be applied in every repo.

Affected locations

File Symbol Notes
.github/workflows/github-pages-mkdocs.yml deploy-pr, deploy-main, deploy-release Remove setup-python / cache / prep steps; pass notebooks-path to composite.
scripts/prep_notebooks.py module Delete; responsibility moves to composite action.
mkdocs.yml mkdocs-jupyter plugin block Remove now-stale comment referencing prep_notebooks.py.
pyproject.toml [project.optional-dependencies].docs Add nbconvert, ipykernel so local mkdocs serve still renders outputs.
uv.lock Refresh lockfile with the two new docs deps.

Motivation Example

Before (per job, ~15 lines):

- uses: actions/setup-python@v5
  with:
    python-version: '3.12'

- name: Restore jupyter notebook cache
  uses: actions/cache@v4
  with:
    path: .jupyter_cache
    key: jupyter-cache-${{ hashFiles('docs/notebook/**/*.ipynb', 'src/statista/**/*.py', 'pyproject.toml') }}
    restore-keys: |
      jupyter-cache-

- name: Prepare notebook outputs (execute uncached, merge cached)
  run: |
    pip install -e . jupyter nbconvert ipykernel
    python scripts/prep_notebooks.py

- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
  with:
    trigger: 'pull_request'
    ...

After (per job):

- uses: serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
  with:
    trigger: 'pull_request'
    notebooks-path: 'docs/notebook'
    ...

Proposed Solution

  1. In .github/workflows/github-pages-mkdocs.yml, drop the setup-python, actions/cache,
    and prep_notebooks.py steps from all three jobs.
  2. Add notebooks-path: 'docs/notebook' to the serapeum-org/github-actions/actions/mkdocs-deploy@mkdocs/v1
    invocation in each job.
  3. Delete scripts/prep_notebooks.py.
  4. Remove the now-stale mkdocs-jupyter plugin comment referencing the deleted script in
    mkdocs.yml.
  5. Add nbconvert and ipykernel to [project.optional-dependencies].docs in
    pyproject.toml so uv run --active mkdocs serve continues to render notebook outputs
    locally.
  6. Refresh uv.lock with uv lock.

Out of Scope

  • Upstream changes to serapeum-org/github-actions/actions/mkdocs-deploy itself — those
    live in the composite action repo.
  • Any documentation-content changes.
  • Migrating other serapeum-org repos to the same pattern.

Effort Estimate

Size: S
Rationale: Half-day task, mostly deletion; implementation already sits in PR #184.

Definition of Done

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions