From 666675e95fe823b7809f64508aea5b57b1867c19 Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Wed, 29 Oct 2025 11:46:09 +0100 Subject: [PATCH] ci: Move folder creation and docker kill to Python script The container_id is already known in the Python script, as well as the folders to create, so just do it there. --- ci/test/02_run_container.py | 13 ++++++++++++- ci/test/02_run_container.sh | 10 ---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ci/test/02_run_container.py b/ci/test/02_run_container.py index 4d0bed2ad41..79d9581be6f 100755 --- a/ci/test/02_run_container.py +++ b/ci/test/02_run_container.py @@ -48,7 +48,15 @@ def main(): file.write(f"{k}={v}\n") run(["cat", env_file]) - if not os.getenv("DANGER_RUN_CI_ON_HOST"): + if os.getenv("DANGER_RUN_CI_ON_HOST"): + print("Running on host system without docker wrapper") + print("Create missing folders") + for create_dir in [ + os.environ["CCACHE_DIR"], + os.environ["PREVIOUS_RELEASES_DIR"], + ]: + Path(create_dir).mkdir(parents=True, exist_ok=True) + else: CI_IMAGE_LABEL = "bitcoin-ci-test" # Use buildx unconditionally @@ -155,6 +163,9 @@ def main(): os.environ["IN_GETOPT_BIN"] = f"{prefix}/bin/getopt" run(["./ci/test/02_run_container.sh"]) # run the remainder + if not os.getenv("DANGER_RUN_CI_ON_HOST"): + print("Stop and remove CI container by ID") + run(["docker", "container", "kill", container_id]) if __name__ == "__main__": diff --git a/ci/test/02_run_container.sh b/ci/test/02_run_container.sh index 41128b5c023..f462db25f9c 100755 --- a/ci/test/02_run_container.sh +++ b/ci/test/02_run_container.sh @@ -10,11 +10,6 @@ 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}" -else - echo "Running on host system without docker wrapper" - echo "Create missing folders" - mkdir -p "${CCACHE_DIR}" - mkdir -p "${PREVIOUS_RELEASES_DIR}" fi CI_EXEC () { @@ -26,8 +21,3 @@ export -f CI_EXEC CI_EXEC rsync --recursive --perms --stats --human-readable "${BASE_READ_ONLY_DIR}/" "${BASE_ROOT_DIR}" || echo "Nothing to copy from ${BASE_READ_ONLY_DIR}/" CI_EXEC "${BASE_ROOT_DIR}/ci/test/01_base_install.sh" CI_EXEC "${BASE_ROOT_DIR}/ci/test/03_test_script.sh" - -if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then - echo "Stop and remove CI container by ID" - docker container kill "${CI_CONTAINER_ID}" -fi