Skip to content

ci/redirects: Add Redirect check for PRs - #1880

Closed
marcleblanc2 wants to merge 3 commits into
mainfrom
check-redirects
Closed

ci/redirects: Add Redirect check for PRs#1880
marcleblanc2 wants to merge 3 commits into
mainfrom
check-redirects

Conversation

@marcleblanc2

@marcleblanc2 marcleblanc2 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Linear FE-499: Fix doc site issues

Stacked on #1858 (base branch check-links-pr-check); merge that one first.

Problem

  • src/data/redirects.ts has ~900 entries that don't work: destination pages that no longer exist, #fragments in the source (browsers never send them, so the entry can never match), duplicates of an earlier source, chains to other redirects, /docs/ prefixes
  • Nothing checks the file, so PRs keep adding broken redirects, and PRs that move a page or rename a heading silently break the redirects pointing at it

Solution

  • dev/check-redirects.mjs validates every entry against the pages and headings in docs/
  • "Check redirects" PR check runs the script on the PR head and its merge base, and reports only what the PR introduced; the ~900 pre-existing problems are ignored
  • Runs in parallel with "Check links"
  • The comment groups findings by problem, and each section says how to fix its entries, so authors learn how to write a correct redirect:
    • Source overshadows a docs page that exists
    • Source has a #fragment, so this redirect can never match
    • Source or destination starts with /docs
    • Source already has an earlier entry, so this one is never used
    • Destination is another redirect (shows the final destination)
    • Destination page does not exist
    • Destination heading does not exist
  • Line numbers link to the entry in redirects.ts on the PR branch
  • The comment is created / updated in place, and once the PR is fixed, the PR check passes and the comment is updated to say so
  • A PR that never broke anything gets no comment
  • pnpm check-redirects runs it locally

Verification

PR check comment in test PR: #1896 (comment)

Check redirects PR comment listing 8 broken redirects grouped by problem

Related

Amp threads

Merge order for the PR-check stack

Trial-merged onto main in this order with no conflicts:

  1. ci: Comment the Vercel build log on PRs whose build fails #1918 Vercel build log comment — independent; first so the other PRs' Vercel failures get a readable log
  2. check-links: one suggestion per fix, synced with findings; one fact per line in reports #1916 check-links report format — adds dev/sync-review-comments.sh, which ci/redirects: Add Redirect check for PRs #1880 calls
  3. ci/redirects: Add Redirect check for PRs #1880 redirect check — needs check-links: one suggestion per fix, synced with findings; one fact per line in reports #1916 merged first
  4. spell check: update inline comments whose text changed #1919 spell check comment updates — independent
  5. check-links: don't fail the generated-docs sync PR over absolute self-links it can't fix #1910 check-links, generated-docs sync PR — conflicts with check-links: one suggestion per fix, synced with findings; one fact per line in reports #1916 on dev/check-links.mjs; rebase after check-links: one suggestion per fix, synced with findings; one fact per line in reports #1916 merges

Squash-merge each, then rebase the next onto main.

#1920 (broken) and #1921 (fixed) are the example PRs that exercise every check; never merge, close them once the stack has landed.

@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sourcegraph-docs Ready Ready Preview Sep 11, 2026 3:08pm UTC

Request Review

@marcleblanc2 marcleblanc2 changed the title ci: fail PRs that break redirects ci: Fail PRs that break redirects Sep 9, 2026
@marcleblanc2 marcleblanc2 changed the title ci: Fail PRs that break redirects ci/redirects: Add PR check for broken redirects Sep 9, 2026
@marcleblanc2 marcleblanc2 changed the title ci/redirects: Add PR check for broken redirects ci/redirects: Add Redirect check for PRs Sep 10, 2026
@marcleblanc2
marcleblanc2 changed the base branch from main to check-links-pr-check September 10, 2026 03:26
@marcleblanc2
marcleblanc2 force-pushed the check-links-pr-check branch 2 times, most recently from 953692f to 492b425 Compare September 11, 2026 01:34
Base automatically changed from check-links-pr-check to main September 11, 2026 01:36
dev/check-redirects.mjs checks every entry in src/data/redirects.ts:
source shadows a page, source has a #fragment, duplicate source,
/docs prefix, chained redirect, missing destination page or heading.
The workflow compares against the merge base, so only redirects a PR
breaks are reported, grouped by problem with the fix explained under
each heading, and posts one suggested change per fixable entry the PR
added (deleted again once the finding is gone).

Not part of `npm run check`: main has hundreds of pre-existing
findings.

Squash of the check-redirects branch rebased onto main; the check-links
commits it carried are already on main.

Amp-Thread-ID: https://ampcode.com/threads/T-01a08fee-74b4-76dc-aaf9-d1245d68fdc9
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

This comment has been minimized.

@marcleblanc2

Copy link
Copy Markdown
Contributor Author

Moved to #1935 (branch renamed to marc/check-redirects).

@marcleblanc2
marcleblanc2 deleted the check-redirects branch September 11, 2026 17:27
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