Skip to content

Commit 5a33f54

Browse files
sgngitster
authored andcommitted
ci: refactor docker runner script
We will support alpine check in docker later in this series. While we're at it, tell people to run as root in podman, if podman is used as drop-in replacement for docker, because podman will map host-user to container's root, therefore, mapping their permission. Signed-off-by: Đoàn Trần Công Danh <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2bd1e2d commit 5a33f54

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ matrix:
3232
services:
3333
- docker
3434
before_install:
35-
script: ci/run-linux32-docker.sh
35+
script: ci/run-docker.sh
3636
- env: jobname=StaticAnalysis
3737
os: linux
3838
compiler:

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,14 @@ jobs:
489489
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
490490
491491
res=0
492-
sudo AGENT_OS="$AGENT_OS" BUILD_BUILDNUMBER="$BUILD_BUILDNUMBER" BUILD_REPOSITORY_URI="$BUILD_REPOSITORY_URI" BUILD_SOURCEBRANCH="$BUILD_SOURCEBRANCH" BUILD_SOURCEVERSION="$BUILD_SOURCEVERSION" SYSTEM_PHASENAME="$SYSTEM_PHASENAME" SYSTEM_TASKDEFINITIONSURI="$SYSTEM_TASKDEFINITIONSURI" SYSTEM_TEAMPROJECT="$SYSTEM_TEAMPROJECT" CC=$CC MAKEFLAGS="$MAKEFLAGS" bash -lxc ci/run-linux32-docker.sh || res=1
492+
sudo AGENT_OS="$AGENT_OS" BUILD_BUILDNUMBER="$BUILD_BUILDNUMBER" BUILD_REPOSITORY_URI="$BUILD_REPOSITORY_URI" BUILD_SOURCEBRANCH="$BUILD_SOURCEBRANCH" BUILD_SOURCEVERSION="$BUILD_SOURCEVERSION" SYSTEM_PHASENAME="$SYSTEM_PHASENAME" SYSTEM_TASKDEFINITIONSURI="$SYSTEM_TASKDEFINITIONSURI" SYSTEM_TEAMPROJECT="$SYSTEM_TEAMPROJECT" CC=$CC MAKEFLAGS="$MAKEFLAGS" jobname=Linux32 bash -lxc ci/run-docker.sh || res=1
493493
494494
sudo chmod a+r t/out/TEST-*.xml
495495
test ! -d t/failed-test-artifacts || sudo chmod a+r t/failed-test-artifacts
496496
497497
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || res=1
498498
exit $res
499-
displayName: 'ci/run-linux32-docker.sh'
499+
displayName: 'jobname=Linux32 ci/run-docker.sh'
500500
env:
501501
GITFILESHAREPWD: $(gitfileshare.pwd)
502502
- task: PublishTestResults@2

ci/run-linux32-build.sh renamed to ci/run-docker-build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/sh
22
#
3-
# Build and test Git in a 32-bit environment
3+
# Build and test Git inside container
44
#
55
# Usage:
6-
# run-linux32-build.sh <host-user-id>
6+
# run-docker-build.sh <host-user-id>
77
#
88

99
set -ex
1010

1111
if test $# -ne 1 || test -z "$1"
1212
then
13-
echo >&2 "usage: run-linux32-build.sh <host-user-id>"
13+
echo >&2 "usage: run-docker-build.sh <host-user-id>"
1414
exit 1
1515
fi
1616

ci/run-linux32-docker.sh renamed to ci/run-docker.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
#!/bin/sh
22
#
3-
# Download and run Docker image to build and test 32-bit Git
3+
# Download and run Docker image to build and test Git
44
#
55

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

8-
docker pull daald/ubuntu32:xenial
8+
case "$jobname" in
9+
Linux32)
10+
CI_CONTAINER="daald/ubuntu32:xenial"
11+
;;
12+
*)
13+
exit 1
14+
;;
15+
esac
16+
17+
docker pull "$CI_CONTAINER"
918

1019
# Use the following command to debug the docker build locally:
11-
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
20+
# <host-user-id> must be 0 if podman is used as drop-in replacement for docker
21+
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/sh "$CI_CONTAINER"
1222
# root@container:/# export jobname=<jobname>
13-
# root@container:/# /usr/src/git/ci/run-linux32-build.sh <host-user-id>
23+
# root@container:/# /usr/src/git/ci/run-docker-build.sh <host-user-id>
1424

1525
container_cache_dir=/tmp/travis-cache
1626

@@ -26,8 +36,8 @@ docker run \
2636
--env cache_dir="$container_cache_dir" \
2737
--volume "${PWD}:/usr/src/git" \
2838
--volume "$cache_dir:$container_cache_dir" \
29-
daald/ubuntu32:xenial \
30-
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
39+
"$CI_CONTAINER" \
40+
/usr/src/git/ci/run-docker-build.sh $(id -u $USER)
3141

3242
check_unignored_build_artifacts
3343

0 commit comments

Comments
 (0)