diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index f6876b5ba..04375806f 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -81,3 +81,24 @@ jobs: [[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "::error::no commit from https://api.visualci.com/status"; exit 1; } trivy image --scanners vuln --ignore-unfixed --severity HIGH,CRITICAL --exit-code 1 --ignorefile .trivyignore.yaml \ "ghcr.io/docspring/visualci-app:$commit" + + # Every link on the live site, outside ones included (lychee.toml), daily and by hand: CI checks the site's own links + # offline, so a page someone else moved or took down turns up here. + links: + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + with: + persist-credentials: false + - uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0 + with: + install_args: lychee + # The pages from the live sitemap. GITHUB_TOKEN keeps lychee's github.com checks inside the API's rate limit. + - env: + GITHUB_TOKEN: ${{ github.token }} + run: | + curl -fsS --retry 3 --max-time 20 https://visualci.com/sitemap.xml | grep -o '[^<]*' | cut -c6- >pages.txt + [ -s pages.txt ] || { echo "::error::no pages in https://visualci.com/sitemap.xml"; exit 1; } + lychee --format compact --files-from pages.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f95eebf0..14a8a1fe3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -627,6 +627,19 @@ jobs: env: GITHUB_TOKEN: ${{ github.token }} VISUALCI_REQUIRE_WASM: "1" + # Every page, file and #anchor the site links to is in the build, its absolute https://visualci.com/ links + # included (lychee.toml; offline, so an outside site never fails a build: the Audit workflow checks those nightly). + - uses: jdx/mise-action@924e7c586e33d7d4bae9c14e26c5d22e2beb6e78 # v5.3.0 + with: + install_args: lychee + # The pages, their Markdown copies and llms.txt. The site's own absolute links point at the build; a Markdown copy's + # #anchor (an HTML page's id) is dropped, since a Markdown heading has none (one remap applies per link: first wins). + - run: | + site=$PWD/frontend/dist-site + lychee --offline --root-dir "$site" --format compact \ + --remap "^https?://(www\.)?visualci\.com/([^#]+\.md)#.*\$ file://$site/\$2" \ + --remap "^https?://(www\.)?visualci\.com/?(.*)\$ file://$site/\$2" \ + "$site/**/*.html" "$site/**/*.md" "$site/llms.txt" "$site/llms-full.txt" - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: dist-site diff --git a/AGENTS.md b/AGENTS.md index 21aff261b..572c2d92d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,10 @@ design is in `docs/design.md`; read it before changing the architecture, and upd cap, never raise a cap, and delete its line once it's under the limit. **Every lint suppression** (`#[allow(...)]`, `@ts-expect-error`, `# noqa`, a zizmor ignore and the rest) is listed in `scripts/ci/suppressions.txt` with its reason, added in the change that adds it (`scripts/ci/check_suppressions.py`). Fix what a lint finds before you - reach for a suppression. Allow a word or turn a lint rule off for a file only in those + reach for a suppression. +- **Links are checked** by lychee (`lychee.toml`): CI's `clients` job checks every page, file and `#anchor` the built + site links to, offline, so a broken internal link fails the build that makes it. The Audit workflow checks every link + 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 files, with the reason beside it. Pin every action by commit SHA with its version in a comment (`pinact run` does it). Ignore a zizmor finding only inline (`# zizmor: ignore[audit]`) with the reason beside it; allow a made-up value in `.betterleaks.toml` only with a description of what it is. A real secret that reached a commit is revoked, diff --git a/frontend/public/ci.md b/frontend/public/ci.md index b02693ba7..8e6ab535d 100644 --- a/frontend/public/ci.md +++ b/frontend/public/ci.md @@ -19,7 +19,7 @@ visualci build finalize when `VISUALCI_TOKEN` is empty (pull requests from forks). - **CircleCI:** https://visualci.com/docs/ci/circleci.md - **GitLab CI:** https://visualci.com/docs/ci/gitlab.md -- **Buildkite, Jenkins, Bitbucket, Semaphore, TeamCity, Travis:** https://visualci.com/docs/ci/.md +- **Buildkite, Jenkins, Bitbucket, Semaphore, TeamCity, Travis:** `https://visualci.com/docs/ci/.md` (`buildkite`, `jenkins`, `bitbucket`, `semaphore`, `teamcity`, `travis`) - **Anything else:** https://visualci.com/docs/ci/other.md Parallel jobs share one build: `visualci build create --nonce --shards `, and each job runs diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 000000000..89b348cd1 --- /dev/null +++ b/lychee.toml @@ -0,0 +1,20 @@ +# lychee (links), run by CI's clients job over the built site (offline: every page, file and #anchor the site links +# to, its own https://visualci.com/ links included) and nightly by the Audit workflow over the live site (every link, +# outside ones too). mise.toml pins it. Exclude a link here only with the reason beside it. +include_fragments = "full" +# Pages are folders with an index.html (/docs/agents/ is docs/agents/index.html). +index_files = ["index.html"] +no_progress = true +max_concurrency = 8 +exclude = [ + # Sign-in pages and API endpoints answer only signed-in or API requests. The app's public pages (galleries, the + # demo) are still checked. + '^https://app\.visualci\.com/(auth|api|oauth)/', + '^https://(api|mcp)\.visualci\.com', +] +remap = [ + # GitHub builds a repository page's #readme anchor in JavaScript, so it's never in the HTML lychee reads. + '^(https://github\.com/[^#]+)#readme$ $1', + # The Markdown copies (for agents) link anchors by their HTML pages' ids, which a Markdown heading doesn't have. + '^(https://visualci\.com/[^#]+\.md)#.*$ $1', +] diff --git a/mise.toml b/mise.toml index a7396b97b..9e0ea5628 100644 --- a/mise.toml +++ b/mise.toml @@ -12,3 +12,4 @@ trivy = "0.77.0" hadolint = "2.15.1" typos = "1.53.0" oxlint = "1.96.0" +lychee = "0.24.2"