Skip to content

Commit afaee3d

Browse files
authored
dev: include Markdown link checks in the local lint suite (#25287)
## Which issue does this PR close? - Part of #21048. The issue stays open for the other checklist items. ## Rationale for this change `dev/rust_lint.sh` is the local mirror of the CI lint jobs, but it does not run the Markdown link check. CI runs `ci/scripts/markdown_link_check.sh` in `dev.yml`. A developer can push a broken internal link after a clean local lint run and then see the failure only in CI. This PR adds the existing checker to the local suite. ## What changes are included in this PR? - `dev/rust_lint.sh` runs `ci/scripts/markdown_link_check.sh` as a read-only step, after the workflow install check and before the Rust documentation build. The `--write` and `--allow-dirty` flags never reach it. - The runner loads `LYCHEE_VERSION` from `ci/scripts/utils/tool_versions.sh` and installs that version when `lychee` is missing. An installed `lychee` is used as is, which is the runner's existing policy for other tools. - `ci/scripts/markdown_link_check.sh` becomes executable, because the runner invokes each registered script directly. The script body, `lychee.toml`, the file selection, and the GitHub workflow do not change. - `docs/source/contributor-guide/testing.md` documents the new behavior and keeps the standalone instructions. ## What is the testing strategy for this PR? - A disposable fixture with stubbed steps and tools: the checker runs once with no arguments in check mode and in both write modes, a missing `lychee` triggers exactly the pinned install command, a present `lychee` triggers no install, and a checker failure stops the suite before the later steps. - A disposable clone with an injected broken internal link: the standalone checker and `./dev/rust_lint.sh` both fail with the same exit code and name the file. After the fix, the full suite passes. - The real checker and the full `./dev/rust_lint.sh` pass on this branch with `lychee` 0.23.0. ## Are there any user-facing changes? No. Developers get the link check in the local lint suite. CI is unchanged. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
1 parent 22cf99d commit afaee3d

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎ci/scripts/markdown_link_check.sh‎

100644100755
File mode changed.

‎dev/rust_lint.sh‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
#
2323
# Note: The installed checking tools (e.g., taplo) are not guaranteed to match
2424
# the CI versions for simplicity, there might be some minor differences. Check
25-
# `.github/workflows` for the CI versions.
25+
# `.github/workflows` for the CI versions. When this script installs a missing
26+
# tool that has a pinned version in `ci/scripts/utils/tool_versions.sh`, it
27+
# installs that pinned version. An already installed tool is used as is.
2628
#
2729
#
2830
#
@@ -84,10 +86,15 @@ while [[ $# -gt 0 ]]; do
8486
done
8587

8688
SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")"
89+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
90+
91+
# Load the tool versions shared with CI (for example, LYCHEE_VERSION).
92+
source "${SCRIPT_DIR}/../ci/scripts/utils/tool_versions.sh"
8793

8894
ensure_tool "taplo" "cargo install taplo-cli --locked"
8995
ensure_tool "hawkeye" "cargo install hawkeye --locked"
9096
ensure_tool "typos" "cargo install typos-cli --locked"
97+
ensure_tool "lychee" "cargo install lychee --locked --version ${LYCHEE_VERSION}"
9198

9299
run_step() {
93100
local name="$1"
@@ -107,6 +114,7 @@ declare -a WRITE_STEPS=(
107114

108115
declare -a READONLY_STEPS=(
109116
"ci/scripts/check_no_cargo_install_in_workflows.sh|false"
117+
"ci/scripts/markdown_link_check.sh|false"
110118
"ci/scripts/rust_docs.sh|false"
111119
)
112120

‎docs/source/contributor-guide/testing.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ tested in the same way using the [doc_comment] crate. See the end of
188188

189189
## Documentation Link Checks
190190

191-
Run the internal markdown link check locally:
191+
`./dev/rust_lint.sh` runs the internal markdown link check. If `lychee` is
192+
missing, the script installs the version pinned in
193+
`ci/scripts/utils/tool_versions.sh`. It uses an existing installation as is,
194+
even if the version differs from the pin.
195+
196+
To run the check on its own:
192197

193198
```shell
194199
source ci/scripts/utils/tool_versions.sh
@@ -200,6 +205,7 @@ Notes:
200205

201206
- The script is run with `bash` and is compatible with the default Bash on macOS (no `mapfile` dependency).
202207
- The CI configuration currently checks internal markdown links only. External `http(s)` and `mailto` links are excluded to avoid flaky failures.
208+
- The check only reports broken links. `./dev/rust_lint.sh --write` does not change them.
203209

204210
When a link is broken, lychee prints the file and URL/path that failed. For example:
205211

0 commit comments

Comments
 (0)