From bee1d3e17053dab2094cb2cf80246f9a613b28ad Mon Sep 17 00:00:00 2001 From: Lucas Gomide Date: Fri, 24 Jul 2026 17:54:38 -0300 Subject: [PATCH] ci: check doc links only on edge and latest versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `mintlify broken-links` walks every frozen version snapshot under `docs/` (currently 22 of them), pushing docs PR checks past 14 minutes and growing with each release. Prune the immutable snapshots — keeping `edge` and the default (latest) version, which unprefixed links resolve against — before running the checker, cutting the run to ~30 seconds. `workflow_dispatch` still checks the full tree, and the deprecated `mintlify` CLI is swapped for `mint`, which drops the `yes` prompt hack. --- .github/workflows/docs-broken-links.yml | 41 ++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs-broken-links.yml b/.github/workflows/docs-broken-links.yml index e1b9aeb0e..4406b9001 100644 --- a/.github/workflows/docs-broken-links.yml +++ b/.github/workflows/docs-broken-links.yml @@ -4,13 +4,11 @@ on: pull_request: paths: - "docs/**" - - "docs.json" push: branches: - main paths: - "docs/**" - - "docs.json" workflow_dispatch: permissions: @@ -28,11 +26,40 @@ jobs: with: node-version: "22" - - name: Install Mintlify CLI - run: npm i -g mintlify + - name: Install Mint CLI + run: npm i -g mint@4.2.741 + + # Pruning immutable snapshots keeps the check fast (--files still parses every + # page); the default version must stay because unprefixed links resolve to it. + - name: Prune frozen doc versions (keep edge and latest) + if: github.event_name != 'workflow_dispatch' + run: | + python3 - <<'EOF' + import json + import shutil + from pathlib import Path + + docs = Path("docs") + spec_path = docs / "docs.json" + spec = json.loads(spec_path.read_text()) + + keep_dirs = {"edge"} + for lang in spec["navigation"]["languages"]: + kept = [v for v in lang["versions"] if v["version"] == "Edge" or v.get("default")] + lang["versions"] = kept + keep_dirs.update(v["version"] for v in kept if v["version"] != "Edge") + + missing = [d for d in keep_dirs if not (docs / d).is_dir()] + if missing: + raise SystemExit(f"docs.json version labels do not match directories: {missing}") + + spec_path.write_text(json.dumps(spec, indent=2)) + + for path in docs.glob("v*"): + if path.is_dir() and path.name not in keep_dirs: + shutil.rmtree(path) + EOF - name: Run broken link checker - run: | - # Auto-answer the prompt with yes command - yes "" | mintlify broken-links || test $? -eq 141 + run: mint broken-links working-directory: ./docs