ci: Move folder creation and docker kill to Python script
What changed, and why it matters
This commit is a routine cleanup of Bitcoin Core's continuous integration (CI) scripts. It moves some folder-creation and Docker cleanup logic from a shell script into an equivalent Python script. There is no user-facing change, no change to Bitcoin's consensus or networking code, and no security relevance.
No security action required. Review as normal CI maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change relocates logic in ci/test/02_run_container.sh (creating CCACHE_DIR and PREVIOUS_RELEASES_DIR when DANGER_RUN_CI_ON_HOST is set, and killing the Docker container after tests) into ci/test/02_run_container.py. The Python script already knows container_id and the directory variables, so the logic is duplicated there. Behavior is functionally identical; this is a refactor of CI internals.
Changed components
ci/test/02_run_container.pyci/test/02_run_container.shInspect captured patch +12 / −11
diff --git a/ci/test/02_run_container.py b/ci/test/02_run_container.py
index 4d0bed2a..79d9581b 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 41128b5c..f462db25 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
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.