From c45fc47b6b50e2a339a830be89d9e2cc1c71f7c9 Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Fri, 2 Oct 2026 17:09:00 -0400 Subject: [PATCH 1/4] Add lychee link checker workflow --- .github/workflows/linkcheck.yaml | 38 ++++++++++++++++++++++++++++++++ Makefile | 5 ++++- lychee.toml | 30 +++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linkcheck.yaml create mode 100644 lychee.toml diff --git a/.github/workflows/linkcheck.yaml b/.github/workflows/linkcheck.yaml new file mode 100644 index 00000000..180b0252 --- /dev/null +++ b/.github/workflows/linkcheck.yaml @@ -0,0 +1,38 @@ +name: Link check + +on: + pull_request: + push: + branches: + - main + schedule: + # Mondays 06:00 UTC, so link rot is caught even without PR activity + - cron: "0 6 * * 1" + workflow_dispatch: + +permissions: {} + +jobs: + lychee: + name: lychee + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Check links + uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 # v2.9.0 + with: + args: >- + --config lychee.toml + --no-progress + 'doc/content/**/*.md' + 'exampleSite/content/**/*.md' + 'README.md' + 'CHANGELOG.md' + fail: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Makefile b/Makefile index 8f3ccefa..ded57d54 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: doc-serve shortcode-docs netlify-preview preview-theme theme docs scipy main blog learn tools serve-dev +.PHONY: doc-serve shortcode-docs netlify-preview preview-theme theme docs scipy main blog learn tools serve-dev linkcheck .DEFAULT_GOAL := doc-serve GH_ORG = scientific-python @@ -83,3 +83,6 @@ tools: git clone --depth 1 https://github.com/scientific-python/tools.scientific-python.org $@ (cd $@ ; perl -pi -e 'print "relativeURLs: true\n" if $$. == 1' config.yaml) (cd $@ ; hugo --themesDir="../..") + +linkcheck: + lychee --config lychee.toml 'doc/content/**/*.md' 'exampleSite/content/**/*.md' README.md CHANGELOG.md diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 00000000..83fee2bd --- /dev/null +++ b/lychee.toml @@ -0,0 +1,30 @@ +# Configuration for lychee (https://lychee.cli.rs) +# Run locally with: lychee --config lychee.toml 'doc/content/**/*.md' README.md + +# Don't fail on these; 403/429 are usually bot-blocking, not dead links +accept = ["200..=299", "403", "429"] + +max_retries = 3 +retry_wait_time = 5 +timeout = 20 +max_concurrency = 16 + +# Hugo template syntax in layouts is not a URL +exclude = [ + "^https?://fonts\\.gstatic\\.com", + "^https?://fonts\\.googleapis\\.com", + "^https?://cdn\\.jsdelivr\\.net", + "^https?://cdnjs\\.cloudflare\\.com", + "\\{\\{.*\\}\\}", + "^https?://localhost", + "^https?://127\\.0\\.0\\.1", + "^https?://example\\.(com|org)", +] + +# Relative links can't resolve without a built site +exclude_path = [] +include_fragments = false +exclude_all_private = true + +# Use GitHub API for github.com links (avoids rate limits; needs GITHUB_TOKEN) +github_token = "" \ No newline at end of file From bd3e16a4dd17bfa75bfcc0d529b8307beb8039a3 Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Fri, 2 Oct 2026 17:37:24 -0400 Subject: [PATCH 2/4] Incorporate review feedback Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- .github/workflows/linkcheck.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linkcheck.yaml b/.github/workflows/linkcheck.yaml index 180b0252..fc94e9e5 100644 --- a/.github/workflows/linkcheck.yaml +++ b/.github/workflows/linkcheck.yaml @@ -35,4 +35,4 @@ jobs: 'CHANGELOG.md' fail: false env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From cfa94ebcc8b2a1bc4c1a3194c5c88c3570b46ab7 Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Fri, 2 Oct 2026 17:37:39 -0400 Subject: [PATCH 3/4] Incorporate review feedback Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> --- lychee.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lychee.toml b/lychee.toml index 83fee2bd..b022f823 100644 --- a/lychee.toml +++ b/lychee.toml @@ -27,4 +27,4 @@ include_fragments = false exclude_all_private = true # Use GitHub API for github.com links (avoids rate limits; needs GITHUB_TOKEN) -github_token = "" \ No newline at end of file +github_token = "" From a01244039987bd56e67f48c2dbb083acfdac379a Mon Sep 17 00:00:00 2001 From: Inessa Pawson Date: Fri, 2 Oct 2026 17:50:29 -0400 Subject: [PATCH 4/4] Drop linkcheck target from Makefile --- Makefile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Makefile b/Makefile index ded57d54..8f3ccefa 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: doc-serve shortcode-docs netlify-preview preview-theme theme docs scipy main blog learn tools serve-dev linkcheck +.PHONY: doc-serve shortcode-docs netlify-preview preview-theme theme docs scipy main blog learn tools serve-dev .DEFAULT_GOAL := doc-serve GH_ORG = scientific-python @@ -83,6 +83,3 @@ tools: git clone --depth 1 https://github.com/scientific-python/tools.scientific-python.org $@ (cd $@ ; perl -pi -e 'print "relativeURLs: true\n" if $$. == 1' config.yaml) (cd $@ ; hugo --themesDir="../..") - -linkcheck: - lychee --config lychee.toml 'doc/content/**/*.md' 'exampleSite/content/**/*.md' README.md CHANGELOG.md