From d31acaa26a089ffa17158fe82dd0d6d43d2bacd8 Mon Sep 17 00:00:00 2001 From: Joshua Hoblitt Date: Tue, 14 Jul 2026 13:17:47 -0700 Subject: [PATCH] ci: check the links in AGENTS.md `AGENTS.md` is almost entirely links into `Documentation/`, which is what keeps it from duplicating the documentation and drifting away from it. That only works while the links resolve, and nothing checked them: the link checker walks `Documentation/` alone, so a moved page would leave `AGENTS.md` pointing at nothing and silently misdirect its reader. Include it in the files the link checker walks. The other markdown files in the repository root are left out on purpose. Several of them already contain dead external links, and adding them here would fail the nightly job for reasons unrelated to this change. Signed-off-by: Joshua Hoblitt (cherry picked from commit 9277239590c75ef8987fe35fcf252b8d5ce6f177) # Conflicts: # tests/scripts/check-markdown-links-internal.sh --- .../scripts/check-markdown-links-internal.sh | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 tests/scripts/check-markdown-links-internal.sh diff --git a/tests/scripts/check-markdown-links-internal.sh b/tests/scripts/check-markdown-links-internal.sh new file mode 100755 index 000000000..bc21f42b2 --- /dev/null +++ b/tests/scripts/check-markdown-links-internal.sh @@ -0,0 +1,60 @@ +#!/usr/bin/env sh + +# This script is intended to be called from withibn the markdown-lint-check container to +# provide # polished output + + +script_dir="$(cd "$(dirname "$0")" && pwd)" +base_dir=$(cd "$script_dir"/../.. && pwd) + +MLC_BASE_CMD="markdown-link-check" +if ! ${MLC_BASE_CMD} --help > /dev/null ; then + echo "ERROR: ${MLC_BASE_CMD} not available." + echo "is this running in the right context/container?" + exit 1 +fi + +MLC="${MLC_BASE_CMD} --config ${script_dir}/mlc_config.json --quiet" + +EXIT_CODE=0 +# AGENTS.md consists almost entirely of links into Documentation/. A stale link there silently +# misdirects the reader, so check it alongside the documentation it points at. +FILES=$(cd "$base_dir" && find Documentation/ -name '*.md' && echo AGENTS.md) +BAD_FILES="" +NUM_CHECKED_FILES=0 +NUM_BAD_FILES=0 +NUM_GOOD_FILES=0 +for file in $FILES ; do + echo "Checking file ${file}: .." + NUM_CHECKED_FILES=$((NUM_CHECKED_FILES + 1)) + if ! ${MLC} "$base_dir/$file" ; then + echo "broken links detected in file $file." + NUM_BAD_FILES=$((NUM_BAD_FILES + 1)) + EXIT_CODE=1 + BAD_FILES="$BAD_FILES $file" + else + echo "file ${file} is good." + NUM_GOOD_FILES=$((NUM_GOOD_FILES + 1)) + fi + EXIT_CODE=$NUM_BAD_FILES +done +if [ $EXIT_CODE -ne 0 ]; then + echo "" + echo "================================" + echo "FAIL: BROKEN LINKS DETECTED !!!" + echo "================================" + echo "The following $NUM_BAD_FILES files contain broken links:" + echo "================================" + for file in $BAD_FILES ; do + echo "- $file" + done +else + echo "SUCCESS: no files with broken links found" +fi + echo "================================" + echo "SUMMARY:" + echo "$NUM_CHECKED_FILES files checked." + echo "$NUM_GOOD_FILES files do not have broken links." + echo "$NUM_BAD_FILES files with broken links found." + echo "================================" +exit $EXIT_CODE