diff --git a/.travis.yml b/.travis.yml index fba5ab87e..3e4a3dc0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/book.toml b/book.toml index 10bc2edd4..af909446a 100644 --- a/book.toml +++ b/book.toml @@ -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 diff --git a/ci/linkcheck.sh b/ci/linkcheck.sh new file mode 100755 index 000000000..85573314c --- /dev/null +++ b/ci/linkcheck.sh @@ -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