]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-145000: Run `check-html-ids.py` in CI (#145632)
authorStan Ulbrych <stan@ulbrych.org>
Wed, 1 Apr 2026 13:10:27 +0000 (15:10 +0200)
committerGitHub <noreply@github.com>
Wed, 1 Apr 2026 13:10:27 +0000 (15:10 +0200)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
.github/workflows/reusable-check-html-ids.yml [new file with mode: 0644]
.github/workflows/reusable-docs.yml
Doc/tools/check-html-ids.py
Doc/tools/removed-ids.txt [new file with mode: 0644]

diff --git a/.github/workflows/reusable-check-html-ids.yml b/.github/workflows/reusable-check-html-ids.yml
new file mode 100644 (file)
index 0000000..47a2e25
--- /dev/null
@@ -0,0 +1,58 @@
+name: Reusable check HTML IDs
+
+on:
+  workflow_call:
+
+permissions:
+  contents: read
+
+env:
+  FORCE_COLOR: 1
+
+jobs:
+  check-html-ids:
+    name: 'Check for removed HTML IDs'
+    runs-on: ubuntu-latest
+    timeout-minutes: 30
+    steps:
+      - name: 'Check out base commit'
+        uses: actions/checkout@v6
+        with:
+          persist-credentials: false
+          ref: ${{ github.event.pull_request.base.sha }}
+      - name: 'Set up Python'
+        uses: actions/setup-python@v6
+        with:
+          python-version: '3'
+          cache: 'pip'
+          cache-dependency-path: 'Doc/requirements.txt'
+      - name: 'Install build dependencies'
+        run: make -C Doc/ venv
+      - name: 'Build HTML documentation'
+        run: make -C Doc/ SPHINXOPTS="--quiet" html
+      - name: 'Check out PR head tools'
+        uses: actions/checkout@v6
+        with:
+          persist-credentials: false
+          sparse-checkout: |
+            Doc/tools/check-html-ids.py
+            Doc/tools/removed-ids.txt
+          sparse-checkout-cone-mode: false
+          path: pr-head
+      - name: 'Use PR head tools'
+        run: |
+          cp pr-head/Doc/tools/check-html-ids.py Doc/tools/check-html-ids.py
+          [ -f pr-head/Doc/tools/removed-ids.txt ] && cp pr-head/Doc/tools/removed-ids.txt Doc/tools/removed-ids.txt
+      - name: 'Collect HTML IDs'
+        run: python Doc/tools/check-html-ids.py collect Doc/build/html -o /tmp/html-ids-base.json.gz
+      - name: 'Download PR head HTML IDs'
+        uses: actions/download-artifact@v8
+        with:
+          name: html-ids-head.json.gz
+          path: /tmp
+      - name: 'Check for removed HTML IDs'
+        run: |
+          # shellcheck disable=SC2046
+          python Doc/tools/check-html-ids.py -v check \
+            /tmp/html-ids-base.json.gz /tmp/html-ids-head.json.gz \
+            $([ -f Doc/tools/removed-ids.txt ] && echo "--exclude-file Doc/tools/removed-ids.txt")
index bee44e8df276639684bf9de7344feb02ba8652be..5227c04c06f9c8d5d8dd6033b5f13af7d139d058 100644 (file)
@@ -75,6 +75,22 @@ jobs:
           --fail-if-regression \
           --fail-if-improved \
           --fail-if-new-news-nit
+    - name: 'Collect HTML IDs'
+      if: github.event_name == 'pull_request'
+      run: python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz
+    - name: 'Upload HTML IDs'
+      if: github.event_name == 'pull_request'
+      uses: actions/upload-artifact@v7
+      with:
+        name: html-ids-head
+        path: Doc/build/html-ids-head.json.gz
+        archive: false
+
+  check-html-ids:
+    name: 'Check for removed HTML IDs'
+    needs: build-doc
+    if: github.event_name == 'pull_request'
+    uses: ./.github/workflows/reusable-check-html-ids.yml
 
   # Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
   doctest:
index 8e8e0a581df72d0652ffa9b92b74d6d5cf2e6967..7d86c6cc3264ad554aad5d73ee81b1d08d0bf674 100644 (file)
@@ -175,6 +175,7 @@ def main(argv):
             )
             if args.exclude_file:
                 print(f'Alternatively, add them to {args.exclude_file}.')
+            sys.exit(1)
 
 
 if __name__ == '__main__':
diff --git a/Doc/tools/removed-ids.txt b/Doc/tools/removed-ids.txt
new file mode 100644 (file)
index 0000000..f3cd8bf
--- /dev/null
@@ -0,0 +1 @@
+# HTML IDs excluded from the check-html-ids.py check.