[pre-commit] Add lychee markdown link checker at the manual stage - #7323
Merged
Conversation
Adds the lychee hook from lycheeverse/lychee, confined to the manual stage: two of the three links it reports are rewritten by open pull requests (ROCm#7253, ROCm#4685), so at the default stage the existing pre-commit CI job would fail on every PR until those land. No exclude is added; .pre-commit-config.yaml:4 already carries a global exclude for third_party/. Also fixes external-builds/pytorch/README.md:199, the one reported link with no open pull request touching that line, and documents the manual invocation in CONTRIBUTING.md.
✅ All Policy Checks Passed
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Follow-up to #7294, where the request was for an off-the-shelf markdown link
checker rather than fixing broken links one instance at a time.
Technical Details
Three changes:
.pre-commit-config.yaml— thelycheeblock exactly as written in#7294,
plus
stages: [manual].external-builds/pytorch/README.md:199— one leading/. The sibling linktwo lines below at
:201already has it.CONTRIBUTING.md— the manual invocation, added to the existing#### pre-commit checksexample block.No
excludeis needed..pre-commit-config.yaml:4already carries a globalexclude: "third_party/", which coversbuild_tools/third_party/. That is thewhole of the 3-vs-4 discrepancy: my 4 came from running the
lycheebinarydirectly over the tree, which applies no pre-commit file filtering; the 3 came
through
pre-commit, which does. My earlier claim that theimpliblink "needsan exclude or the hook stays red" was wrong.
Why
stages: [manual]Because two of the three links it reports cannot be fixed here — open pull
requests rewrite both lines — so at the default stage the existing
.github/workflows/pre-commit.ymljob would fail on every PR until they land.docs/development/README.md:24@@ -17,11 +17,11 @@deletes that exact linedocs/development/workflow_outputs.md:305@@ -295,15 +295,15 @@rewrites that exact lineexternal-builds/pytorch/README.md:199190-195and #7313180-185Hunk ranges are from each PR's combined diff against its own merge base. The
scan covered all 481 open PRs.
What
stages: [manual]actually doesIt skips the binary install, not the hook repo clone. Each row is a fresh
PRE_COMMIT_HOME:lycheebinary installedpre-commit install-hookspre-commit runpre-commit run --all-filespre-commit run --hook-stage manual --all-filesstages: [manual],pre-commit run --all-filesSo the
cargostep you had to approve is skipped on commit and in CI; the7.4 MB
git cloneoflycheeverse/lycheestill happens on any firstpre-commitinvocation, includinginstall-hooks.Separately: the
lycheehook id bootstrapped fine here on a clean cache — itfetches
cargo-binstalland a prebuilt binary, no pre-existingcargoneeded.My earlier report that it failed to bootstrap was a network restriction on my
side, not the hook.
Test Plan
pre-commit4.6.2, Python 3.12.10, Windows 11, at47947a1. Each run used anisolated
PRE_COMMIT_HOME. Linux and macOS were not exercised.Test Result
Default stage, whole config, whole tree — what CI runs.
lycheeis absent fromthe list, and the run is green:
Manual stage, after the
external-builds/pytorch/README.mdfix — 3 errors downto 2, and the OK count moves 506 → 507:
The
third_partyA/B, deleting only line 4 of.pre-commit-config.yamlandchanging nothing else:
If you want the class actually gated rather than merely available, the existing
pre-commitjob takes it in three lines — but only once the two links above areresolved, since it would be red until then:
Happy to send that as a follow-up after #7253 lands.
Submission Checklist