-
Notifications
You must be signed in to change notification settings - Fork 2.1k
ci(docs): check changed markdown links on pull requests #1139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
13ernkastel
wants to merge
11
commits into
NVIDIA:main
Choose a base branch
from
13ernkastel:codex/issue-552-docs-link-checker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+217
−11
Open
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e4fa005
ci(docs): check changed markdown links on pull requests
13ernkastel 113bbf4
ci(docs): stabilize doc checker locale handling
13ernkastel 1ff2346
ci(docs): tighten markdown link filtering
13ernkastel d948e2f
Merge branch 'main' into codex/issue-552-docs-link-checker
13ernkastel 8af07c8
test(docs): handle mixed markdown fence delimiters
13ernkastel ebf9fb1
Merge branch 'main' into codex/issue-552-docs-link-checker
13ernkastel 8d724c5
test(docs): reject trailing text on fence closers
13ernkastel 3905941
Merge branch 'main' into codex/issue-552-docs-link-checker
cv be3c965
chore(ci): rerun PR checks after DCO sign-off update
13ernkastel 8a53462
Merge branch 'main' into codex/issue-552-docs-link-checker
13ernkastel 6e31ae2
Merge branch 'main' into codex/issue-552-docs-link-checker
cv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| name: Docs Links PR | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| types: [opened, reopened, synchronize] | ||
| paths: | ||
| - "**/*.md" | ||
| - ".github/workflows/docs-links-pr.yaml" | ||
| - "test/e2e/e2e-cloud-experimental/check-docs.sh" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| markdown-links: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Determine changed markdown files | ||
| id: changed | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| base="${{ github.event.pull_request.base.sha }}" | ||
| head="${{ github.event.pull_request.head.sha }}" | ||
| mapfile -t md_files < <( | ||
| git diff --name-only --diff-filter=ACMR "$base" "$head" -- \ | ||
| '*.md' \ | ||
| ':(exclude)node_modules/**' \ | ||
| ':(exclude)dist/**' \ | ||
| ':(exclude)vendor/**' \ | ||
| ':(exclude)build/**' \ | ||
| | LC_ALL=C sort -u | ||
| ) | ||
|
|
||
| if [[ "${#md_files[@]}" -eq 0 ]]; then | ||
| echo "has_files=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "has_files=true" >> "$GITHUB_OUTPUT" | ||
| { | ||
| echo "files<<EOF" | ||
| printf '%s\n' "${md_files[@]}" | ||
| echo "EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Run markdown link checker | ||
| if: steps.changed.outputs.has_files == 'true' | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| mapfile -t md_files <<< "${{ steps.changed.outputs.files }}" | ||
| bash test/e2e/e2e-cloud-experimental/check-docs.sh --only-links --local-only "${md_files[@]}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { describe, it, expect } from "vitest"; | ||
| import { spawnSync } from "node:child_process"; | ||
| import fs from "node:fs"; | ||
| import os from "node:os"; | ||
| import path from "node:path"; | ||
|
|
||
| const CHECK_DOCS = path.join(import.meta.dirname, "e2e", "e2e-cloud-experimental", "check-docs.sh"); | ||
|
|
||
| function runCheckDocs(filePath) { | ||
| return spawnSync("bash", [CHECK_DOCS, "--only-links", "--local-only", filePath], { | ||
| encoding: "utf-8", | ||
| }); | ||
| } | ||
|
|
||
| describe("check-docs link validation", () => { | ||
| it("reports broken local markdown links with source line numbers", () => { | ||
| const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-check-docs-")); | ||
| const mdPath = path.join(tempDir, "guide.md"); | ||
| fs.writeFileSync(path.join(tempDir, "exists.md"), "# ok\n"); | ||
| fs.writeFileSync( | ||
| mdPath, | ||
| [ | ||
| "# Guide", | ||
| "", | ||
| "[working](./exists.md)", | ||
| "[broken](./missing.md)", | ||
| "```md", | ||
| "[ignored](./inside-code-fence.md)", | ||
| "```", | ||
| "", | ||
| ].join("\n"), | ||
| ); | ||
|
|
||
| const result = runCheckDocs(mdPath); | ||
|
|
||
| expect(result.status).toBe(1); | ||
| expect(`${result.stdout}${result.stderr}`).toContain(`broken local link in ${mdPath}:4 -> ./missing.md`); | ||
| expect(`${result.stdout}${result.stderr}`).not.toContain("inside-code-fence.md"); | ||
| }); | ||
|
|
||
| it("ignores broken links inside fenced code blocks", () => { | ||
| const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-check-docs-codefence-")); | ||
| const mdPath = path.join(tempDir, "guide.md"); | ||
| fs.writeFileSync( | ||
| mdPath, | ||
| [ | ||
| "# Guide", | ||
| "", | ||
| "```md", | ||
| "[example](./missing.md)", | ||
| "```", | ||
| "", | ||
| ].join("\n"), | ||
| ); | ||
|
|
||
| const result = runCheckDocs(mdPath); | ||
|
|
||
| expect(result.status).toBe(0); | ||
| }); | ||
|
|
||
| it("ignores broken links inside tilde-fenced code blocks", () => { | ||
| const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "nemoclaw-check-docs-tildefence-")); | ||
| const mdPath = path.join(tempDir, "guide.md"); | ||
| fs.writeFileSync( | ||
| mdPath, | ||
| [ | ||
| "# Guide", | ||
| "", | ||
| "~~~md", | ||
| "[example](./missing.md)", | ||
| "~~~", | ||
| "", | ||
| ].join("\n"), | ||
| ); | ||
|
|
||
| const result = runCheckDocs(mdPath); | ||
|
|
||
| expect(result.status).toBe(0); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.