Skip to content

Commit 4e0695c

Browse files
committed
PYTHON-5393 Make link checking more robust
1 parent 9145521 commit 4e0695c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.github/workflows/test-python.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ jobs:
125125
linkcheck:
126126
name: Link Check
127127
runs-on: ubuntu-latest
128+
permissions:
129+
contents: read
128130
steps:
129131
- uses: actions/checkout@v4
130132
with:
@@ -139,6 +141,8 @@ jobs:
139141
- name: Install dependencies
140142
run: just install
141143
- name: Build docs
144+
env:
145+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142146
run: just docs-linkcheck
143147

144148
typing:

doc/conf.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# This file is execfile()d with the current directory set to its containing dir.
55
from __future__ import annotations
66

7+
import os
78
import sys
89
from pathlib import Path
910

@@ -91,6 +92,14 @@
9192
r"https://sourceforge.net/",
9293
]
9394

95+
# Add GitHub auth if available to avoid rate limiting.
96+
if "GH_TOKEN" in os.environ:
97+
token = os.environ["GH_TOKEN"]
98+
linkcheck_request_headers = {r"https://github.\.com/.+": {"authorization": f"Bearer ${token}"}}
99+
100+
# Allow for flakey links.
101+
linkcheck_retries = 2
102+
94103
# -- Options for extensions ----------------------------------------------------
95104
autoclass_content = "init"
96105

0 commit comments

Comments
 (0)