diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81ea4f0541..80951276f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,6 +53,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade nox virtualenv + - name: Restore linkcheck baseline + if: matrix.noxenv == 'linkcheck' && (github.event_name == 'pull_request' || github.event_name == 'merge_group') + uses: actions/cache/restore@v4 + with: + path: build/output.json + key: linkcheck-baseline-${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }} - name: Nox ${{ matrix.noxenv }} env: @@ -60,7 +66,12 @@ jobs: GITHUB_TOKEN: ${{ matrix.noxenv == 'linkcheck' && github.token || '' }} run: | python -m nox -s ${{ matrix.noxenv }} - + - name: Save linkcheck baseline + if: always() && matrix.noxenv == 'linkcheck' && github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/cache/save@v4 + with: + path: build/output.json + key: linkcheck-baseline-${{ github.sha }} check: # This job does nothing and is only used for the branch protection diff --git a/source/conf.py b/source/conf.py index d44be01630..4ced2db4ab 100644 --- a/source/conf.py +++ b/source/conf.py @@ -1,8 +1,10 @@ # -- Project information --------------------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +import json import os import pathlib +import re import sys _ROOT = pathlib.Path(__file__).resolve().parent.parent @@ -165,6 +167,13 @@ # Temporarily ignored due to expired TLS cert. r"https://kivy.org/.*", ] +if ( + os.getenv("GITHUB_ACTIONS") == "true" + and os.getenv("GITHUB_EVENT_NAME") in {"pull_request", "merge_group"} + and (baseline := pathlib.Path("build/output.json")).exists() +): + with baseline.open() as f: + linkcheck_ignore.extend(re.escape(json.loads(line)["uri"]) for line in f) linkcheck_retries = 2 linkcheck_timeout = 30 # Ignore anchors for common targets when we know they likely won't be found