Skip to content

Commit daaa0fd

Browse files
authored
Merge pull request #5281 from pradyunsg/ci/short-circuiting
Add the ability to short circuit Travis CI builds for docs-only changes
2 parents ad65c7c + 4f1273e commit daaa0fd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.travis/run.sh

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,28 @@
22
set -e
33
set -x
44

5+
# Short circuit tests and linting jobs if there are no code changes involved.
6+
if [[ $TOXENV != docs ]]; then
7+
if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]
8+
then
9+
echo "This is not a PR -- will do a complete build."
10+
else
11+
# Pull requests are slightly complicated because $TRAVIS_COMMIT_RANGE
12+
# may include more changes than desired if the history is convoluted.
13+
# Instead, explicitly fetch the base branch and compare against the
14+
# merge-base commit.
15+
git fetch -q origin +refs/heads/$TRAVIS_BRANCH
16+
changes=$(git diff --name-only HEAD $(git merge-base HEAD FETCH_HEAD))
17+
echo "Files changed:"
18+
echo "$changes"
19+
if ! echo "$changes" | grep -qvE '(\.rst$)|(^docs)|(^news)|(^\.github)'
20+
then
21+
echo "Only Documentation was updated -- skipping build."
22+
exit
23+
fi
24+
fi
25+
fi
26+
527
if [[ $TOXENV == py* ]]; then
628
# Run unit tests
729
tox -- -m unit

0 commit comments

Comments
 (0)