Skip to content

Commit d186e04

Browse files
committed
Check newly added links in PRs
1 parent 457e74f commit d186e04

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎.github/workflows/test.yml‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,25 @@ jobs:
5353
- name: Install dependencies
5454
run: |
5555
python -m pip install --upgrade nox virtualenv
56+
- name: Restore linkcheck baseline
57+
if: matrix.noxenv == 'linkcheck' && (github.event_name == 'pull_request' || github.event_name == 'merge_group')
58+
uses: actions/cache/restore@v4
59+
with:
60+
path: build/output.json
61+
key: linkcheck-baseline-${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }}
5662

5763
- name: Nox ${{ matrix.noxenv }}
5864
env:
5965
# Authenticate github.com requests during linkcheck to avoid rate limits.
6066
GITHUB_TOKEN: ${{ matrix.noxenv == 'linkcheck' && github.token || '' }}
6167
run: |
6268
python -m nox -s ${{ matrix.noxenv }}
63-
69+
- name: Save linkcheck baseline
70+
if: always() && matrix.noxenv == 'linkcheck' && github.event_name == 'push' && github.ref == 'refs/heads/main'
71+
uses: actions/cache/save@v4
72+
with:
73+
path: build/output.json
74+
key: linkcheck-baseline-${{ github.sha }}
6475

6576
check:
6677
# This job does nothing and is only used for the branch protection

‎source/conf.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# -- Project information ---------------------------------------------------------------
22
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
33

4+
import json
45
import os
56
import pathlib
7+
import re
68
import sys
79

810
_ROOT = pathlib.Path(__file__).resolve().parent.parent
@@ -165,6 +167,16 @@
165167
# Temporarily ignored due to expired TLS cert.
166168
r"https://kivy.org/.*",
167169
]
170+
if (
171+
os.getenv("GITHUB_ACTIONS") == "true"
172+
and os.getenv("GITHUB_EVENT_NAME") in {"pull_request", "merge_group"}
173+
and (baseline := pathlib.Path("build/output.json")).exists()
174+
):
175+
with baseline.open() as f:
176+
linkcheck_ignore.extend(
177+
re.escape(json.loads(line)["uri"])
178+
for line in f
179+
)
168180
linkcheck_retries = 2
169181
linkcheck_timeout = 30
170182
# Ignore anchors for common targets when we know they likely won't be found

0 commit comments

Comments
 (0)