Repository navigation
Commit fed1673
ci/redirects: Add Redirect check for PRs (#1935)
Linear [FE-499: Fix doc site
issues](https://linear.app/sourcegraph/issue/FE-499/fix-doc-site-issues)
## 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)
<img width="1000" alt="Check redirects PR comment listing 8 broken
redirects grouped by problem"
src="https://ampcode.com/user-content/artifacts/a074bef7c771368ba56da54a9e62f9a41cef9402a064594646cd3e8b0fa6c166-file.png"
/>
## Related
- #1858 added the "Check links" PR check this is built on; #1916 added
`dev/sync-review-comments.sh`, which this check calls
## Amp threads
- [Redirect list
cleanup](https://ampcode.com/threads/T-01a07e6f-db41-74af-bbeb-f8952e637289)
- [Redirect check PR
comment](https://ampcode.com/threads/T-01a088d9-b8fd-76fd-ba93-3a416c5829a3)
---------
Co-authored-by: Amp <amp@ampcode.com>1 parent bd1d86d commit fed1673
4 files changed
Lines changed: 621 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
0 commit comments