Merge branch 'sg/travis-skip-identical-test'
Avoid repeatedly testing the same tree in TravisCI that have been tested successfully already. * sg/travis-skip-identical-test: travis-ci: record and skip successfully built trees travis-ci: create the cache directory early in the build process travis-ci: print the "tip of branch is exactly at tag" message in color
This commit is contained in:
commit
a19caa7d63
@ -16,18 +16,67 @@ skip_branch_tip_with_tag () {
|
|||||||
if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
|
if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
|
||||||
test "$TAG" != "$TRAVIS_BRANCH"
|
test "$TAG" != "$TRAVIS_BRANCH"
|
||||||
then
|
then
|
||||||
echo "Tip of $TRAVIS_BRANCH is exactly at $TAG"
|
echo "$(tput setaf 2)Tip of $TRAVIS_BRANCH is exactly at $TAG$(tput sgr0)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
good_trees_file="$HOME/travis-cache/good-trees"
|
||||||
|
|
||||||
|
# Save some info about the current commit's tree, so we can skip the build
|
||||||
|
# job if we encounter the same tree again and can provide a useful info
|
||||||
|
# message.
|
||||||
|
save_good_tree () {
|
||||||
|
echo "$(git rev-parse $TRAVIS_COMMIT^{tree}) $TRAVIS_COMMIT $TRAVIS_JOB_NUMBER $TRAVIS_JOB_ID" >>"$good_trees_file"
|
||||||
|
# limit the file size
|
||||||
|
tail -1000 "$good_trees_file" >"$good_trees_file".tmp
|
||||||
|
mv "$good_trees_file".tmp "$good_trees_file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Skip the build job if the same tree has already been built and tested
|
||||||
|
# successfully before (e.g. because the branch got rebased, changing only
|
||||||
|
# the commit messages).
|
||||||
|
skip_good_tree () {
|
||||||
|
if ! good_tree_info="$(grep "^$(git rev-parse $TRAVIS_COMMIT^{tree}) " "$good_trees_file")"
|
||||||
|
then
|
||||||
|
# Haven't seen this tree yet, or no cached good trees file yet.
|
||||||
|
# Continue the build job.
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$good_tree_info" | {
|
||||||
|
read tree prev_good_commit prev_good_job_number prev_good_job_id
|
||||||
|
|
||||||
|
if test "$TRAVIS_JOB_ID" = "$prev_good_job_id"
|
||||||
|
then
|
||||||
|
cat <<-EOF
|
||||||
|
$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
|
||||||
|
This commit has already been built and tested successfully by this build job.
|
||||||
|
To force a re-build delete the branch's cache and then hit 'Restart job'.
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<-EOF
|
||||||
|
$(tput setaf 2)Skipping build job for commit $TRAVIS_COMMIT.$(tput sgr0)
|
||||||
|
This commit's tree has already been built and tested successfully in build job $prev_good_job_number for commit $prev_good_commit.
|
||||||
|
The log of that build job is available at https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$prev_good_job_id
|
||||||
|
To force a re-build delete the branch's cache and then hit 'Restart job'.
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# Set 'exit on error' for all CI scripts to let the caller know that
|
# Set 'exit on error' for all CI scripts to let the caller know that
|
||||||
# something went wrong.
|
# something went wrong.
|
||||||
# Set tracing executed commands, primarily setting environment variables
|
# Set tracing executed commands, primarily setting environment variables
|
||||||
# and installing dependencies.
|
# and installing dependencies.
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
mkdir -p "$HOME/travis-cache"
|
||||||
|
|
||||||
skip_branch_tip_with_tag
|
skip_branch_tip_with_tag
|
||||||
|
skip_good_tree
|
||||||
|
|
||||||
if test -z "$jobname"
|
if test -z "$jobname"
|
||||||
then
|
then
|
||||||
|
@ -22,3 +22,5 @@ docker run \
|
|||||||
--volume "${HOME}/travis-cache:/tmp/travis-cache" \
|
--volume "${HOME}/travis-cache:/tmp/travis-cache" \
|
||||||
daald/ubuntu32:xenial \
|
daald/ubuntu32:xenial \
|
||||||
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
|
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
|
||||||
|
|
||||||
|
save_good_tree
|
||||||
|
@ -6,3 +6,5 @@
|
|||||||
. ${0%/*}/lib-travisci.sh
|
. ${0%/*}/lib-travisci.sh
|
||||||
|
|
||||||
make coccicheck
|
make coccicheck
|
||||||
|
|
||||||
|
save_good_tree
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
. ${0%/*}/lib-travisci.sh
|
. ${0%/*}/lib-travisci.sh
|
||||||
|
|
||||||
mkdir -p $HOME/travis-cache
|
|
||||||
ln -s $HOME/travis-cache/.prove t/.prove
|
ln -s $HOME/travis-cache/.prove t/.prove
|
||||||
make --quiet test
|
make --quiet test
|
||||||
|
|
||||||
|
save_good_tree
|
||||||
|
@ -99,3 +99,5 @@ gfwci "action=log&buildId=$BUILD_ID" | cut -c 30-
|
|||||||
|
|
||||||
# Set exit code for TravisCI
|
# Set exit code for TravisCI
|
||||||
test "$RESULT" = "success"
|
test "$RESULT" = "success"
|
||||||
|
|
||||||
|
save_good_tree
|
||||||
|
@ -25,3 +25,5 @@ sed '/^GIT_VERSION = / d' stderr.log
|
|||||||
! test -s stderr.log
|
! test -s stderr.log
|
||||||
test -s Documentation/git.html
|
test -s Documentation/git.html
|
||||||
grep '<meta name="generator" content="Asciidoctor ' Documentation/git.html
|
grep '<meta name="generator" content="Asciidoctor ' Documentation/git.html
|
||||||
|
|
||||||
|
save_good_tree
|
||||||
|
Loading…
Reference in New Issue
Block a user