From fa336053aada79d13cd771ce025857256814465e Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 29 Oct 2025 13:11:04 +0100 Subject: [PATCH] Move ci_exec to the Python script The Bash script was acceptable, but CI_EXEC_CMD_PREFIX was a single string, relying on brittle word splitting that the shellcheck SC2086 would warn about. So just fix that by moving everything to the Python script and deleting the Bash script. This also removes the need to export the CI_CONTAINER_ID env var. --- ci/test/02_run_container.py | 23 +++++++++++++++++++++-- ci/test/02_run_container.sh | 23 ----------------------- 2 files changed, 21 insertions(+), 25 deletions(-) delete mode 100755 ci/test/02_run_container.sh diff --git a/ci/test/02_run_container.py b/ci/test/02_run_container.py index 377ccfa9cfd..d9ef27b490a 100755 --- a/ci/test/02_run_container.py +++ b/ci/test/02_run_container.py @@ -162,9 +162,28 @@ def main(): stdout=subprocess.PIPE, text=True, ).stdout.strip() - os.environ["CI_CONTAINER_ID"] = container_id - run(["./ci/test/02_run_container.sh"]) # run the remainder + def ci_exec(cmd_inner, **kwargs): + if os.getenv("DANGER_RUN_CI_ON_HOST"): + prefix = [] + else: + prefix = ["docker", "exec", container_id] + + return run([*prefix, *cmd_inner], **kwargs) + + # Normalize all folders to BASE_ROOT_DIR + ci_exec([ + "rsync", + "--recursive", + "--perms", + "--stats", + "--human-readable", + f"{os.environ['BASE_READ_ONLY_DIR']}/", + f"{os.environ['BASE_ROOT_DIR']}", + ]) + ci_exec([f"{os.environ['BASE_ROOT_DIR']}/ci/test/01_base_install.sh"]) + ci_exec([f"{os.environ['BASE_ROOT_DIR']}/ci/test/03_test_script.sh"]) + if not os.getenv("DANGER_RUN_CI_ON_HOST"): print("Stop and remove CI container by ID") run(["docker", "container", "kill", container_id]) diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh deleted file mode 100755 index 9771065e0ee..00000000000 --- a/ci/test/02_run_container.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright (c) 2018-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 -o pipefail -o xtrace - -if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then - export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}" -fi - -CI_EXEC () { - $CI_EXEC_CMD_PREFIX "$@" -} -export -f CI_EXEC - -# Normalize all folders to BASE_ROOT_DIR -CI_EXEC rsync --recursive --perms --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" -CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh" -CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh"