From ffed92711e5b4645bce7f93e2de7b91e20a37b05 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Sat, 17 Oct 2026 21:23:07 +0200 Subject: [PATCH] links: check with landingkit links instead of an inline curl loop The kit's checker (pinned by go.mod) probes github.com blob links on the raw host, which the inline loop did not. Run on this site first: all links pass; a planted dead repo link and dead blob link both fail it. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/links.yml | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml index dd01dbd..d1d7ef6 100644 --- a/.github/workflows/links.yml +++ b/.github/workflows/links.yml @@ -33,30 +33,14 @@ jobs: hugo-version: "0.168.0" extended: true - run: hugo --minify --destination ./public + # The checker is the landing kit's own, `landingkit links`, at the + # version go.mod pins (Renovate bumps it with the partials). It replaces + # an inline curl loop, and probes github.com blob links on + # raw.githubusercontent.com: github.com answers a program's request for a + # blob page with 503 most of the time. Checked on this site before the + # switch: every link passes, and a planted dead repository link and a + # dead blob link both fail it (exit 1). - name: Check - run: | - set -uo pipefail - # The character class matters: an extractor that stops only at ) and " - # carries a closing > or < into the request. - urls=$(grep -rhoE 'https?://[^)">< [:space:]]+' public/ | sed 's/[.,]$//' | sort -u) - test -n "$urls" || { echo "::error::no links found; did the site build?"; exit 1; } - echo "checking $(printf '%s\n' "$urls" | wc -l) distinct URLs" - fail=0 - while read -r u; do - # img.shields.io renders anything asked of it and proves nothing. - case "$u" in *img.shields.io*) continue ;; esac - # Three attempts: one is a flake detector rather than a link - # checker, and a lane that fails at random is a lane people learn - # to ignore. - code=000 - for attempt in 1 2 3; do - code=$(curl -sS -o /dev/null -w '%{http_code}' -L --max-time 25 "$u" || echo 000) - case "$code" in 2*|3*) break ;; esac - sleep 3 - done - case "$code" in - 2*|3*) printf ' ok %s %s\n' "$code" "$u" ;; - *) printf ' FAIL %s %s\n' "$code" "$u"; fail=1 ;; - esac - done <<< "$urls" - test "$fail" -eq 0 || { echo "::error::at least one link or image does not resolve"; exit 1; } + env: + GOWORK: "off" + run: go run github.com/go-fleettools/landingkit/cmd/landingkit links public