Skip to content

Commit 7f7bfa6

Browse files
committed
Check rendered docs links locally
1 parent e7c5bac commit 7f7bfa6

2 files changed

Lines changed: 28 additions & 51 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -253,26 +253,12 @@ jobs:
253253
run: |
254254
echo "${{ github.sha }}" > artifacts/docs/.preview-commit
255255
256-
- name: Write doc preview link-check URL list
257-
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
258-
env:
259-
PREVIEW_URL: https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}
260-
run: |
261-
find "${GITHUB_WORKSPACE}/artifacts/docs" -type f -name '*.html' ! -path '*/_static/*' -printf '%P\n' \
262-
| LC_ALL=C sort \
263-
| sed "s#^#${PREVIEW_URL}/#" > lychee-preview-urls.txt
264-
if [[ ! -s lychee-preview-urls.txt ]]; then
265-
echo "error: no rendered HTML pages found for lychee" >&2
266-
exit 1
267-
fi
268-
wc -l lychee-preview-urls.txt
269-
270-
- name: Upload doc preview link-check URL list
256+
- name: Upload rendered docs for link checking
271257
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
272258
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
273259
with:
274-
name: docs-preview-linkcheck-urls
275-
path: lychee-preview-urls.txt
260+
name: docs-rendered-html
261+
path: artifacts/docs/
276262
if-no-files-found: error
277263
retention-days: 3
278264

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

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ name: "CI: Check rendered docs links"
77
on:
88
workflow_call:
99
inputs:
10-
url-artifact:
11-
description: "Artifact containing the rendered doc preview URL list"
10+
docs-artifact:
11+
description: "Artifact containing the rendered docs HTML tree"
1212
required: false
13-
default: docs-preview-linkcheck-urls
13+
default: docs-rendered-html
1414
type: string
1515

1616
jobs:
@@ -26,54 +26,45 @@ jobs:
2626
run:
2727
shell: bash -el {0}
2828
steps:
29-
- name: Checkout ${{ github.event.repository.name }}
30-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31-
32-
- name: Get PR number
33-
uses: ./.github/actions/get_pr_number
29+
- name: Extract PR number
30+
run: |
31+
PR_NUMBER="${GITHUB_REF_NAME#pull-request/}"
32+
if [[ ! "${PR_NUMBER}" =~ ^[0-9]+$ ]]; then
33+
echo "error: cannot extract PR number from ref ${GITHUB_REF_NAME}" >&2
34+
exit 1
35+
fi
36+
echo "PR_NUMBER=${PR_NUMBER}" >> "${GITHUB_ENV}"
3437
35-
- name: Download doc preview link-check URL list
38+
- name: Download rendered docs
3639
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
3740
with:
38-
name: ${{ inputs.url-artifact }}
39-
path: linkcheck-input
41+
name: ${{ inputs.docs-artifact }}
42+
path: rendered-docs
4043

41-
- name: Wait for doc preview deployment
42-
env:
43-
PREVIEW_URL: https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}
44-
EXPECTED_SHA: ${{ github.sha }}
44+
- name: Write rendered docs file list
4545
run: |
46-
preview_ready=0
47-
marker_url="${PREVIEW_URL}/.preview-commit"
48-
for attempt in {1..60}; do
49-
marker=$(curl -fsSL "${marker_url}" || true)
50-
if [[ "${marker}" == "${EXPECTED_SHA}" ]]; then
51-
preview_ready=1
52-
break
53-
fi
54-
echo "Waiting for doc preview marker ${marker_url} (${attempt}/60)"
55-
sleep 10
56-
done
57-
if [[ "${preview_ready}" != "1" ]]; then
58-
echo "error: doc preview marker did not update to ${EXPECTED_SHA}" >&2
46+
find "${GITHUB_WORKSPACE}/rendered-docs" -type f -name '*.html' ! -path '*/_static/*' \
47+
| LC_ALL=C sort > lychee-rendered-html-files.txt
48+
if [[ ! -s lychee-rendered-html-files.txt ]]; then
49+
echo "error: no rendered HTML pages found for lychee" >&2
5950
exit 1
6051
fi
61-
echo "Doc preview is available at ${PREVIEW_URL}"
52+
wc -l lychee-rendered-html-files.txt
6253
6354
- name: Restore lychee cache
6455
id: restore-lychee-cache
6556
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
6657
with:
6758
path: .lycheecache
68-
key: docs-preview-lychee-${{ env.PR_NUMBER }}-${{ github.sha }}
59+
key: docs-rendered-lychee-${{ env.PR_NUMBER }}-${{ github.sha }}
6960
restore-keys: |
70-
docs-preview-lychee-${{ env.PR_NUMBER }}-
61+
docs-rendered-lychee-${{ env.PR_NUMBER }}-
7162
72-
- name: Check doc preview links
63+
- name: Check rendered docs links
7364
uses: lycheeverse/lychee-action@6da1d14f3a43098a294b7696d93d938aa8d20fc0 # unreleased: supports v0.24.x archive layout
7465
with:
7566
args: >-
76-
--files-from ${{ github.workspace }}/linkcheck-input/lychee-preview-urls.txt
67+
--files-from ${{ github.workspace }}/lychee-rendered-html-files.txt
7768
--include-fragments=full
7869
--cache
7970
--max-cache-age 1d
@@ -89,7 +80,7 @@ jobs:
8980
format: markdown
9081
jobSummary: false
9182
lycheeVersion: v0.24.2
92-
output: lychee-preview.md
83+
output: lychee-rendered-html.md
9384
token: ${{ github.token }}
9485

9586
- name: Save lychee cache

0 commit comments

Comments
 (0)