Johannes Schindelin | 88dedd5 | 2017-03-05 19:25:19 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
Đoàn Trần Công Danh | 5a33f54 | 2020-04-04 08:08:48 +0700 | [diff] [blame] | 3 | # Build and test Git inside container |
Johannes Schindelin | 88dedd5 | 2017-03-05 19:25:19 +0100 | [diff] [blame] | 4 | # |
| 5 | # Usage: |
Đoàn Trần Công Danh | 5a33f54 | 2020-04-04 08:08:48 +0700 | [diff] [blame] | 6 | # run-docker-build.sh <host-user-id> |
Johannes Schindelin | 88dedd5 | 2017-03-05 19:25:19 +0100 | [diff] [blame] | 7 | # |
| 8 | |
SZEDER Gábor | 04d47e9 | 2018-01-29 18:17:10 +0100 | [diff] [blame] | 9 | set -ex |
SZEDER Gábor | a8b8b6b | 2017-12-27 17:36:00 +0100 | [diff] [blame] | 10 | |
SZEDER Gábor | 5330330 | 2018-01-29 18:17:12 +0100 | [diff] [blame] | 11 | if test $# -ne 1 || test -z "$1" |
| 12 | then |
Đoàn Trần Công Danh | 5a33f54 | 2020-04-04 08:08:48 +0700 | [diff] [blame] | 13 | echo >&2 "usage: run-docker-build.sh <host-user-id>" |
SZEDER Gábor | 5330330 | 2018-01-29 18:17:12 +0100 | [diff] [blame] | 14 | exit 1 |
| 15 | fi |
| 16 | |
Đoàn Trần Công Danh | 2bd1e2d | 2020-04-04 08:08:47 +0700 | [diff] [blame] | 17 | case "$jobname" in |
Ævar Arnfjörð Bjarmason | c08bb26 | 2021-11-23 17:29:10 +0100 | [diff] [blame] | 18 | linux32) |
Đoàn Trần Công Danh | 2bd1e2d | 2020-04-04 08:08:47 +0700 | [diff] [blame] | 19 | switch_cmd="linux32 --32bit i386" |
| 20 | ;; |
Đoàn Trần Công Danh | e0f8690 | 2020-04-04 08:08:50 +0700 | [diff] [blame] | 21 | linux-musl) |
| 22 | switch_cmd= |
| 23 | useradd () { adduser -D "$@"; } |
| 24 | ;; |
Đoàn Trần Công Danh | 2bd1e2d | 2020-04-04 08:08:47 +0700 | [diff] [blame] | 25 | *) |
| 26 | exit 1 |
| 27 | ;; |
| 28 | esac |
| 29 | |
Đoàn Trần Công Danh | c3bc449 | 2020-04-04 08:08:49 +0700 | [diff] [blame] | 30 | "${0%/*}/install-docker-dependencies.sh" |
Johannes Schindelin | 88dedd5 | 2017-03-05 19:25:19 +0100 | [diff] [blame] | 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. |
SZEDER Gábor | 5330330 | 2018-01-29 18:17:12 +0100 | [diff] [blame] | 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. |
SZEDER Gábor | 04d47e9 | 2018-01-29 18:17:10 +0100 | [diff] [blame] | 37 | HOST_UID=$1 |
SZEDER Gábor | 5330330 | 2018-01-29 18:17:12 +0100 | [diff] [blame] | 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 |
SZEDER Gábor | 6b99576 | 2018-01-29 18:17:13 +0100 | [diff] [blame] | 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 |
SZEDER Gábor | 5330330 | 2018-01-29 18:17:12 +0100 | [diff] [blame] | 50 | fi |
Johannes Schindelin | 88dedd5 | 2017-03-05 19:25:19 +0100 | [diff] [blame] | 51 | |
| 52 | # Build and test |
Đoàn Trần Công Danh | 2bd1e2d | 2020-04-04 08:08:47 +0700 | [diff] [blame] | 53 | command $switch_cmd su -m -l $CI_USER -c " |
SZEDER Gábor | 04d47e9 | 2018-01-29 18:17:10 +0100 | [diff] [blame] | 54 | set -ex |
Đoàn Trần Công Danh | ffce2eb | 2020-04-04 08:08:46 +0700 | [diff] [blame] | 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' |
SZEDER Gábor | 04d47e9 | 2018-01-29 18:17:10 +0100 | [diff] [blame] | 62 | cd /usr/src/git |
Đoàn Trần Công Danh | ffce2eb | 2020-04-04 08:08:46 +0700 | [diff] [blame] | 63 | test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove |
Johannes Schindelin | eaa6229 | 2019-01-27 15:26:52 -0800 | [diff] [blame] | 64 | make |
SZEDER Gábor | bbf24ad | 2019-01-17 02:29:11 +0100 | [diff] [blame] | 65 | make test |
Đoàn Trần Công Danh | ffce2eb | 2020-04-04 08:08:46 +0700 | [diff] [blame] | 66 | " |