From 7bd4ede1196aefd94d7ecf91b8f664d12e1059ec Mon Sep 17 00:00:00 2001 From: Jonathan Miller <1+jmiller@noreply.git.mokoconsulting.tech> Date: Wed, 20 May 2026 02:13:12 +0000 Subject: [PATCH] fix(ci): clean up docs-index link check (remove broken heredoc remnants) Authored-by: Moko Consulting --- .gitea/workflows/repo-health.yml | 46 ++++++-------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/.gitea/workflows/repo-health.yml b/.gitea/workflows/repo-health.yml index 5c6a513..5392de3 100644 --- a/.gitea/workflows/repo-health.yml +++ b/.gitea/workflows/repo-health.yml @@ -608,11 +608,10 @@ jobs: fi if [ -f "${DOCS_INDEX}" ]; then - missing_links="" - if [ -f "${DOCS_INDEX}" ]; then - while IFS= read -r line; do - for link in $(echo "$line" | grep -oP '\]\(\K[^)]+' || true); do - case "$link" in http://*|https://*|\#*|mailto:*) continue ;; esac + missing_links="" + while IFS= read -r docline; do + for link in $(echo "$docline" | grep -oE '\]\([^)]+\)' | sed 's/\](//' | sed 's/)$//' || true); do + case "$link" in http://*|https://*|"#"*|mailto:*) continue ;; esac linkpath="${link%%#*}" linkpath="${linkpath%%\?*}" [ -z "$linkpath" ] && continue @@ -621,46 +620,17 @@ jobs: else testpath="$(dirname "${DOCS_INDEX}")/${linkpath}" fi - [ ! -e "$testpath" ] && missing_links="${missing_links}${testpath} -" + [ ! -e "$testpath" ] && missing_links="${missing_links}${testpath} " done done < "${DOCS_INDEX}" - fi - import re - - idx = os.environ.get('DOCS_INDEX', 'docs/docs-index.md') - base = os.getcwd() - - bad = [] - pat = re.compile(r'\[[^\]]+\]\(([^)]+)\)') - - with open(idx, 'r', encoding='utf-8') as f: - for line in f: - for m in pat.findall(line): - link = m.strip() - if link.startswith('http://') or link.startswith('https://') or link.startswith('#') or link.startswith('mailto:'): - continue - if link.startswith('/'): - rel = link.lstrip('/') - else: - rel = os.path.normpath(os.path.join(os.path.dirname(idx), link)) - rel = rel.split('#', 1)[0] - rel = rel.split('?', 1)[0] - if not rel: - continue - p = os.path.join(base, rel) - if not os.path.exists(p): - bad.append(rel) - - print('\n'.join(sorted(set(bad)))) - PY - )" if [ -n "${missing_links}" ]; then extended_findings+=("docs/docs-index.md contains broken relative links") { printf '%s\n' '### Docs index link integrity' printf '%s\n' 'Broken relative links:' - while IFS= read -r l; do [ -n "${l}" ] && printf '%s\n' "- ${l}"; done <<< "${missing_links}" + for bl in ${missing_links}; do + printf '%s\n' "- ${bl}" + done printf '\n' } >> "${GITHUB_STEP_SUMMARY}" fi