diff options
author | Thomas Broyer <t.broyer@ltgt.net> | 2015-06-29 11:18:14 +0000 |
---|---|---|
committer | Damien Martin-Guillerez <dmarting@google.com> | 2015-06-29 16:39:55 +0000 |
commit | 5bae07efd7069f88b6f06fea1e0084aa12602734 (patch) | |
tree | 018ec4f34216b7308be90efb9eb90d917587a9c8 /scripts/ci/ci.sh | |
parent | 0cd6dfb85f930275d486104b380c60ae13f4ee46 (diff) |
Update CI script to build against a common ancestor of origin/master and HEAD
Also give advice for some changes to make to the script depending on the
environment and events triggering the script.
--
Change-Id: Ic230d96c29785c8df392b72fc4809eb7703fafff
Reviewed-on: https://bazel-review.googlesource.com/#/c/1570/
MOS_MIGRATED_REVID=97118314
Diffstat (limited to 'scripts/ci/ci.sh')
-rwxr-xr-x | scripts/ci/ci.sh | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/scripts/ci/ci.sh b/scripts/ci/ci.sh index 0501d0dca3..3ddcadb42b 100755 --- a/scripts/ci/ci.sh +++ b/scripts/ci/ci.sh @@ -15,7 +15,8 @@ # limitations under the License. -# This script looks at the files changed in git against origin/master and +# This script looks at the files changed in git against origin/master +# (actually a common ancestor of origin/master and the current commit) and # queries for all build and test targets associated with those files. # # Running this script on a CI server should allow you to only test the targets @@ -30,21 +31,25 @@ # tested, and only those targets affected by a particular change are # built and tested" # -# When your code is running on Gerrit (for example) and you have a fast-forward -# only policy on your repo you can be sure, by diffing from the origin/master.. -# refspec, that you're listing all the files that are included in a review. -# This would let a team working on Gerrit have the verified bit be -# autopopulated without having the pain of having to wait for the whole world -# to compile. +# When this script is triggered by Gerrit's patchset-updated hook (for example) +# you can replace origina/master in the COMMIT_RANGE variable initialization +# with the branch passed as argument to the hook. When using Jenkins with the +# Gerrit Trigger Plugin, use $GERRIT_BRANCH instead. This would make it +# possible to have the Verified label on Gerrit patchsets populated as fast +# as possible. +# For a ref-updated event, use "${GERRIT_OLDREV}..${GERRIT_NEWREV}" as the +# value for COMMIT_RANGE. +# When running in Travis-CI, you can directly use the $TRAVIS_COMMIT_RANGE +# environment variable. -REFSPEC="origin/master.." +COMMIT_RANGE=$(git merge-base origin/master HEAD)".." # Go to the root of the repo cd "$(git rev-parse --show-toplevel)" # Get a list of the current files in package form by querying Bazel. files=() -for file in $(git diff --name-only ${REFSPEC} ); do +for file in $(git diff --name-only ${COMMIT_RANGE} ); do files+=($(bazel query $file)) echo $(bazel query $file) done |