Skip to content

Add the ability to short circuit CI builds for docs-only changes #5281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@
set -e
set -x

# Short circuit tests and linting jobs if there are no code changes involved.
if [[ $TOXENV != docs ]]; then
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
then
echo "This is not a PR -- will do a complete build."
else
# Pull requests are slightly complicated because $TRAVIS_COMMIT_RANGE
# may include more changes than desired if the history is convoluted.
# Instead, explicitly fetch the base branch and compare against the
# merge-base commit.
git fetch -q origin +refs/heads/$TRAVIS_BRANCH
changes=$(git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD))
echo "Files changed:"
echo "$changes"
if ! echo "$changes" | grep -qvE '(\.rst$)|(^docs)|(^news)|(^\.github)'
then
echo "Only Documentation was updated -- skipping build."
exit
fi
fi
fi

if [[ $TOXENV == py* ]]; then
# Run unit tests
tox -- -m unit
Expand Down