aboutsummaryrefslogtreecommitdiff
path: root/ci/test/02_run_container.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ci/test/02_run_container.sh')
-rwxr-xr-xci/test/02_run_container.sh18
1 files changed, 18 insertions, 0 deletions
diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh
index afd447c347..9069fba156 100755
--- a/ci/test/02_run_container.sh
+++ b/ci/test/02_run_container.sh
@@ -15,12 +15,22 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
python3 -c 'import os; [print(f"{key}={value}") for key, value in os.environ.items() if "\n" not in value and "HOME" != key and "PATH" != key and "USER" != key]' | tee "/tmp/env-$USER-$CONTAINER_NAME"
# System-dependent env vars must be kept as is. So read them from the container.
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
+
+ # Env vars during the build can not be changed. For example, a modified
+ # $MAKEJOBS is ignored in the build process. Use --cpuset-cpus as an
+ # approximation to respect $MAKEJOBS somewhat, if cpuset is available.
+ MAYBE_CPUSET=""
+ if [ "$HAVE_CGROUP_CPUSET" ]; then
+ MAYBE_CPUSET="--cpuset-cpus=$( python3 -c "import random;P=$( nproc );M=min(P,int('$MAKEJOBS'.lstrip('-j')));print(','.join(map(str,sorted(random.sample(range(P),M)))))" )"
+ fi
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
+ # shellcheck disable=SC2086
DOCKER_BUILDKIT=1 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
--build-arg "CI_IMAGE_NAME_TAG=${CI_IMAGE_NAME_TAG}" \
--build-arg "FILE_ENV=${FILE_ENV}" \
+ $MAYBE_CPUSET \
--label="${CI_IMAGE_LABEL}" \
--tag="${CONTAINER_NAME}" \
"${BASE_READ_ONLY_DIR}"
@@ -48,6 +58,14 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
CI_PREVIOUS_RELEASES_MOUNT="type=bind,src=${PREVIOUS_RELEASES_DIR},dst=$PREVIOUS_RELEASES_DIR"
fi
+ if [ "$DANGER_CI_ON_HOST_CCACHE_FOLDER" ]; then
+ if [ ! -d "${CCACHE_DIR}" ]; then
+ echo "Error: Directory '${CCACHE_DIR}' must be created in advance."
+ exit 1
+ fi
+ CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=${CCACHE_DIR}"
+ fi
+
docker network create --ipv6 --subnet 1111:1111::/112 ci-ip6net || true
if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then