Skip to content

Commit

Permalink
linkcheck only for changed files except in cron jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-i-m committed Oct 7, 2020
1 parent d4581a5 commit 5e44f19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions ci/linkcheck.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5e44f19

Please sign in to comment.