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.
This commit is contained in:
MarcoFalke
2025-10-29 11:46:09 +01:00
parent b30262dcaa
commit 666675e95f
2 changed files with 12 additions and 11 deletions

View File

@@ -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__":

View File

@@ -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