Skip to content

Commit c65fde4

Browse files
committed
ci: vary /tmp/env
1 parent 03c5b00 commit c65fde4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ci/test/02_run_container.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ set -ex
1212
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
1313
# Export all env vars to avoid missing some.
1414
# Though, exclude those with newlines to avoid parsing problems.
15-
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
15+
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"
1616
# System-dependent env vars must be kept as is. So read them from the container.
17-
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append /tmp/env
17+
docker run --rm "${CI_IMAGE_NAME_TAG}" bash -c "env | grep --extended-regexp '^(HOME|PATH|USER)='" | tee --append "/tmp/env-$USER-$CONTAINER_NAME"
1818
echo "Creating $CI_IMAGE_NAME_TAG container to run in"
1919
DOCKER_BUILDKIT=1 docker build \
2020
--file "${BASE_READ_ONLY_DIR}/ci/test_imagefile" \
@@ -44,6 +44,8 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
4444
# When detecting podman-docker, `--external` should be added.
4545
docker image prune --force --filter "label=$CI_IMAGE_LABEL"
4646

47+
# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
48+
# to allow support starting multiple runs simultaneously by the same user.
4749
# shellcheck disable=SC2086
4850
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
4951
--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
5254
--mount "type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources" \
5355
--mount "type=volume,src=${CONTAINER_NAME}_depends_SDKs_android,dst=$DEPENDS_DIR/SDKs/android" \
5456
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
55-
--env-file /tmp/env \
57+
--env-file /tmp/env-$USER-$CONTAINER_NAME \
5658
--name "$CONTAINER_NAME" \
5759
"$CONTAINER_NAME")
5860
export CI_CONTAINER_ID

0 commit comments

Comments
 (0)