Skip to content

Commit 6c447fa

Browse files
committed
Links: lychee checks the built site's own links and anchors offline in CI, and every live link nightly (sc-9611)
1 parent ba9bbe6 commit 6c447fa

5 files changed

Lines changed: 51 additions & 1 deletion

File tree

‎.github/workflows/audit.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,24 @@ jobs:
8181
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::no commit from https://api.visualci.com/status"; exit 1; }
8282
trivy image --scanners vuln --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml \
8383
"ghcr.io/docspring/visualci-app:$commit"
84+
85+
# Every link on the live site, outside ones included (lychee.toml), daily and by hand: CI checks the site's own links
86+
# offline, so a page someone else moved or took down turns up here.
87+
links:
88+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
89+
runs-on: ubuntu-latest
90+
timeout-minutes: 15
91+
steps:
92+
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
93+
with:
94+
persist-credentials: false
95+
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
96+
with:
97+
install_args: lychee
98+
# The pages from the live sitemap. GITHUB_TOKEN keeps lychee's github.com checks inside the API's rate limit.
99+
- env:
100+
GITHUB_TOKEN: ${{ github.token }}
101+
run: |
102+
curl -fsS --retry 3 --max-time 20 https://visualci.com/sitemap.xml | grep -o '<loc>[^<]*' | cut -c6- >pages.txt
103+
[ -s pages.txt ] || { echo "::error::no pages in https://visualci.com/sitemap.xml"; exit 1; }
104+
lychee --format compact --files-from pages.txt

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,15 @@ jobs:
615615
env:
616616
GITHUB_TOKEN: ${{ github.token }}
617617
VISUALCI_REQUIRE_WASM: "1"
618+
# Every page, file and #anchor the site links to is in the build, its absolute https://visualci.com/ links
619+
# included (lychee.toml; offline, so an outside site never fails a build: the Audit workflow checks those nightly).
620+
- uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0
621+
with:
622+
install_args: lychee
623+
- run: |
624+
site=$PWD/frontend/dist-site
625+
lychee --offline --root-dir "$site" --remap "^https://visualci\.com/?(.*)\$ file://$site/\$1" --format compact \
626+
'frontend/dist-site/**/*.html'
618627
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
619628
with:
620629
name: dist-site

‎AGENTS.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ design is in `docs/design.md`; read it before changing the architecture, and upd
2626
cap, never raise a cap, and delete its line once it's under the limit. **Every lint suppression** (`#[allow(...)]`,
2727
`@ts-expect-error`, `# noqa`, a zizmor ignore and the rest) is listed in `scripts/ci/suppressions.txt` with its
2828
reason, added in the change that adds it (`scripts/ci/check_suppressions.py`). Fix what a lint finds before you
29-
reach for a suppression. Allow a word or turn a lint rule off for a file only in those
29+
reach for a suppression.
30+
- **Links are checked** by lychee (`lychee.toml`): CI's `clients` job checks every page, file and `#anchor` the built
31+
site links to, offline, so a broken internal link fails the build that makes it. The Audit workflow checks every link
32+
on the live site, outside ones included, each night. Exclude a link in `lychee.toml` only with the reason beside it. Allow a word or turn a lint rule off for a file only in those
3033
files, with the reason beside it. Pin every action by commit SHA with its version in a comment (`pinact run` does
3134
it). Ignore a zizmor finding only inline (`# zizmor: ignore[audit]`) with the reason beside it; allow a made-up
3235
value in `.betterleaks.toml` only with a description of what it is. A real secret that reached a commit is revoked,

‎lychee.toml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# lychee (links), run by CI's clients job over the built site (offline: every page, file and #anchor the site links
2+
# to, its own https://visualci.com/ links included) and nightly by the Audit workflow over the live site (every link,
3+
# outside ones too). mise.toml pins it. Exclude a link here only with the reason beside it.
4+
include_fragments = "full"
5+
# Pages are folders with an index.html (/docs/agents/ is docs/agents/index.html).
6+
index_files = ["index.html"]
7+
no_progress = true
8+
max_concurrency = 8
9+
exclude = [
10+
# The app, API and MCP hosts answer only signed-in or API requests (the site links their sign-in and endpoints).
11+
'^https://(app|api|mcp)\.visualci\.com',
12+
]
13+
remap = [
14+
# GitHub builds a repository page's #readme anchor in JavaScript, so it's never in the HTML lychee reads.
15+
'^(https://github\.com/[^#]+)#readme$ $1',
16+
]

‎mise.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ trivy = "0.77.0"
1212
hadolint = "2.15.1"
1313
typos = "1.53.0"
1414
oxlint = "1.96.0"
15+
lychee = "0.24.2"

0 commit comments

Comments
 (0)