Merge branch 'dd/ci-musl-libc' into HEAD

* dd/ci-musl-libc:
  travis: build and test on Linux with musl libc and busybox
  ci/linux32: libify install-dependencies step
  ci: refactor docker runner script
  ci/linux32: parameterise command to switch arch
  ci/lib-docker: preserve required environment variables
  ci: make MAKEFLAGS available inside the Docker container in the Linux32 job
This commit is contained in:
Junio C Hamano 2020-04-07 22:16:30 -07:00
commit 5471124340
7 changed files with 111 additions and 46 deletions

View File

@ -32,7 +32,15 @@ matrix:
services:
- docker
before_install:
script: ci/run-linux32-docker.sh
script: ci/run-docker.sh
- env: jobname=linux-musl
os: linux
compiler:
addons:
services:
- docker
before_install:
script: ci/run-docker.sh
- env: jobname=StaticAnalysis
os: linux
compiler:

View File

@ -489,14 +489,14 @@ jobs:
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || ci/mount-fileshare.sh //gitfileshare.file.core.windows.net/test-cache gitfileshare "$GITFILESHAREPWD" "$HOME/test-cache" || exit 1
res=0
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
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
sudo chmod a+r t/out/TEST-*.xml
test ! -d t/failed-test-artifacts || sudo chmod a+r t/failed-test-artifacts
test "$GITFILESHAREPWD" = '$(gitfileshare.pwd)' || sudo umount "$HOME/test-cache" || res=1
exit $res
displayName: 'ci/run-linux32-docker.sh'
displayName: 'jobname=Linux32 ci/run-docker.sh'
env:
GITFILESHAREPWD: $(gitfileshare.pwd)
- task: PublishTestResults@2

View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# Install dependencies required to build and test Git inside container
#
case "$jobname" in
Linux32)
linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev \
libssl-dev libexpat-dev gettext python >/dev/null
'
;;
linux-musl)
apk add --update build-base curl-dev openssl-dev expat-dev gettext \
pcre2-dev python3 musl-libintl perl-utils ncurses >/dev/null
;;
esac

View File

@ -198,6 +198,14 @@ osx-clang|osx-gcc)
GIT_TEST_GETTEXT_POISON)
export GIT_TEST_GETTEXT_POISON=true
;;
Linux32)
CC=gcc
;;
linux-musl)
CC=gcc
MAKEFLAGS="$MAKEFLAGS PYTHON_PATH=/usr/bin/python3 USE_LIBPCRE2=Yes"
MAKEFLAGS="$MAKEFLAGS NO_REGEX=Yes ICONV_OMITS_BOM=Yes"
;;
esac
MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"

View File

@ -1,25 +1,33 @@
#!/bin/sh
#
# Build and test Git in a 32-bit environment
# Build and test Git inside container
#
# Usage:
# run-linux32-build.sh <host-user-id>
# run-docker-build.sh <host-user-id>
#
set -ex
if test $# -ne 1 || test -z "$1"
then
echo >&2 "usage: run-linux32-build.sh <host-user-id>"
echo >&2 "usage: run-docker-build.sh <host-user-id>"
exit 1
fi
# Update packages to the latest available versions
linux32 --32bit i386 sh -c '
apt update >/dev/null &&
apt install -y build-essential libcurl4-openssl-dev libssl-dev \
libexpat-dev gettext python >/dev/null
'
case "$jobname" in
Linux32)
switch_cmd="linux32 --32bit i386"
;;
linux-musl)
switch_cmd=
useradd () { adduser -D "$@"; }
;;
*)
exit 1
;;
esac
"${0%/*}/install-docker-dependencies.sh"
# If this script runs inside a docker container, then all commands are
# usually executed as root. Consequently, the host user might not be
@ -51,10 +59,17 @@ else
fi
# Build and test
linux32 --32bit i386 su -m -l $CI_USER -c '
command $switch_cmd su -m -l $CI_USER -c "
set -ex
export DEVELOPER='$DEVELOPER'
export DEFAULT_TEST_TARGET='$DEFAULT_TEST_TARGET'
export GIT_PROVE_OPTS='$GIT_PROVE_OPTS'
export GIT_TEST_OPTS='$GIT_TEST_OPTS'
export GIT_TEST_CLONE_2GB='$GIT_TEST_CLONE_2GB'
export MAKEFLAGS='$MAKEFLAGS'
export cache_dir='$cache_dir'
cd /usr/src/git
test -n "$cache_dir" && ln -s "$cache_dir/.prove" t/.prove
test -n '$cache_dir' && ln -s '$cache_dir/.prove' t/.prove
make
make test
'
"

47
ci/run-docker.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/sh
#
# Download and run Docker image to build and test Git
#
. ${0%/*}/lib.sh
case "$jobname" in
Linux32)
CI_CONTAINER="daald/ubuntu32:xenial"
;;
linux-musl)
CI_CONTAINER=alpine
;;
*)
exit 1
;;
esac
docker pull "$CI_CONTAINER"
# Use the following command to debug the docker build locally:
# <host-user-id> must be 0 if podman is used as drop-in replacement for docker
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/sh "$CI_CONTAINER"
# root@container:/# export jobname=<jobname>
# root@container:/# /usr/src/git/ci/run-docker-build.sh <host-user-id>
container_cache_dir=/tmp/travis-cache
docker run \
--interactive \
--env DEVELOPER \
--env DEFAULT_TEST_TARGET \
--env GIT_PROVE_OPTS \
--env GIT_TEST_OPTS \
--env GIT_TEST_CLONE_2GB \
--env MAKEFLAGS \
--env jobname \
--env cache_dir="$container_cache_dir" \
--volume "${PWD}:/usr/src/git" \
--volume "$cache_dir:$container_cache_dir" \
"$CI_CONTAINER" \
/usr/src/git/ci/run-docker-build.sh $(id -u $USER)
check_unignored_build_artifacts
save_good_tree

View File

@ -1,31 +0,0 @@
#!/bin/sh
#
# Download and run Docker image to build and test 32-bit Git
#
. ${0%/*}/lib.sh
docker pull daald/ubuntu32:xenial
# Use the following command to debug the docker build locally:
# $ docker run -itv "${PWD}:/usr/src/git" --entrypoint /bin/bash daald/ubuntu32:xenial
# root@container:/# /usr/src/git/ci/run-linux32-build.sh <host-user-id>
container_cache_dir=/tmp/travis-cache
docker run \
--interactive \
--env DEVELOPER \
--env DEFAULT_TEST_TARGET \
--env GIT_PROVE_OPTS \
--env GIT_TEST_OPTS \
--env GIT_TEST_CLONE_2GB \
--env cache_dir="$container_cache_dir" \
--volume "${PWD}:/usr/src/git" \
--volume "$cache_dir:$container_cache_dir" \
daald/ubuntu32:xenial \
/usr/src/git/ci/run-linux32-build.sh $(id -u $USER)
check_unignored_build_artifacts
save_good_tree