Skip to content

Replace htmltest with Lychee for link checking - #2665

Merged
chalin merged 11 commits into
docsy:mainfrom
chalin:chalin-m24-lychee-docsy-2026-0626
Jun 26, 2026
Merged

chalin merged 11 commits into
docsy:mainfrom
chalin:chalin-m24-lychee-docsy-2026-0626

Conversation

@chalin

@chalin chalin commented Jun 26, 2026 •

Copy link
Copy Markdown
Collaborator
  • Switches docsy.dev link checking from the unmaintained htmltest to Lychee
  • Adds the Lychee setup:
    • Runs a wrapper (scripts/check-links-lychee.sh) over the built site, bridging gh's token into GITHUB_TOKEN so local runs aren't GitHub-throttled.
    • Ports .htmltest.yml into lychee.toml, keeping full fragment checking (include_fragments + index_files) for parity.
    • Commits a seeded .lycheecache (938 OK entries) and a test:lychee sanity suite (10 tests).
  • Removes htmltest and its artifacts: .htmltest.yml, refcache.json, the prune/unescape/matrix scripts, and the make link targets.
  • Temporary excludes: a marked lychee.toml block excludes 55 externals broken by upstream restructures (GitHub theme-paths, gohugo.io anchors, Google SEO, Mermaid); their fixes are partitioned onto a follow-up content-only branch, and the block is removed once that lands.
  • Validates the result: full online run = 0 errors; test:lychee 10/10; build, format, and markdownlint clean.

chalin added 7 commits June 26, 2026 11:54
- Adds tests/lychee (run via test:lychee) that pin the behavior the htmltest to Lychee switch depends on: Lychee is installed, and local paths, local fragments, external URLs, and external fragments each pass and fail as expected.
- Targets docsy.dev for the external cases -- a site we control -- with a canary that fails loudly if the referenced page or anchor ever moves; set LYCHEE_SANITY_NO_NET=1 to skip the network cases.
- Encodes the offline pretty-URL fragment gap as a todo test (Lychee resolves /foo/ to the directory, not foo/index.html, when scanning anchors), so the suite documents the limitation now and flips green once Lychee fixes it.
- Replaces the pretty-URL fragment todo with two passing tests: one proving `--index-files index.html` resolves a Hugo pretty-URL directory link for offline fragment checks, and one guarding the failure mode without the flag (so a future lychee that resolves indexes by default becomes a visible signal).
- The fix matches otel.io's generated lychee.toml (`include_fragments` + `index_files`); offline pretty-URL fragments were never a real blocker, just a missing config option.
- Removes redundant comments that the test names and the thoughtry tracker already convey, keeping only the non-obvious `--index-files` note.
- Adds `docsy.dev/lychee.toml`, ported from `.htmltest.yml` (excludes and
  fragment checking via `include_fragments`/`index_files`); an offline run over
  the built site reaches full htmltest parity (0 errors).
- Adds `scripts/check-links-lychee.sh`, which resolves the absolute `public/`
  path and bridges a `GITHUB_TOKEN` from `gh` when unset, and wires the
  `check:links:lychee` npm scripts (`:internal` runs offline). htmltest stays
  the default checker for now.
Make Lychee the sole link checker for docsy.dev, dropping htmltest and its
caching artifacts (the prior commit added the Lychee config and run script
alongside htmltest).

- Point `_check:links` and `check:links:internal` at the Lychee wrapper, and
  remove the htmltest plumbing: `.htmltest.yml`, the `make`-based targets, the
  committed `refcache.json`, and the `prune:refcache`, refcache-unescape, and
  full-vs-lean matrix scripts.
- Extend `lychee.toml` excludes to reach a clean run: the per-page provenance
  `commit/` links htmltest skipped via `data-proofer-ignore`; bot-walled hosts
  (npmjs, Algolia) and SPA fragment routes (Prism builder hash, AWS signup); and
  a temporary block, to remove after 0.16.0 ships, for the unreleased tag and
  the version dropdown's links to pages new or draft this cycle.
- Ignore `lychee.toml` in Prettier (no TOML parser) and drop a stale htmltest
  mention in a fixture-site test comment.
Commit a pre-warmed `.lycheecache` (938 OK entries) so CI and local
runs skip re-checking known-good external links within `max_cache_age`.
A later housekeeping workflow will refresh it periodically.
The fixes for 55 externals broken by upstream restructures (GitHub
theme-paths, gohugo.io anchors, Google SEO, Mermaid) live on a parked
branch (chalin-m24-docsy-link-rot-2026-0626) to keep this PR tooling-only.
Exclude them here so the online link check stays green until that branch
lands; the marked block is removed once it does.
@chalin chalin added this to the 0.16.0 milestone Jun 26, 2026
chalin added 4 commits June 26, 2026 15:35
Adds a pinned lychee install step to the test workflow: the switch dropped htmltest's Makefile auto-install, but the new wrapper expects `lychee` on PATH, so the blocking online link check (ci:test, Linux only) failed with "lychee not found".
Fetches the release binary directly (lychee-action's installer can't handle the versioned tarball layout) into `$HOME/.local/bin` and adds it to `GITHUB_PATH`; gated to the Linux runner since Windows doesn't run the check.
- lychee writes .lycheecache in a nondeterministic order, so a CI link check rewrites the committed cache and the post-test clean-tree check (_diff:check) fails on the dirty file.
- Sort the cache after each run in the run wrapper and commit it sorted, so warm reruns yield a byte-identical file; a genuinely new uncached URL still changes the cache, which usefully flags a coverage gap.
- Pass GITHUB_TOKEN inline to lychee instead of exporting it, so a token bridged from gh never lingers in the script's environment (e.g. for the later cache-sort step).
- Generalize the header comment so the wrapper reads repo-agnostically, ahead of a planned generic version usable by any repo.
@chalin
chalin merged commit 09443ba into docsy:main Jun 26, 2026
16 checks passed
@chalin
chalin deleted the chalin-m24-lychee-docsy-2026-0626 branch June 26, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant