Retry markdown link check on failure (#4387)

This commit is contained in:
Trask Stalnaker 2022-04-15 17:48:08 -07:00 committed by GitHub
parent d6017ecf7c
commit 2fcdacec3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 4 deletions

View File

@ -0,0 +1,15 @@
#!/bin/bash -e
retry_count=3
for file in "$@"; do
for i in $(seq 1 $retry_count); do
if markdown-link-check --config "$(dirname "$0")/markdown-link-check-config.json" \
"$file"; then
break
elif [[ $i -eq $retry_count ]]; then
exit 1
fi
sleep 5
done
done

View File

@ -17,5 +17,4 @@ jobs:
find . -type f \
-name '*.md' \
-not -path './CHANGELOG.md' \
| xargs markdown-link-check \
--config .github/scripts/markdown-link-check-config.json
| xargs .github/scripts/markdown-link-check-with-retry.sh

View File

@ -167,8 +167,28 @@ requests if external links break.
find . -type f \
-name '*.md' \
-not -path './CHANGELOG.md' \
| xargs markdown-link-check \
--config .github/scripts/markdown-link-check-config.json
| .github/scripts/markdown-link-check-with-retry.sh
```
`.github/scripts/markdown-link-check-with-retry.sh` helps to reduce sporadic link check failures by
retrying at a file-by-file level. It fails fast to make errors easier to find in the log.
```bash
#!/bin/bash -e
retry_count=3
for file in "$@"; do
for i in $(seq 1 $retry_count); do
if markdown-link-check --config "$(dirname "$0")/markdown-link-check-config.json" \
"$file"; then
break
elif [[ $i -eq $retry_count ]]; then
exit 1
fi
sleep 5
done
done
```
The file `.github/scripts/markdown-link-check-config.json` is for configuring the markdown link check: