]> git.ipfire.org Git - thirdparty/git.git/blame - ci/run-docker-build.sh
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / ci / run-docker-build.sh
CommitLineData
88dedd5e
JS
1#!/bin/sh
2#
5a33f541 3# Build and test Git inside container
88dedd5e
JS
4#
5# Usage:
5a33f541 6# run-docker-build.sh <host-user-id>
88dedd5e
JS
7#
8
04d47e96 9set -ex
a8b8b6b8 10
53303302
SG
11if test $# -ne 1 || test -z "$1"
12then
5a33f541 13 echo >&2 "usage: run-docker-build.sh <host-user-id>"
53303302
SG
14 exit 1
15fi
16
2bd1e2d2 17case "$jobname" in
c08bb260 18linux32)
2bd1e2d2
ĐTCD
19 switch_cmd="linux32 --32bit i386"
20 ;;
e0f8690d
ĐTCD
21linux-musl)
22 switch_cmd=
23 useradd () { adduser -D "$@"; }
24 ;;
2bd1e2d2
ĐTCD
25*)
26 exit 1
27 ;;
28esac
29
c3bc449e 30"${0%/*}/install-docker-dependencies.sh"
88dedd5e
JS
31
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.
53303302
SG
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.
04d47e96 37HOST_UID=$1
53303302
SG
38if test $HOST_UID -eq 0
39then
40 # Just in case someone does want to run the test suite as root.
41 CI_USER=root
42else
43 CI_USER=ci
6b995760
SG
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
49 fi
53303302 50fi
88dedd5e
JS
51
52# Build and test
2bd1e2d2 53command $switch_cmd su -m -l $CI_USER -c "
04d47e96 54 set -ex
ffce2ebd
ĐTCD
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'
04d47e96 62 cd /usr/src/git
ffce2ebd 63 test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove
eaa62291 64 make
bbf24adb 65 make test
ffce2ebd 66"