Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 43 additions & 11 deletions ci/test/02_run_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,26 @@ 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)

# Modify PATH to prepend the retry script, needed for CI_RETRY_EXE
os.environ["PATH"] = f"{os.environ['BASE_ROOT_DIR']}/ci/retry:{os.environ['PATH']}"
# GNU getopt is required for the CI_RETRY_EXE script
if os.getenv("CI_OS_NAME") == "macos":
prefix = run(
["brew", "--prefix", "gnu-getopt"],
stdout=subprocess.PIPE,
text=True,
).stdout.strip()
os.environ["IN_GETOPT_BIN"] = f"{prefix}/bin/getopt"
else:
CI_IMAGE_LABEL = "bitcoin-ci-test"

# Use buildx unconditionally
Expand Down Expand Up @@ -143,18 +162,31 @@ def main():
stdout=subprocess.PIPE,
text=True,
).stdout.strip()
os.environ["CI_CONTAINER_ID"] = container_id

# GNU getopt is required for the CI_RETRY_EXE script
if os.getenv("CI_OS_NAME") == "macos":
prefix = run(
["brew", "--prefix", "gnu-getopt"],
stdout=subprocess.PIPE,
text=True,
).stdout.strip()
os.environ["IN_GETOPT_BIN"] = f"{prefix}/bin/getopt"
def ci_exec(cmd_inner, **kwargs):
if os.getenv("DANGER_RUN_CI_ON_HOST"):
prefix = []
else:
prefix = ["docker", "exec", container_id]
Comment thread
maflcko marked this conversation as resolved.

return run([*prefix, *cmd_inner], **kwargs)

# Normalize all folders to BASE_ROOT_DIR
ci_exec([
Comment thread
maflcko marked this conversation as resolved.
"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"])

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__":
Expand Down
33 changes: 0 additions & 33 deletions ci/test/02_run_container.sh

This file was deleted.

3 changes: 3 additions & 0 deletions ci/test/03_test_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export LC_ALL=C.UTF-8

set -ex

cd "${BASE_ROOT_DIR}"

export PATH="/path_with space:${PATH}"
export ASAN_OPTIONS="detect_leaks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan"
export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1:second_deadlock_stack=1"
Expand Down
1 change: 1 addition & 0 deletions ci/test_imagefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ENV FILE_ENV=${FILE_ENV}
ARG BASE_ROOT_DIR
ENV BASE_ROOT_DIR=${BASE_ROOT_DIR}

# Make retry available in PATH, needed for CI_RETRY_EXE
COPY ./ci/retry/retry /usr/bin/retry
COPY ./ci/test/00_setup_env.sh ./${FILE_ENV} ./ci/test/01_base_install.sh /ci_container_base/ci/test/

Expand Down
Loading