Skip to content

ci(docs): add mermaid render lint to catch diagram syntax regressions - #233

Merged
yeongseon merged 1 commit into
mainfrom
ci/mermaid-render-lint-214
Jul 26, 2026
Merged

ci(docs): add mermaid render lint to catch diagram syntax regressions#233
yeongseon merged 1 commit into
mainfrom
ci/mermaid-render-lint-214

Conversation

@yeongseon

Copy link
Copy Markdown
Owner

Summary

  • Add scripts/render_mermaid.py: renders every mermaid block via mmdc and fails on invalid syntax (catches errors the text-only label linter cannot).
  • Add scripts/puppeteer-config.json: --no-sandbox config so Chromium runs in CI containers.
  • Add .github/workflows/mermaid-lint.yml: isolated workflow triggered only on PRs touching README*/docs/**, keeping the headless-Chromium dependency out of the main docs build.

Verification

  • Renders all 8 existing diagrams cleanly (READMEs ×4, DESIGN.md, docs/architecture.md ×3) → exit 0.
  • Fails with a parser error + file:line on a deliberately broken diagram → exit 1.

Closes #214

Add an isolated Mermaid render check (mmdc) that runs only on PRs touching
READMEs/docs. Unlike the text-only label linter, it renders every mermaid
block and fails fast on invalid syntax. Kept in its own workflow to isolate
the headless-Chromium dependency.

Closes #214

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

Adds an isolated GitHub Actions workflow to render-check Mermaid diagrams in Markdown, catching syntax regressions that text-only checks can miss, without introducing Chromium dependencies into the main docs build.

Changes:

  • Add scripts/render_mermaid.py to extract and render all fenced ```mermaid blocks via mmdc, failing CI on render errors.
  • Add scripts/puppeteer-config.json to run Chromium in CI containers (no-sandbox flags).
  • Add .github/workflows/mermaid-lint.yml to run the render lint on PRs that touch docs/READMEs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
scripts/render_mermaid.py Implements Mermaid extraction + mmdc render-lint for Markdown docs.
scripts/puppeteer-config.json Puppeteer args for Chromium execution in CI.
.github/workflows/mermaid-lint.yml New isolated workflow to run the Mermaid render-lint on relevant PRs.

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

Comment thread scripts/render_mermaid.py
Comment on lines +4 to +6
Unlike ``lint_mermaid.py`` (label-hygiene only), this script actually renders
every ```mermaid``` fenced block with the Mermaid CLI (``mmdc``). Invalid
syntax that a text linter cannot detect will fail the render, and therefore CI.
Comment thread scripts/render_mermaid.py
Comment on lines +37 to +38
# Puppeteer config so Chromium runs in sandboxed CI containers.
PUPPETEER_CONFIG = REPO_ROOT / "scripts" / "puppeteer-config.json"
Comment thread scripts/render_mermaid.py
Comment on lines +70 to +71
buffer.append(raw)
return blocks
Comment thread scripts/render_mermaid.py
Comment on lines +112 to +115
for path in targets:
for start_line, source in _extract_blocks(path):
if not source.strip():
continue
Comment thread scripts/render_mermaid.py
Comment on lines +88 to +92
cmd += ["--puppeteerConfigFile", str(PUPPETEER_CONFIG)]
proc = subprocess.run(cmd, capture_output=True, text=True)
if proc.returncode != 0:
detail = (proc.stderr or proc.stdout or "").strip()
return False, detail
Comment on lines +40 to +41
- name: Install mermaid-cli
run: npm install -g @mermaid-js/mermaid-cli
@yeongseon
yeongseon merged commit 50c1d92 into main Jul 26, 2026
14 checks passed
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.

ci(docs): add mermaid render lint to prevent diagram syntax regressions

3 participants