git-prompt: stop manually parsing HEAD with unknown ref formats
[git.git] / ci / run-docker-build.sh
blob6cd832efb9cb59687fac4cf95bf471bc87923a96
1 #!/bin/sh
3 # Build and test Git inside container
5 # Usage:
6 # run-docker-build.sh <host-user-id>
9 set -ex
11 if test $# -ne 1 || test -z "$1"
12 then
13 echo >&2 "usage: run-docker-build.sh <host-user-id>"
14 exit 1
17 case "$jobname" in
18 linux32)
19 switch_cmd="linux32 --32bit i386"
21 linux-musl)
22 switch_cmd=
23 useradd () { adduser -D "$@"; }
26 exit 1
28 esac
30 "${0%/*}/install-docker-dependencies.sh"
32 # If this script runs inside a docker container, then all commands are
33 # usually executed as root. Consequently, the host user might not be
34 # able to access the test output files.
35 # If a non 0 host user id is given, then create a user "ci" with that
36 # user id to make everything accessible to the host user.
37 HOST_UID=$1
38 if test $HOST_UID -eq 0
39 then
40 # Just in case someone does want to run the test suite as root.
41 CI_USER=root
42 else
43 CI_USER=ci
44 if test "$(id -u $CI_USER 2>/dev/null)" = $HOST_UID
45 then
46 echo "user '$CI_USER' already exists with the requested ID $HOST_UID"
47 else
48 useradd -u $HOST_UID $CI_USER
52 # Build and test
53 command $switch_cmd su -m -l $CI_USER -c "
54 set -ex
55 export DEVELOPER='$DEVELOPER'
56 export DEFAULT_TEST_TARGET='$DEFAULT_TEST_TARGET'
57 export GIT_PROVE_OPTS='$GIT_PROVE_OPTS'
58 export GIT_TEST_OPTS='$GIT_TEST_OPTS'
59 export GIT_TEST_CLONE_2GB='$GIT_TEST_CLONE_2GB'
60 export MAKEFLAGS='$MAKEFLAGS'
61 export cache_dir='$cache_dir'
62 cd /usr/src/git
63 test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove
64 make
65 make test