aboutsummaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2024-01-16 23:03:07 +0100
committerSjors Provoost <sjors@sprovoost.nl>2024-01-18 18:18:08 +0100
commitc65fde483133a04964cc8757c96005b78d9e8ca8 (patch)
tree1aa55d901d6efd4c4028057de2886ffbd30f9ca0 /ci
parent03c5b0064d4f766bc8dc6508773c7579e9ad39bc (diff)
downloadbitcoin-c65fde483133a04964cc8757c96005b78d9e8ca8.tar.xz
ci: vary /tmp/env
Diffstat (limited to 'ci')
-rwxr-xr-xci/test/02_run_container.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh
index 8a7a978994..e6c4a61341 100755
--- a/ci/test/02_run_container.sh
+++ b/ci/test/02_run_container.sh
@@ -12,9 +12,9 @@ set -ex
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# Export all env vars to avoid missing some.
# Though, exclude those with newlines to avoid parsing problems.
- 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
+ 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
+ docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
DOCKER_BUILDKIT=1 docker build \
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
@@ -44,6 +44,8 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
# When detecting podman-docker, `--external` should be added.
docker image prune --force --filter "label=$CI_IMAGE_LABEL"
+ # Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
+ # to allow support starting multiple runs simultaneously by the same user.
# shellcheck disable=SC2086
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
@@ -52,7 +54,7 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
--mount "type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources" \
--mount "type=volume,src=${CONTAINER_NAME}_depends_SDKs_android,dst=$DEPENDS_DIR/SDKs/android" \
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
- --env-file /tmp/env \
+ --env-file /tmp/env-$USER-$CONTAINER_NAME \
--name "$CONTAINER_NAME" \
"$CONTAINER_NAME")
export CI_CONTAINER_ID