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.
This commit is contained in:
MarcoFalke
2025-10-29 13:11:04 +01:00
parent fa83555d16
commit fa336053aa
2 changed files with 21 additions and 25 deletions

View File

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

View File

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