Skip to content

Commit 798224a

Browse files
committed
Merge branch 'sg/travis-linux32-sanity'
Travis updates. * sg/travis-linux32-sanity: travis-ci: don't fail if user already exists on 32 bit Linux build job travis-ci: don't run the test suite as root in the 32 bit Linux build travis-ci: don't repeat the path of the cache directory travis-ci: use 'set -e' in the 32 bit Linux build job travis-ci: use 'set -x' for the commands under 'su' in the 32 bit Linux build
2 parents 8df7f75 + 6b99576 commit 798224a

File tree

4 files changed

+50
-18
lines changed

4 files changed

+50
-18
lines changed

ci/lib-travisci.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ skip_branch_tip_with_tag () {
2121
fi
2222
}
2323

24-
good_trees_file="$HOME/travis-cache/good-trees"
25-
2624
# Save some info about the current commit's tree, so we can skip the build
2725
# job if we encounter the same tree again and can provide a useful info
2826
# message.
@@ -83,7 +81,10 @@ check_unignored_build_artifacts ()
8381
# and installing dependencies.
8482
set -ex
8583

86-
mkdir -p "$HOME/travis-cache"
84+
cache_dir="$HOME/travis-cache"
85+
good_trees_file="$cache_dir/good-trees"
86+
87+
mkdir -p "$cache_dir"
8788

8889
skip_branch_tip_with_tag
8990
skip_good_tree

ci/run-linux32-build.sh

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,58 @@
33
# Build and test Git in a 32-bit environment
44
#
55
# Usage:
6-
# run-linux32-build.sh [host-user-id]
6+
# run-linux32-build.sh <host-user-id>
77
#
88

9-
set -x
9+
set -ex
10+
11+
if test $# -ne 1 || test -z "$1"
12+
then
13+
echo >&2 "usage: run-linux32-build.sh <host-user-id>"
14+
exit 1
15+
fi
1016

1117
# Update packages to the latest available versions
1218
linux32 --32bit i386 sh -c '
1319
apt update >/dev/null &&
1420
apt install -y build-essential libcurl4-openssl-dev libssl-dev \
1521
libexpat-dev gettext python >/dev/null
16-
' &&
22+
'
1723

1824
# If this script runs inside a docker container, then all commands are
1925
# usually executed as root. Consequently, the host user might not be
2026
# able to access the test output files.
21-
# If a host user id is given, then create a user "ci" with the host user
22-
# id to make everything accessible to the host user.
23-
HOST_UID=$1 &&
24-
CI_USER=$USER &&
25-
test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) &&
27+
# If a non 0 host user id is given, then create a user "ci" with that
28+
# user id to make everything accessible to the host user.
29+
HOST_UID=$1
30+
if test $HOST_UID -eq 0
31+
then
32+
# Just in case someone does want to run the test suite as root.
33+
CI_USER=root
34+
else
35+
CI_USER=ci
36+
if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
37+
then
38+
echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
39+
else
40+
useradd -u $HOST_UID $CI_USER
41+
fi
42+
43+
# Due to a bug the test suite was run as root in the past, so
44+
# a prove state file created back then is only accessible by
45+
# root. Now that bug is fixed, the test suite is run as a
46+
# regular user, but the prove state file coming from Travis
47+
# CI's cache might still be owned by root.
48+
# Make sure that this user has rights to any cached files,
49+
# including an existing prove state file.
50+
test -n "$cache_dir" && chown -R $HOST_UID:$HOST_UID "$cache_dir"
51+
fi
2652

2753
# Build and test
2854
linux32 --32bit i386 su -m -l $CI_USER -c '
29-
cd /usr/src/git &&
30-
ln -s /tmp/travis-cache/.prove t/.prove &&
31-
make --jobs=2 &&
32-
make --quiet test
55+
set -ex
56+
cd /usr/src/git
57+
test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove
58+
make --jobs=2
59+
make --quiet test
3360
'

ci/run-linux32-docker.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ docker pull daald/ubuntu32:xenial
99

1010
# Use the following command to debug the docker build locally:
1111
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
12-
# root@container:/# /usr/src/git/ci/run-linux32-build.sh
12+
# root@container:/# /usr/src/git/ci/run-linux32-build.sh <host-user-id>
13+
14+
container_cache_dir=/tmp/travis-cache
1315

1416
docker run \
1517
--interactive \
@@ -18,8 +20,9 @@ docker run \
1820
--env GIT_PROVE_OPTS \
1921
--env GIT_TEST_OPTS \
2022
--env GIT_TEST_CLONE_2GB \
23+
--env cache_dir="$container_cache_dir" \
2124
--volume "${PWD}:/usr/src/git" \
22-
--volume "${HOME}/travis-cache:/tmp/travis-cache" \
25+
--volume "$cache_dir:$container_cache_dir" \
2326
daald/ubuntu32:xenial \
2427
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
2528

ci/run-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
. ${0%/*}/lib-travisci.sh
77

8-
ln -s $HOME/travis-cache/.prove t/.prove
8+
ln -s "$cache_dir/.prove" t/.prove
9+
910
make --quiet test
1011
if test "$jobname" = "linux-gcc"
1112
then

0 commit comments

Comments
 (0)