Skip to content

Commit ae4ab5b

Browse files
tghosthclaude
andauthored
Retry status-0 URL check failures with curl (#3342)
* Retry status-0 URL check failures with curl before failing The cr.yp.to links consistently fail with status 0 (connection failure) from GitHub Actions runners despite being valid URLs. - Increase markdown-link-check timeout from default 10s to 30s - Add a retry step that re-checks status-0 failures using curl with retries, so genuine dead links still fail but servers that don't respond to the Node.js HTTP client get a second chance Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix pipefail: tee was swallowing markdown-link-check exit code Adding `| tee` to capture output caused the pipeline exit code to always be 0 (from tee), so link check failures were silently ignored. Adding `set -o pipefail` ensures the pipeline fails when markdown-link-check fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Use continue-on-error so curl retry can rescue the job The `if: failure()` approach ran the retry step but couldn't change the job outcome. Using `continue-on-error: true` with step ID lets the retry step determine the final pass/fail result. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 63eea77 commit ae4ab5b

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

.github/workflows/config/url-checker-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
],
2121
"retryOn429": true,
2222
"aliveStatusCodes": [200, 403],
23+
"timeout": "30s",
2324
"fallbackRetryDelay": "30s",
2425
"see": "https://github.com/tcort/markdown-link-check#config-file-format"
2526
}

.github/workflows/url-checker.yml

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ jobs:
3737
cat /tmp/files_to_check.txt
3838
3939
- name: Check URLs
40+
id: linkcheck
41+
continue-on-error: true
4042
run: |
43+
set -o pipefail
4144
ERROR_FOUND=0
4245
while IFS= read -r file; do
4346
if [ -n "$file" ]; then
44-
markdown-link-check "$file" --config .github/workflows/config/url-checker-config.json -q || ERROR_FOUND=1
47+
markdown-link-check "$file" --config .github/workflows/config/url-checker-config.json -q 2>&1 | tee -a /tmp/link-check-output.txt || ERROR_FOUND=1
4548
fi
4649
done < /tmp/files_to_check.txt
4750
@@ -53,3 +56,49 @@ jobs:
5356
echo ""
5457
echo "All links are good!"
5558
fi
59+
60+
- name: Retry status-0 failures with curl
61+
if: steps.linkcheck.outcome == 'failure'
62+
run: |
63+
echo "Retrying status-0 (connection failure) URLs with curl..."
64+
DEAD_LINKS=0
65+
66+
# Extract URLs that failed with status 0
67+
grep -oP '\[✖\] \Khttps?://\S+(?= → Status: 0)' /tmp/link-check-output.txt > /tmp/status0-urls.txt || true
68+
69+
if [ ! -s /tmp/status0-urls.txt ]; then
70+
echo "No status-0 failures found to retry - all failures are genuine dead links."
71+
exit 1
72+
fi
73+
74+
# Check if there were non-status-0 failures too
75+
NON_ZERO_FAILURES=$(grep '\[✖\]' /tmp/link-check-output.txt | grep -v 'Status: 0' | wc -l)
76+
if [ "$NON_ZERO_FAILURES" -gt 0 ]; then
77+
echo "Found $NON_ZERO_FAILURES non-connection failures (these are genuine dead links):"
78+
grep '\[✖\]' /tmp/link-check-output.txt | grep -v 'Status: 0'
79+
DEAD_LINKS=1
80+
fi
81+
82+
echo ""
83+
echo "Retrying $(wc -l < /tmp/status0-urls.txt) status-0 URL(s) with curl..."
84+
echo ""
85+
86+
while IFS= read -r url; do
87+
if [ -n "$url" ]; then
88+
HTTP_CODE=$(curl -sS -o /dev/null -w "%{http_code}" --max-time 30 --retry 2 --retry-delay 5 -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0" "$url" 2>/dev/null || echo "000")
89+
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 400 ]; then
90+
echo "[✓] $url → curl status: $HTTP_CODE (OK)"
91+
else
92+
echo "[✖] $url → curl status: $HTTP_CODE (FAILED)"
93+
DEAD_LINKS=1
94+
fi
95+
fi
96+
done < /tmp/status0-urls.txt
97+
98+
echo ""
99+
if [ "$DEAD_LINKS" -eq 1 ]; then
100+
echo "ERROR: Dead links confirmed after retry!"
101+
exit 1
102+
else
103+
echo "All status-0 URLs passed curl retry - links are alive!"
104+
fi

0 commit comments

Comments
 (0)