linkcheck only for changed files except in cron jobs

This commit is contained in:
mark 2020-10-05 13:23:14 -05:00 committed by Joshua Nelson
parent 1ae9303960
commit 6ba01cf9eb
3 changed files with 22 additions and 1 deletions

View File

@ -12,7 +12,7 @@ before_install:
install:
- source ~/.cargo/env || true
- cargo install mdbook --version '^0.4.3'
- cargo install mdbook-linkcheck --version '^0.7.0'
- cargo install mdbook-linkcheck --git https://github.com/Michael-F-Bryan/mdbook-linkcheck
script:
- git checkout -b ci
- git rebase origin/master

View File

@ -14,6 +14,7 @@ enable = true
level = 0
[output.linkcheck]
command = "../../ci/linkcheck.sh"
follow-web-links = true
exclude = [ "crates\\.io", "gcc\\.godbolt\\.org", "youtube\\.com", "youtu\\.be", "dl\\.acm\\.org", "cs\\.bgu\\.ac\\.il", "www\\.amazon\\.com", "www\\.rustaceans\\.org" ]
cache-timeout = 86400

20
ci/linkcheck.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
if [ "$TRAVIS_EVENT_TYPE" = "cron" ] ; then # running in cron job
FLAGS=""
echo "Doing full link check."
elif [ "$CI" = "true" ] ; then # running in PR CI build
CHANGED_FILES=$(git diff --name-only $TRAVIS_COMMIT_RANGE | tr '\n' ' ')
FLAGS="-f $CHANGED_FILES"
echo "Checking files changed in $TRAVIS_COMMIT_RANGE: $CHANGED_FILES"
else # running locally
COMMIT_RANGE=master...
CHANGED_FILES=$(git diff --name-only $COMMIT_RANGE | tr '\n' ' ')
FLAGS="-f $CHANGED_FILES"
echo "Checking files changed in $COMMIT_RANGE: $CHANGED_FILES"
fi
exec mdbook-linkcheck $FLAGS -- $TRAVIS_BUILD_DIR