Skip to content

Commit ed50484

Browse files
committed
Check rendered doc preview links with lychee
1 parent d6466e9 commit ed50484

5 files changed

Lines changed: 72 additions & 174 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ jobs:
216216
run: |
217217
pushd cuda_python/docs/
218218
if [[ "${{ inputs.is-release }}" == "false" ]]; then
219-
DOCS_LINKCHECK=1 ./build_all_docs.sh latest-only
219+
./build_all_docs.sh latest-only
220220
else
221-
DOCS_LINKCHECK=1 ./build_all_docs.sh
221+
./build_all_docs.sh
222222
# At release time, we don't want to update the latest docs
223223
rm -rf build/html/latest
224224
fi
@@ -232,9 +232,9 @@ jobs:
232232
COMPONENT=$(echo "${{ inputs.component }}" | tr '-' '_')
233233
pushd ${COMPONENT}/docs/
234234
if [[ "${{ inputs.is-release }}" == "false" ]]; then
235-
DOCS_LINKCHECK=1 ./build_docs.sh latest-only
235+
./build_docs.sh latest-only
236236
else
237-
DOCS_LINKCHECK=1 ./build_docs.sh
237+
./build_docs.sh
238238
# At release time, we don't want to update the latest docs
239239
rm -rf build/html/latest
240240
fi
@@ -248,6 +248,11 @@ jobs:
248248
fi
249249
mv ${COMPONENT}/docs/build/html/* artifacts/docs/${TARGET}
250250
251+
- name: Write doc preview marker
252+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
253+
run: |
254+
echo "${{ github.sha }}" > artifacts/docs/.preview-commit
255+
251256
# TODO: Consider removing this step?
252257
- name: Upload doc artifacts
253258
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
@@ -263,6 +268,69 @@ jobs:
263268
'artifacts/empty_docs' }}
264269
pr-number: ${{ env.PR_NUMBER }}
265270

271+
- name: Wait for doc preview deployment
272+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
273+
env:
274+
PREVIEW_URL: https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}
275+
run: |
276+
marker_url="${PREVIEW_URL}/.preview-commit"
277+
for attempt in {1..60}; do
278+
marker=$(curl -fsSL "${marker_url}" || true)
279+
if [[ "${marker}" == "${{ github.sha }}" ]]; then
280+
echo "Doc preview is available at ${PREVIEW_URL}"
281+
exit 0
282+
fi
283+
echo "Waiting for doc preview marker ${marker_url} (${attempt}/60)"
284+
sleep 10
285+
done
286+
echo "error: doc preview marker did not update to ${{ github.sha }}" >&2
287+
exit 1
288+
289+
- name: Restore lychee cache
290+
id: restore-lychee-cache
291+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
292+
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
293+
with:
294+
path: .lycheecache
295+
key: docs-preview-lychee-${{ env.PR_NUMBER }}-${{ github.sha }}
296+
restore-keys: |
297+
docs-preview-lychee-${{ env.PR_NUMBER }}-
298+
299+
- name: Check doc preview links
300+
if: ${{ !inputs.is-release && github.ref_name != 'main' && !startsWith(github.ref_name, 'release/') }}
301+
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2
302+
with:
303+
args: >-
304+
--base-url https://nvidia.github.io/cuda-python/pr-preview/pr-${{ env.PR_NUMBER }}/
305+
--root-dir ${{ github.workspace }}/artifacts/docs
306+
--index-files index.html
307+
--fallback-extensions html,htm
308+
--include-fragments full
309+
--cache
310+
--max-cache-age 1d
311+
--max-concurrency 16
312+
--host-concurrency 2
313+
--host-request-interval 250ms
314+
--max-retries 3
315+
--retry-wait-time 5
316+
--timeout 30
317+
--no-progress
318+
'${{ github.workspace }}/artifacts/docs/**/*.html'
319+
fail: true
320+
failIfEmpty: true
321+
format: markdown
322+
jobSummary: true
323+
lycheeVersion: v0.24.2
324+
output: lychee-preview.md
325+
token: ${{ github.token }}
326+
327+
- name: Save lychee cache
328+
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 != '' }}
329+
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
330+
with:
331+
path: .lycheecache
332+
key: ${{ steps.restore-lychee-cache.outputs.cache-primary-key }}
333+
266334
- name: Deploy doc update
267335
if: ${{ github.ref_name == 'main' || inputs.is-release }}
268336
uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0

cuda_bindings/docs/build_docs.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ else
3737
fi
3838
SPHINXOPTS="${HTML_SPHINXOPTS}" make html
3939

40-
if [[ "${DOCS_LINKCHECK:-0}" == "1" ]]; then
41-
if [[ -n "${CUDA_PYTHON_DOCS_GITHUB_REF:-}" ]]; then
42-
DOCS_EXAMPLES_REF="${CUDA_PYTHON_DOCS_GITHUB_REF}"
43-
elif [[ "${BUILD_PREVIEW:-0}" == "1" || "${BUILD_LATEST:-0}" == "1" ]]; then
44-
DOCS_EXAMPLES_REF="main"
45-
else
46-
DOCS_EXAMPLES_REF="v${SPHINX_CUDA_BINDINGS_VER}"
47-
fi
48-
python ../../cuda_python/docs/check_example_links.py \
49-
--source-dir source \
50-
--examples-root cuda_bindings/examples \
51-
--expected-ref "${DOCS_EXAMPLES_REF}" \
52-
--placeholder cuda_bindings_github_ref
53-
fi
54-
5540
# for debugging/developing (conf.py), please comment out the above line and
5641
# use the line below instead, as we must build in serial to avoid getting
5742
# obsecure Sphinx errors

cuda_core/docs/build_docs.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ fi
3737
SPHINXOPTS="${HTML_SPHINXOPTS}"
3838
make html
3939

40-
if [[ "${DOCS_LINKCHECK:-0}" == "1" ]]; then
41-
if [[ -n "${CUDA_PYTHON_DOCS_GITHUB_REF:-}" ]]; then
42-
DOCS_EXAMPLES_REF="${CUDA_PYTHON_DOCS_GITHUB_REF}"
43-
elif [[ "${BUILD_PREVIEW:-0}" == "1" || "${BUILD_LATEST:-0}" == "1" ]]; then
44-
DOCS_EXAMPLES_REF="main"
45-
else
46-
DOCS_EXAMPLES_REF="cuda-core-v${SPHINX_CUDA_CORE_VER}"
47-
fi
48-
python ../../cuda_python/docs/check_example_links.py \
49-
--source-dir source \
50-
--examples-root cuda_core/examples \
51-
--expected-ref "${DOCS_EXAMPLES_REF}" \
52-
--placeholder cuda_core_github_ref
53-
fi
54-
5540
# to support version dropdown menu
5641
cp ./versions.json build/html
5742
cp ./nv-versions.json build/html

cuda_pathfinder/docs/build_docs.sh

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ else
3737
fi
3838
SPHINXOPTS="${HTML_SPHINXOPTS}" make html
3939

40-
if [[ "${DOCS_LINKCHECK:-0}" == "1" ]]; then
41-
if [[ -n "${CUDA_PYTHON_DOCS_GITHUB_REF:-}" ]]; then
42-
DOCS_EXAMPLES_REF="${CUDA_PYTHON_DOCS_GITHUB_REF}"
43-
elif [[ "${BUILD_PREVIEW:-0}" == "1" || "${BUILD_LATEST:-0}" == "1" ]]; then
44-
DOCS_EXAMPLES_REF="main"
45-
else
46-
DOCS_EXAMPLES_REF="cuda-pathfinder-v${SPHINX_CUDA_PATHFINDER_VER}"
47-
fi
48-
python ../../cuda_python/docs/check_example_links.py \
49-
--source-dir source \
50-
--examples-root cuda_pathfinder/examples \
51-
--expected-ref "${DOCS_EXAMPLES_REF}" \
52-
--allow-empty
53-
fi
54-
5540
# for debugging/developing (conf.py), please comment out the above line and
5641
# use the line below instead, as we must build in serial to avoid getting
5742
# obsecure Sphinx errors

cuda_python/docs/check_example_links.py

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

0 commit comments

Comments
 (0)