diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f06d22..24d0f33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fix buildbot version in upgraded platforms ([#32](../../pull/32)) +### Changed +- Optimize build cache for PR builds ([#36](../../pull/36)) + ## [2.4.1-1] - 2019-09-20 ### Added - Upgrade to buildbot 2.4.1 ([#29](../../pull/29)) diff --git a/scripts/travis.sh b/scripts/travis.sh index ef980c0..574f78b 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -5,7 +5,14 @@ # When a tag is built (TRAVIS_TAG), the branch cannot be determined from # TRAVIS_BRANCH. Assume that it is a release tag: If the version is 1.8.x, we're # on the 1.8 maintenance branch. Otherwise, we're on master. -if [ -z "$TRAVIS_TAG" ] +# +# For PR builds (TRAVIS_PULL_REQUEST_BRANCH), use the branch from which the PR +# originated, not the target branch. This means that the same image is used for +# the Docker build cache as for the corresponding branch build. +if [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ] +then + BRANCH="$TRAVIS_PULL_REQUEST_BRANCH" +elif [ -z "$TRAVIS_TAG" ] then BRANCH="$TRAVIS_BRANCH" elif [[ "$TRAVIS_TAG" =~ ^v1\.8\. ]]