Skip to content

Fix linkcheck false positives from the gh-pages migration - #215

Merged
mmcky merged 3 commits into
mainfrom
fix-linkcheck-false-positives
Jul 7, 2026
Merged

mmcky merged 3 commits into
mainfrom
fix-linkcheck-false-positives

Conversation

@mmcky

@mmcky mmcky commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

What

Fixes the noisy link-check reports (e.g. #214) introduced by the gh-pages migration (#213). Follow-up to that PR.

The regression

Migration PR #213 switched the link checker from checking out the gh-pages branch to a wget mirror of the live site. Two problems came from that:

  1. wget --accept html fetches only HTML — none of the _static/* CSS/JS, _images/*, _pdf/, or _notebooks/ assets. lychee then checked those relative links as local files and reported them all as "Cannot find file". (The old gh-pages checkout had the whole site, assets included, so they resolved.)
  2. --accept 403,503 dropped 200 — so every working link, including the site's own pages, was flagged as "Rejected status code: 200".

Net effect in #214: 522 "errors" out of 1000, essentially all false positives — 0 real broken links, 0 timeouts. For comparison, the last pre-migration run (#212) reported 37 errors out of 1109.

Error category in #214 Count Real?
"Cannot find file" (assets not mirrored) 190 ❌
"Rejected status code: 200" (accept list) 171 ❌
"Error building URL" (root-relative links) 20 ❌

The fix

Check links against the published HTML release asset — a permanent .tar.gz of the full site (HTML plus all assets) that the publish workflow now attaches to each publish-* release. This is the approach recommended in QuantEcon/meta#282 (lesson 2) and already used by lecture-python-programming.

  • Download + extract continuous-time-mcs-html-*.tar.gz from the latest release into _site (replaces the wget mirror). No dependency on the live site being reachable at check time.
  • Restore --accept 200,403,503 so working links pass.
  • Add --root-dir so root-relative links (/_notebooks/*.ipynb, /_pdf/book.pdf) resolve against the extracted site root.
  • Keep the empty-input guard (now "release asset missing") and the peter-evans/create-issue-from-file reporting.

After this, a run should surface only genuine link issues (on the order of #212's ~37), not the ~485 false positives.

Related

  • Supersedes the false-alarm report in Link Checker Report #214 (safe to close).
  • lecture-dp uses the same wget-mirror linkcheck pattern and has the same latent issue — worth the same fix in a separate PR.

🤖 Generated with Claude Code

The artifact migration (#213) switched linkcheck from checking out the
gh-pages branch to a wget mirror of the live site. That mirror fetches
only HTML (--accept html), so lychee reported every local asset
(_static/*, _images/*) as "file not found"; the deploy also dropped 200
from --accept, so every working link (200) was flagged. Net result was
issue #214: 522 "errors" that were essentially all false positives
(0 real broken links, 0 timeouts).

Switch to checking the published HTML release asset instead — a permanent
tarball of the full site (HTML + assets), per QuantEcon/meta#282 lesson 2
and matching lecture-python-programming's linkcheck. Restore
--accept 200,403,503 and add --root-dir so root-relative links
(/_notebooks/*.ipynb, /_pdf/book.pdf) resolve against the site root. The
release-asset input also removes the dependency on the live site being
reachable at check time.

See QuantEcon/meta#282

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 7, 2026 06:09
@netlify

netlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for adorable-cucurucho-69162b ready!

Name Link
🔨 Latest commit 29ed8e3
🔍 Latest deploy log https://app.netlify.com/projects/adorable-cucurucho-69162b/deploys/6a4c9b31235d780007a0dc06
😎 Deploy Preview https://deploy-preview-215--adorable-cucurucho-69162b.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for sparkly-moxie-de1f0e ready!

Name Link
🔨 Latest commit 29ed8e3
🔍 Latest deploy log https://app.netlify.com/projects/sparkly-moxie-de1f0e/deploys/6a4c9b31a936b50008be351b
😎 Deploy Preview https://deploy-preview-215--sparkly-moxie-de1f0e.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the repository’s GitHub Actions link-check workflow to avoid false positives introduced by the recent GitHub Pages deployment migration, by checking links against the published site HTML release asset rather than a partial wget mirror of the live site.

Changes:

  • Download and extract the latest published HTML release tarball into _site (instead of mirroring the live site with wget).
  • Restore --accept 200,403,503 so successful links (200) are not incorrectly flagged as failures.
  • Add --root-dir so root-relative links (e.g. /_pdf/..., /_notebooks/...) resolve correctly against the extracted site tree.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/linkcheck.yml Resolved
The recursive glob also scanned _site/_static/webpack-macros.html, a Sphinx
theme partial containing raw Jinja (`{{ pathto(...) }}`) that lychee misread
as ~15 broken local links. Restrict to top-level '_site/*.html' — matching the
old checkout's '*.html' scope — so only real lecture pages are checked.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@mmcky

mmcky commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Validated on the PR branch via workflow_dispatch (two runs):

  • Before (buggy wget-mirror, Link Checker Report #214): 522 errors / 1000 — essentially all false positives (0 real broken links, 0 timeouts).
  • After release-tarball input + --accept 200,403,503 + --root-dir: 20 errors.
  • After also restricting to top-level _site/*.html (skipping the _static/webpack-macros.html theme partial): 6 errors / 1109, all genuine.

The 6 remaining are real dangling links in the built site, not config artifacts: the auto-generated utility pages (genindex, prf-prf, search) link to _notebooks/*.ipynb that are never built, plus a None href on those pages. No linkcheck-config false positives remain. Validation run: 28845629158.

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Under `set -eo pipefail`, a transient `gh api` failure aborted the fetch step
before the empty-input guard ran, so no 'release asset missing' report was
created. Add `|| true` (and silence stderr) so the guard still fires.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
mmcky added a commit to QuantEcon/lecture-dp that referenced this pull request Jul 7, 2026
Under `set -eo pipefail`, a transient `gh api` failure aborted the fetch step
before the empty-input guard ran, so no 'release asset missing' report was
created. Add `|| true` (and silence stderr) so the guard still fires.

Mirrors QuantEcon/continuous_time_mcs#215 (Copilot review follow-up).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions
github-actions Bot temporarily deployed to pull request July 7, 2026 06:28 Inactive
@mmcky
mmcky merged commit d65698f into main Jul 7, 2026
7 checks passed
@mmcky
mmcky deleted the fix-linkcheck-false-positives branch July 7, 2026 10:49
mmcky added a commit to QuantEcon/lecture-dp that referenced this pull request Jul 7, 2026
* Fix linkcheck false positives (release-asset input, accept 200)

lecture-dp's link checker mirrored the live site with `wget --accept html`,
which fetches only HTML — so lychee reported every local asset (_static/*,
_images/*) as "file not found" — and used `--accept 403,503`, which drops 200
so every working link was flagged.

Check the published HTML release asset instead — a permanent tarball of the
full site (HTML + assets), per QuantEcon/meta#282 lesson 2 and matching
lecture-python-programming. Restore `--accept 200,403,503`, add `--root-dir`
for root-relative links, and scan only top-level `_site/*.html` so the Sphinx
theme partials under _static/ (raw Jinja, not real links) are skipped.

Mirrors the fix in QuantEcon/continuous_time_mcs#215.

See QuantEcon/meta#282

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Make release-asset fetch non-fatal

Under `set -eo pipefail`, a transient `gh api` failure aborted the fetch step
before the empty-input guard ran, so no 'release asset missing' report was
created. Add `|| true` (and silence stderr) so the guard still fires.

Mirrors QuantEcon/continuous_time_mcs#215 (Copilot review follow-up).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* Harden release-asset extract against partial downloads (Copilot review)

A failed or truncated `curl | tar` was swallowed by `|| true`, potentially
leaving a partial _site tree where count > 0 — so lychee would run against an
incomplete site and re-introduce 'file not found' false positives. Use `curl
-f` and an `if !` guard that clears _site on failure, so a bad download is
treated as 'no usable asset' and reported via the guard.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

This branch was previously deployed

1 inactive deployment
pull request — 29ed8e32 Deployed Jul 7, 2026 by github-actions[bot]
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.

2 participants