Skip to content

Commit 08c5d3d

Browse files
gh-145000: Run check-html-ids.py in CI (#145632)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 07d5d72 commit 08c5d3d

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Reusable check HTML IDs
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
FORCE_COLOR: 1
11+
12+
jobs:
13+
check-html-ids:
14+
name: 'Check for removed HTML IDs'
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 30
17+
steps:
18+
- name: 'Check out base commit'
19+
uses: actions/checkout@v6
20+
with:
21+
persist-credentials: false
22+
ref: ${{ github.event.pull_request.base.sha }}
23+
- name: 'Set up Python'
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: '3'
27+
cache: 'pip'
28+
cache-dependency-path: 'Doc/requirements.txt'
29+
- name: 'Install build dependencies'
30+
run: make -C Doc/ venv
31+
- name: 'Build HTML documentation'
32+
run: make -C Doc/ SPHINXOPTS="--quiet" html
33+
- name: 'Check out PR head tools'
34+
uses: actions/checkout@v6
35+
with:
36+
persist-credentials: false
37+
sparse-checkout: |
38+
Doc/tools/check-html-ids.py
39+
Doc/tools/removed-ids.txt
40+
sparse-checkout-cone-mode: false
41+
path: pr-head
42+
- name: 'Use PR head tools'
43+
run: |
44+
cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py
45+
[ -f pr-head/Doc/tools/removed-ids.txt ] && cp pr-head/Doc/tools/removed-ids.txt Doc/tools/removed-ids.txt
46+
- name: 'Collect HTML IDs'
47+
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz
48+
- name: 'Download PR head HTML IDs'
49+
uses: actions/download-artifact@v8
50+
with:
51+
name: html-ids-head.json.gz
52+
path: /tmp
53+
- name: 'Check for removed HTML IDs'
54+
run: |
55+
# shellcheck disable=SC2046
56+
python Doc/tools/check-html-ids.py -v check \
57+
/tmp/html-ids-base.json.gz /tmp/html-ids-head.json.gz \
58+
$([ -f Doc/tools/removed-ids.txt ] && echo "--exclude-file Doc/tools/removed-ids.txt")

.github/workflows/reusable-docs.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ jobs:
7575
--fail-if-regression \
7676
--fail-if-improved \
7777
--fail-if-new-news-nit
78+
- name: 'Collect HTML IDs'
79+
if: github.event_name == 'pull_request'
80+
run: python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz
81+
- name: 'Upload HTML IDs'
82+
if: github.event_name == 'pull_request'
83+
uses: actions/upload-artifact@v7
84+
with:
85+
name: html-ids-head
86+
path: Doc/build/html-ids-head.json.gz
87+
archive: false
88+
89+
check-html-ids:
90+
name: 'Check for removed HTML IDs'
91+
needs: build-doc
92+
if: github.event_name == 'pull_request'
93+
uses: ./.github/workflows/reusable-check-html-ids.yml
7894

7995
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
8096
doctest:

Doc/tools/check-html-ids.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ def verbose_print(*args, **kwargs):
175175
)
176176
if args.exclude_file:
177177
print(f'Alternatively, add them to {args.exclude_file}.')
178+
sys.exit(1)
178179

179180

180181
if __name__ == '__main__':

Doc/tools/removed-ids.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# HTML IDs excluded from the check-html-ids.py check.

0 commit comments

Comments
 (0)