From fac9abbf475a1de6f9f39ddede9a6a59bbd1cff4 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 28 Sep 2023 11:05:28 +0200 Subject: [PATCH 1/4] ci: Rename 04_install to 02_run_container This reflects what the script does (docker run ...). --- ci/test/{04_install.sh => 02_run_container.sh} | 0 ci/test_run_all.sh | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename ci/test/{04_install.sh => 02_run_container.sh} (100%) diff --git a/ci/test/04_install.sh b/ci/test/02_run_container.sh similarity index 100% rename from ci/test/04_install.sh rename to ci/test/02_run_container.sh diff --git a/ci/test_run_all.sh b/ci/test_run_all.sh index 2284a2903b7..efc524eb809 100755 --- a/ci/test_run_all.sh +++ b/ci/test_run_all.sh @@ -1,13 +1,13 @@ #!/usr/bin/env bash # -# Copyright (c) 2019-2020 The Bitcoin Core developers +# Copyright (c) 2019-present The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. export LC_ALL=C.UTF-8 set -o errexit; source ./ci/test/00_setup_env.sh -set -o errexit; source ./ci/test/04_install.sh +set -o errexit; source "./ci/test/02_run_container.sh" set -o errexit CI_EXEC "${BASE_ROOT_DIR}/ci/test/06_script_b.sh" From fa09a031c1eb8abcb9a04cacdf5629f95ffc77f8 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 4 Oct 2023 17:04:40 +0200 Subject: [PATCH 2/4] ci: Add set -ex to 02_run_container.sh The same is done by the 06 script. --- ci/test/02_run_container.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh index b5a84ae08d6..8602353b45a 100755 --- a/ci/test/02_run_container.sh +++ b/ci/test/02_run_container.sh @@ -6,6 +6,8 @@ export LC_ALL=C.UTF-8 +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. From fa695b4df069425414fd26b2ddc08d72a6b506f6 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 28 Sep 2023 11:18:31 +0200 Subject: [PATCH 3/4] ci: Work around podman stop bug Force remove any containers, pontentially leaving dangling processes, which should be fine. --- ci/test/02_run_container.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh index 8602353b45a..96fae733591 100755 --- a/ci/test/02_run_container.sh +++ b/ci/test/02_run_container.sh @@ -29,14 +29,12 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then echo "Restart docker before run to stop and clear all containers started with --rm" - podman container stop --all # Similar to "systemctl restart docker" + podman container rm --force --all # Similar to "systemctl restart docker" echo "Prune all dangling images" docker image prune --force fi # 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" \ --mount "type=volume,src=${CONTAINER_NAME}_ccache,dst=$CCACHE_DIR" \ From fa2c894cbb41a64371717139fb3c3ddfb9bb8b19 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Thu, 28 Sep 2023 13:35:02 +0200 Subject: [PATCH 4/4] ci: move-only CI_CONTAINER_ID to 02_run_container.sh This limits the scope of the CI_CONTAINER_ID symbol. Can be reviewed with --color-moved=dimmed-zebra --- ci/test/02_run_container.sh | 7 +++++++ ci/test_run_all.sh | 8 +------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh index 96fae733591..a7c1e22a6db 100755 --- a/ci/test/02_run_container.sh +++ b/ci/test/02_run_container.sh @@ -68,3 +68,10 @@ CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh" CI_EXEC git config --global --add safe.directory \"*\" CI_EXEC mkdir -p "${BINS_SCRATCH_DIR}" + +CI_EXEC "${BASE_ROOT_DIR}/ci/test/06_script_b.sh" + +if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then + echo "Stop and remove CI container by ID" + docker container kill "${CI_CONTAINER_ID}" +fi diff --git a/ci/test_run_all.sh b/ci/test_run_all.sh index efc524eb809..3afc47b23ed 100755 --- a/ci/test_run_all.sh +++ b/ci/test_run_all.sh @@ -7,11 +7,5 @@ export LC_ALL=C.UTF-8 set -o errexit; source ./ci/test/00_setup_env.sh -set -o errexit; source "./ci/test/02_run_container.sh" set -o errexit -CI_EXEC "${BASE_ROOT_DIR}/ci/test/06_script_b.sh" - -if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then - echo "Stop and remove CI container by ID" - docker container kill "${CI_CONTAINER_ID}" -fi +"./ci/test/02_run_container.sh"