Skip to content

Commit 06c0119

Browse files
committed
Address review feedback
- Install requirements_docs.txt in the docs deploy workflow instead of an ad-hoc package list (Copilot) - Run zensical build --clean --strict in both docs workflows to match the validated command and fail fast on warnings (Copilot) - Scope contents: write permission to the deploy job with an explanatory comment instead of workflow-level (CodeRabbit) - Pin peaceiris/actions-gh-pages to the v4 commit SHA for supply-chain safety (CodeRabbit) - Continue past per-notebook conversion failures and exit non-zero at the end so one bad notebook doesn't hide the rest (CodeRabbit)
1 parent e23a8f8 commit 06c0119

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/docs-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
pip install -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt
3434
pip install .
3535
- run: python scripts/convert_notebooks.py
36-
- run: zensical build
36+
- run: zensical build --clean --strict
3737
- name: Deploy to Netlify
3838
uses: nwtgck/actions-netlify@v4.0
3939
with:

.github/workflows/docs.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ on:
33
push:
44
branches:
55
- main
6-
permissions:
7-
contents: write
86
jobs:
97
deploy:
108
runs-on: ubuntu-latest
9+
# Required to push the built site to the gh-pages branch.
10+
permissions:
11+
contents: write
1112
steps:
1213
- uses: actions/checkout@v7
1314
- uses: actions/setup-python@v6
@@ -17,13 +18,12 @@ jobs:
1718
run: |
1819
python -m pip install --upgrade pip
1920
pip install --user --no-cache-dir Cython
20-
pip install --user -r requirements.txt -r requirements_dev.txt
21+
pip install --user -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt
2122
pip install --user .
22-
- run: pip install zensical mkdocstrings-python nbconvert nbformat
2323
- run: python scripts/convert_notebooks.py
24-
- run: zensical build
24+
- run: zensical build --clean --strict
2525
- name: Deploy to GitHub Pages
26-
uses: peaceiris/actions-gh-pages@v4
26+
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4
2727
with:
2828
github_token: ${{ secrets.GITHUB_TOKEN }}
2929
publish_dir: ./site

scripts/convert_notebooks.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"""
1212

1313
import pathlib
14+
import sys
1415

1516
import nbformat
1617
from nbconvert import MarkdownExporter
@@ -46,11 +47,26 @@ def convert_notebook(nb_path: pathlib.Path) -> pathlib.Path:
4647

4748

4849
def main() -> None:
49-
"""Convert all notebooks in the configured docs directories."""
50+
"""Convert all notebooks in the configured docs directories.
51+
52+
Conversion continues past individual failures so that one broken
53+
notebook does not hide the status of the others; the script exits
54+
with a non-zero status if any notebook failed to convert.
55+
"""
56+
failures = []
5057
for dir_name in NOTEBOOK_DIRS:
5158
for nb_path in sorted((ROOT / dir_name).glob("*.ipynb")):
52-
md_path = convert_notebook(nb_path)
53-
print(f"Converted {nb_path.relative_to(ROOT)} -> {md_path.name}")
59+
try:
60+
md_path = convert_notebook(nb_path)
61+
except Exception as e:
62+
failures.append(nb_path)
63+
print(f"FAILED to convert {nb_path.relative_to(ROOT)}: {e}")
64+
else:
65+
print(f"Converted {nb_path.relative_to(ROOT)} -> {md_path.name}")
66+
67+
if failures:
68+
print(f"{len(failures)} notebook(s) failed to convert.")
69+
sys.exit(1)
5470

5571

5672
if __name__ == "__main__":

0 commit comments

Comments
 (0)