Skip to content

Commit 0a319ad

Browse files
committed
Inline rendered docs link check
1 parent 22dde0a commit 0a319ad

4 files changed

Lines changed: 57 additions & 123 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,65 @@ jobs:
245245
fi
246246
mv ${COMPONENT}/docs/build/html/* artifacts/docs/${TARGET}
247247
248-
- name: Upload rendered docs for link checking
248+
- name: Write rendered docs file list
249249
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
250-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
250+
run: |
251+
find "${GITHUB_WORKSPACE}/artifacts/docs" -type f -name '*.html' ! -path '*/_static/*' \
252+
| LC_ALL=C sort > lychee-rendered-html-files.txt
253+
if [[ ! -s lychee-rendered-html-files.txt ]]; then
254+
echo "error: no rendered HTML pages found for lychee" >&2
255+
exit 1
256+
fi
257+
wc -l lychee-rendered-html-files.txt
258+
259+
- name: Restore lychee cache
260+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
261+
id: restore-lychee-cache
262+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
251263
with:
252-
name: docs-rendered-html
253-
path: artifacts/docs/
254-
if-no-files-found: error
255-
retention-days: 3
264+
path: .lycheecache
265+
key: docs-rendered-lychee-${{ env.PR_NUMBER }}-${{ github.sha }}
266+
restore-keys: |
267+
docs-rendered-lychee-${{ env.PR_NUMBER }}-
268+
269+
- name: Check rendered docs links
270+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
271+
uses: lycheeverse/lychee-action@6da1d14f3a43098a294b7696d93d938aa8d20fc0 # unreleased: supports v0.24.x archive layout
272+
with:
273+
# PR-preview canonical URLs are checked by the preview deployment workflow.
274+
# The cuda-bindings #id links are docutils "problematic" anchors from generated API docs.
275+
# TODO: Remove this exclusion after cybind stops emitting those problematic anchors.
276+
# Preferred Networks rejects hosted-runner GETs, but the URL is browser reachable.
277+
args: >-
278+
--files-from ${{ github.workspace }}/lychee-rendered-html-files.txt
279+
--include-fragments=full
280+
--cache
281+
--max-cache-age 1d
282+
--max-concurrency 16
283+
--host-concurrency 2
284+
--host-request-interval 250ms
285+
--max-retries 3
286+
--retry-wait-time 5
287+
--timeout 30
288+
--no-progress
289+
--exclude '^https://nvidia\.github\.io/cuda-python/pr-preview/pr-[0-9]+/'
290+
--exclude '^file://.*/cuda-bindings/latest/module/(driver|runtime)\.html#id[0-9]+$'
291+
--exclude '^https://www\.preferred\.jp/en/?$'
292+
fail: true
293+
failIfEmpty: true
294+
format: markdown
295+
jobSummary: false
296+
lycheeVersion: v0.24.2
297+
output: lychee-rendered-html.md
298+
token: ${{ github.token }}
299+
300+
- name: Save lychee cache
301+
if: ${{ always() && !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') && steps.restore-lychee-cache.outputs.cache-hit != 'true' && steps.restore-lychee-cache.outputs.cache-primary-key != '' }}
302+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
303+
with:
304+
path: .lycheecache
305+
key: ${{ steps.restore-lychee-cache.outputs.cache-primary-key }}
256306

257-
# This is the GitHub Pages artifact format; the link checker needs a
258-
# normal workflow artifact with the rendered HTML tree above.
259307
- name: Upload docs GitHub Pages artifact
260308
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
261309
with:

.github/workflows/check-doc-links.yml

Lines changed: 0 additions & 98 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,6 @@ jobs:
415415
with:
416416
is-release: ${{ github.ref_type == 'tag' }}
417417

418-
doc-linkcheck:
419-
name: Docs link check
420-
if: ${{ github.repository_owner == 'nvidia' && startsWith(github.ref_name, 'pull-request/') && needs.doc.result == 'success' }}
421-
permissions:
422-
actions: read
423-
contents: read
424-
pull-requests: read
425-
needs:
426-
- doc
427-
secrets: inherit
428-
uses: ./.github/workflows/check-doc-links.yml
429-
430418
checks:
431419
name: Check job status
432420
if: always()
@@ -440,7 +428,6 @@ jobs:
440428
- test-linux-aarch64
441429
- test-windows
442430
- doc
443-
- doc-linkcheck
444431
steps:
445432
- name: Exit
446433
run: |
@@ -476,9 +463,6 @@ jobs:
476463
if ${{ needs.doc.result == 'cancelled' || needs.doc.result == 'failure' }}; then
477464
exit 1
478465
fi
479-
if ${{ needs.doc-linkcheck.result == 'cancelled' || needs.doc-linkcheck.result == 'failure' }}; then
480-
exit 1
481-
fi
482466
if ${{ needs.test-sdist-linux.result == 'cancelled' ||
483467
needs.test-sdist-linux.result == 'failure' ||
484468
needs.test-sdist-windows.result == 'cancelled' ||

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ repos:
5656

5757
# Link checking for authored documentation files
5858
- repo: https://github.com/lycheeverse/lychee
59-
rev: lychee-v0.24.2
59+
rev: 2bba271688c1abb1503097a064e6c3bc1d1b6a9b # frozen: lychee-v0.24.2
6060
hooks:
6161
- id: lychee
6262
args:

0 commit comments

Comments
 (0)