fix(ci): make the Mermaid fail-closed guard actually fire

The guard added earlier could never trigger. tools/render_mermaid.py has no
nonzero exit path — its own docstring said "Exits 0 even if some/all fail
(non-fatal)" — so `if ! render_mermaid.py ...; then exit 1; fi` never ran its
body, and a build that rendered zero diagrams still passed. Reproduced by
running the script with no Chrome on PATH: it printed the fallback warning and
exited 0.

Adds a --strict flag that exits 1 when Chrome is missing or any diagram fails
to render, and passes it from every workflow invocation. The default stays
lenient so local mobile-reader builds keep working, which is what the exit-0
behaviour was actually for.

Verified both directions: with no Chrome, --strict exits 1 and the default
exits 0; against the real book with Chrome, --strict renders every diagram and
exits 0.
This commit is contained in:
yeasy
2026-07-23 07:40:28 -07:00
parent 1c8f0dc14d
commit d705dfb631
2 changed files with 13 additions and 3 deletions
+1 -1
View File
@@ -100,7 +100,7 @@ jobs:
run: |
title=$(python3 -c 'import json; print(json.load(open("book.json", encoding="utf-8"))["title"])')
PATH="$GITHUB_WORKSPACE/node_modules/.bin:$PATH" \
python3 tools/render_mermaid.py --book-dir . --svg-out "$RUNNER_TEMP/mmsvg"
python3 tools/render_mermaid.py --book-dir . --svg-out "$RUNNER_TEMP/mmsvg" --strict
python3 tools/build_html_reader.py \
--book-dir . \
--title "$title" \