travis: Build only changed things

Build library only if the library changed
This commit is contained in:
Matthias Beyer 2016-01-09 23:55:44 +01:00
parent 7a08c9b773
commit 37e5307e08

View file

@ -16,14 +16,39 @@ before_script:
script: script:
- | - |
if [[ "doc" == $(git diff --name-only $TRAVIS_BRANCH..$TRAVIS_COMMIT | cut -d "/" -f 1 | uniq) ]]; then changes_in() {
echo "There are only changes in the ./doc directory... not doing anything" [[ $(git diff --name-only $TRAVIS_BRANCH..$TRAVIS_COMMIT | \
else cut -d "/" -f 1 | \
grep "$n") ]] > /dev/null
}
travis_cargo_run_in() {
[[ -d "$1" ]] &&
cd "$1" &&
travis-cargo build && travis-cargo build &&
travis-cargo test && travis-cargo test &&
travis-cargo bench && travis-cargo bench &&
travis-cargo --only stable doc travis-cargo --only stable doc &&
fi cd -
}
if_changed_then_build_or_exit() {
if [[ $(changes_in "$1") ]]; then
echo "Changes in $1, building..."
travis_cargo_run_in "$1" || exit 1
else
echo "No changes in $1"
fi
}
[[ $(changes_in "doc") ]] && echo "Changes in ./doc are not build by CI"
if_changed_then_build_or_exit "libimagmodule"
if_changed_then_build_or_exit "libimagrt"
if_changed_then_build_or_exit "libimagstore"
if_changed_then_build_or_exit "libimagutil"
(changes_in "src" && travis_cargo_run_in ".") || true
addons: addons:
apt: apt: