Skip to content

Commit a37b73e

Browse files
committed
Merge branch 'ls/travis-scriptify' into maint
The scripts to drive TravisCI has been reorganized and then an optimization to avoid spending cycles on a branch whose tip is tagged has been implemented. * ls/travis-scriptify: travis-ci: fix "skip_branch_tip_with_tag()" string comparison travis: dedent a few scripts that are indented overly deeply travis-ci: skip a branch build if equal tag is present travis-ci: move Travis CI code into dedicated scripts
2 parents 031062d + 8376eb4 commit a37b73e

10 files changed

+154
-81
lines changed

.travis.yml

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,8 @@ matrix:
6161
services:
6262
- docker
6363
before_install:
64-
- docker pull daald/ubuntu32:xenial
6564
before_script:
66-
script:
67-
- >
68-
docker run
69-
--interactive
70-
--env DEVELOPER
71-
--env DEFAULT_TEST_TARGET
72-
--env GIT_PROVE_OPTS
73-
--env GIT_TEST_OPTS
74-
--env GIT_TEST_CLONE_2GB
75-
--volume "${PWD}:/usr/src/git"
76-
daald/ubuntu32:xenial
77-
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
78-
# Use the following command to debug the docker build locally:
79-
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
80-
# root@container:/# /usr/src/git/ci/run-linux32-build.sh
65+
script: ci/run-linux32-docker.sh
8166
- env: Static Analysis
8267
os: linux
8368
compiler:
@@ -86,9 +71,8 @@ matrix:
8671
packages:
8772
- coccinelle
8873
before_install:
89-
script:
90-
# "before_script" that builds Git is inherited from base job
91-
- make coccicheck
74+
# "before_script" that builds Git is inherited from base job
75+
script: ci/run-static-analysis.sh
9276
after_failure:
9377
- env: Documentation
9478
os: linux
@@ -99,70 +83,14 @@ matrix:
9983
- asciidoc
10084
- xmlto
10185
before_install:
102-
before_script: gem install asciidoctor
86+
before_script:
10387
script: ci/test-documentation.sh
10488
after_failure:
10589

106-
before_install:
107-
- >
108-
case "${TRAVIS_OS_NAME:-linux}" in
109-
linux)
110-
export GIT_TEST_HTTPD=YesPlease
111-
112-
mkdir --parents custom/p4
113-
pushd custom/p4
114-
wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4d
115-
wget --quiet http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION/bin.linux26x86_64/p4
116-
chmod u+x p4d
117-
chmod u+x p4
118-
export PATH="$(pwd):$PATH"
119-
popd
120-
mkdir --parents custom/git-lfs
121-
pushd custom/git-lfs
122-
wget --quiet https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz
123-
tar --extract --gunzip --file "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
124-
cp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .
125-
export PATH="$(pwd):$PATH"
126-
popd
127-
;;
128-
osx)
129-
brew update --quiet
130-
# Uncomment this if you want to run perf tests:
131-
# brew install gnu-time
132-
brew install git-lfs gettext
133-
brew link --force gettext
134-
brew install caskroom/cask/perforce
135-
;;
136-
esac;
137-
echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)";
138-
p4d -V | grep Rev.;
139-
echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)";
140-
p4 -V | grep Rev.;
141-
echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)";
142-
git-lfs version;
143-
144-
before_script: make --jobs=2
145-
146-
script:
147-
- >
148-
mkdir -p $HOME/travis-cache;
149-
ln -s $HOME/travis-cache/.prove t/.prove;
150-
make --quiet test;
151-
152-
after_failure:
153-
- >
154-
: '<-- Click here to see detailed test output! ';
155-
for TEST_EXIT in t/test-results/*.exit;
156-
do
157-
if [ "$(cat "$TEST_EXIT")" != "0" ];
158-
then
159-
TEST_OUT="${TEST_EXIT%exit}out";
160-
echo "------------------------------------------------------------------------";
161-
echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)";
162-
echo "------------------------------------------------------------------------";
163-
cat "${TEST_OUT}";
164-
fi;
165-
done;
90+
before_install: ci/install-dependencies.sh
91+
before_script: ci/run-build.sh
92+
script: ci/run-tests.sh
93+
after_failure: ci/print-test-failures.sh
16694

16795
notifications:
16896
email: false

ci/install-dependencies.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Install dependencies required to build and test Git on Linux and macOS
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
P4WHENCE=http://filehost.perforce.com/perforce/r$LINUX_P4_VERSION
9+
LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION
10+
11+
case "${TRAVIS_OS_NAME:-linux}" in
12+
linux)
13+
export GIT_TEST_HTTPD=YesPlease
14+
15+
mkdir --parents custom/p4
16+
pushd custom/p4
17+
wget --quiet "$P4WHENCE/bin.linux26x86_64/p4d"
18+
wget --quiet "$P4WHENCE/bin.linux26x86_64/p4"
19+
chmod u+x p4d
20+
chmod u+x p4
21+
export PATH="$(pwd):$PATH"
22+
popd
23+
mkdir --parents custom/git-lfs
24+
pushd custom/git-lfs
25+
wget --quiet "$LFSWHENCE/git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
26+
tar --extract --gunzip --file "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz"
27+
cp git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs .
28+
export PATH="$(pwd):$PATH"
29+
popd
30+
;;
31+
osx)
32+
brew update --quiet
33+
# Uncomment this if you want to run perf tests:
34+
# brew install gnu-time
35+
brew install git-lfs gettext
36+
brew link --force gettext
37+
brew install caskroom/cask/perforce
38+
;;
39+
esac
40+
41+
echo "$(tput setaf 6)Perforce Server Version$(tput sgr0)"
42+
p4d -V | grep Rev.
43+
echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)"
44+
p4 -V | grep Rev.
45+
echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)"
46+
git-lfs version

ci/lib-travisci.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Library of functions shared by all CI scripts
2+
3+
skip_branch_tip_with_tag () {
4+
# Sometimes, a branch is pushed at the same time the tag that points
5+
# at the same commit as the tip of the branch is pushed, and building
6+
# both at the same time is a waste.
7+
#
8+
# Travis gives a tagname e.g. v2.14.0 in $TRAVIS_BRANCH when
9+
# the build is triggered by a push to a tag. Let's see if
10+
# $TRAVIS_BRANCH is exactly at a tag, and if so, if it is
11+
# different from $TRAVIS_BRANCH. That way, we can tell if
12+
# we are building the tip of a branch that is tagged and
13+
# we can skip the build because we won't be skipping a build
14+
# of a tag.
15+
16+
if TAG=$(git describe --exact-match "$TRAVIS_BRANCH" 2>/dev/null) &&
17+
test "$TAG" != "$TRAVIS_BRANCH"
18+
then
19+
echo "Tip of $TRAVIS_BRANCH is exactly at $TAG"
20+
exit 0
21+
fi
22+
}
23+
24+
# Set 'exit on error' for all CI scripts to let the caller know that
25+
# something went wrong
26+
set -e
27+
28+
skip_branch_tip_with_tag

ci/print-test-failures.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
#
3+
# Print output of failing tests
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
for TEST_EXIT in t/test-results/*.exit
9+
do
10+
if [ "$(cat "$TEST_EXIT")" != "0" ]
11+
then
12+
TEST_OUT="${TEST_EXIT%exit}out"
13+
echo "------------------------------------------------------------------------"
14+
echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)"
15+
echo "------------------------------------------------------------------------"
16+
cat "${TEST_OUT}"
17+
fi
18+
done

ci/run-build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
#
3+
# Build Git
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
make --jobs=2

ci/run-linux32-docker.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
#
3+
# Download and run Docker image to build and test 32-bit Git
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
docker pull daald/ubuntu32:xenial
9+
10+
# Use the following command to debug the docker build locally:
11+
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
12+
# root@container:/# /usr/src/git/ci/run-linux32-build.sh
13+
14+
docker run \
15+
--interactive \
16+
--env DEVELOPER \
17+
--env DEFAULT_TEST_TARGET \
18+
--env GIT_PROVE_OPTS \
19+
--env GIT_TEST_OPTS \
20+
--env GIT_TEST_CLONE_2GB \
21+
--volume "${PWD}:/usr/src/git" \
22+
daald/ubuntu32:xenial \
23+
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)

ci/run-static-analysis.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
#
3+
# Perform various static code analysis checks
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
make coccicheck

ci/run-tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
#
3+
# Test Git
4+
#
5+
6+
. ${0%/*}/lib-travisci.sh
7+
8+
mkdir -p $HOME/travis-cache
9+
ln -s $HOME/travis-cache/.prove t/.prove
10+
make --quiet test

ci/run-windows-build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
# supported) and a commit hash.
77
#
88

9+
. ${0%/*}/lib-travisci.sh
10+
911
test $# -ne 2 && echo "Unexpected number of parameters" && exit 1
1012
test -z "$GFW_CI_TOKEN" && echo "GFW_CI_TOKEN not defined" && exit
1113

ci/test-documentation.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
# Perform sanity checks on documentation and build it.
44
#
55

6-
set -e
6+
. ${0%/*}/lib-travisci.sh
7+
8+
gem install asciidoctor
79

810
make check-builtins
911
make check-docs

0 commit comments

Comments
 (0)