summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rwxr-xr-xci/lib-travisci.sh72
-rwxr-xr-xci/print-test-failures.sh9
-rwxr-xr-xci/run-build-and-tests.sh19
-rwxr-xr-xci/run-build.sh8
-rwxr-xr-xci/run-linux32-build.sh50
-rwxr-xr-xci/run-linux32-docker.sh10
-rwxr-xr-xci/run-static-analysis.sh2
-rwxr-xr-xci/run-tests.sh10
-rwxr-xr-xci/run-windows-build.sh7
-rwxr-xr-xci/test-documentation.sh8
10 files changed, 161 insertions, 34 deletions
diff --git a/ci/lib-travisci.sh b/ci/lib-travisci.sh
index 331d3eb..109ef28 100755
--- a/ci/lib-travisci.sh
+++ b/ci/lib-travisci.sh
@@ -16,16 +16,78 @@ skip_branch_tip_with_tag () {
if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
test "$TAG" != "$TRAVIS_BRANCH"
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
fi
}
+# 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
+}
+
+check_unignored_build_artifacts ()
+{
+ ! git ls-files --other --exclude-standard --error-unmatch \
+ -- ':/*' 2>/dev/null ||
+ {
+ echo "$(tput setaf 1)error: found unignored build artifacts$(tput sgr0)"
+ false
+ }
+}
+
# 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
+# and installing dependencies.
set -ex
+cache_dir="$HOME/travis-cache"
+good_trees_file="$cache_dir/good-trees"
+
+mkdir -p "$cache_dir"
+
skip_branch_tip_with_tag
+skip_good_tree
if test -z "$jobname"
then
@@ -35,7 +97,7 @@ fi
export DEVELOPER=1
export DEFAULT_TEST_TARGET=prove
export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
-export GIT_TEST_OPTS="--verbose-log"
+export GIT_TEST_OPTS="--verbose-log -x"
export GIT_TEST_CLONE_2GB=YesPlease
case "$jobname" in
@@ -48,8 +110,8 @@ linux-clang|linux-gcc)
export LINUX_P4_VERSION="16.2"
export LINUX_GIT_LFS_VERSION="1.5.2"
- P4_PATH="$(pwd)/custom/p4"
- GIT_LFS_PATH="$(pwd)/custom/git-lfs"
+ P4_PATH="$HOME/custom/p4"
+ GIT_LFS_PATH="$HOME/custom/git-lfs"
export PATH="$GIT_LFS_PATH:$P4_PATH:$PATH"
;;
osx-clang|osx-gcc)
diff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh
index 8c8973c..4f261dd 100755
--- a/ci/print-test-failures.sh
+++ b/ci/print-test-failures.sh
@@ -5,6 +5,15 @@
. ${0%/*}/lib-travisci.sh
+# Tracing executed commands would produce too much noise in the loop below.
+set +x
+
+if ! ls t/test-results/*.exit >/dev/null 2>/dev/null
+then
+ echo "Build job failed before the tests could have been run"
+ exit
+fi
+
for TEST_EXIT in t/test-results/*.exit
do
if [ "$(cat "$TEST_EXIT")" != "0" ]
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
new file mode 100755
index 0000000..3735ce4
--- /dev/null
+++ b/ci/run-build-and-tests.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Build and test Git
+#
+
+. ${0%/*}/lib-travisci.sh
+
+ln -s "$cache_dir/.prove" t/.prove
+
+make --jobs=2
+make --quiet test
+if test "$jobname" = "linux-gcc"
+then
+ GIT_TEST_SPLIT_INDEX=YesPlease make --quiet test
+fi
+
+check_unignored_build_artifacts
+
+save_good_tree
diff --git a/ci/run-build.sh b/ci/run-build.sh
deleted file mode 100755
index 4f940d1..0000000
--- a/ci/run-build.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-#
-# Build Git
-#
-
-. ${0%/*}/lib-travisci.sh
-
-make --jobs=2
diff --git a/ci/run-linux32-build.sh b/ci/run-linux32-build.sh
index e30fb2c..2c60d2e 100755
--- a/ci/run-linux32-build.sh
+++ b/ci/run-linux32-build.sh
@@ -3,28 +3,58 @@
# Build and test Git in a 32-bit environment
#
# Usage:
-# run-linux32-build.sh [host-user-id]
+# run-linux32-build.sh <host-user-id>
#
+set -ex
+
+if test $# -ne 1 || test -z "$1"
+then
+ echo >&2 "usage: run-linux32-build.sh <host-user-id>"
+ exit 1
+fi
+
# Update packages to the latest available versions
linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev libssl-dev \
libexpat-dev gettext python >/dev/null
-' &&
+'
# If this script runs inside a docker container, then all commands are
# usually executed as root. Consequently, the host user might not be
# able to access the test output files.
-# If a host user id is given, then create a user "ci" with the host user
-# id to make everything accessible to the host user.
-HOST_UID=$1 &&
-CI_USER=$USER &&
-test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) &&
+# If a non 0 host user id is given, then create a user "ci" with that
+# user id to make everything accessible to the host user.
+HOST_UID=$1
+if test $HOST_UID -eq 0
+then
+ # Just in case someone does want to run the test suite as root.
+ CI_USER=root
+else
+ CI_USER=ci
+ if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
+ then
+ echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
+ else
+ useradd -u $HOST_UID $CI_USER
+ fi
+
+ # Due to a bug the test suite was run as root in the past, so
+ # a prove state file created back then is only accessible by
+ # root. Now that bug is fixed, the test suite is run as a
+ # regular user, but the prove state file coming from Travis
+ # CI's cache might still be owned by root.
+ # Make sure that this user has rights to any cached files,
+ # including an existing prove state file.
+ test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
+fi
# Build and test
linux32 --32bit i386 su -m -l $CI_USER -c '
- cd /usr/src/git &&
- make --jobs=2 &&
- make --quiet test
+ set -ex
+ cd /usr/src/git
+ test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove
+ make --jobs=2
+ make --quiet test
'
diff --git a/ci/run-linux32-docker.sh b/ci/run-linux32-docker.sh
index 0edf63a..2163790 100755
--- a/ci/run-linux32-docker.sh
+++ b/ci/run-linux32-docker.sh
@@ -9,7 +9,9 @@ docker pull daald/ubuntu32:xenial
# Use the following command to debug the docker build locally:
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
-# root@container:/# /usr/src/git/ci/run-linux32-build.sh
+# root@container:/# /usr/src/git/ci/run-linux32-build.sh <host-user-id>
+
+container_cache_dir=/tmp/travis-cache
docker run \
--interactive \
@@ -18,6 +20,12 @@ docker run \
--env GIT_PROVE_OPTS \
--env GIT_TEST_OPTS \
--env GIT_TEST_CLONE_2GB \
+ --env cache_dir="$container_cache_dir" \
--volume "${PWD}:/usr/src/git" \
+ --volume "$cache_dir:$container_cache_dir" \
daald/ubuntu32:xenial \
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
+
+check_unignored_build_artifacts
+
+save_good_tree
diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh
index 68dd0f0..fe4ee4e 100755
--- a/ci/run-static-analysis.sh
+++ b/ci/run-static-analysis.sh
@@ -6,3 +6,5 @@
. ${0%/*}/lib-travisci.sh
make coccicheck
+
+save_good_tree
diff --git a/ci/run-tests.sh b/ci/run-tests.sh
deleted file mode 100755
index f0c743d..0000000
--- a/ci/run-tests.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-#
-# Test Git
-#
-
-. ${0%/*}/lib-travisci.sh
-
-mkdir -p $HOME/travis-cache
-ln -s $HOME/travis-cache/.prove t/.prove
-make --quiet test
diff --git a/ci/run-windows-build.sh b/ci/run-windows-build.sh
index 8757b3a..d99a180 100755
--- a/ci/run-windows-build.sh
+++ b/ci/run-windows-build.sh
@@ -69,6 +69,10 @@ esac
echo "Visual Studio Team Services Build #${BUILD_ID}"
+# Tracing execued commands would produce too much noise in the waiting
+# loop below.
+set +x
+
# Wait until build job finished
STATUS=
RESULT=
@@ -90,7 +94,10 @@ done
# Print log
echo ""
echo ""
+set -x
gfwci "action=log&buildId=$BUILD_ID" | cut -c 30-
# Set exit code for TravisCI
test "$RESULT" = "success"
+
+save_good_tree
diff --git a/ci/test-documentation.sh b/ci/test-documentation.sh
index 7a0a848..a20de9c 100755
--- a/ci/test-documentation.sh
+++ b/ci/test-documentation.sh
@@ -18,6 +18,9 @@ test -s Documentation/git.xml
test -s Documentation/git.1
grep '<meta name="generator" content="AsciiDoc ' Documentation/git.html
+rm -f stdout.log stderr.log
+check_unignored_build_artifacts
+
# Build docs with AsciiDoctor
make clean
make --jobs=2 USE_ASCIIDOCTOR=1 doc > >(tee stdout.log) 2> >(tee stderr.log >&2)
@@ -25,3 +28,8 @@ sed '/^GIT_VERSION = / d' stderr.log
! test -s stderr.log
test -s Documentation/git.html
grep '<meta name="generator" content="Asciidoctor ' Documentation/git.html
+
+rm -f stdout.log stderr.log
+check_unignored_build_artifacts
+
+save_good_tree