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"