Skip to content

Commit c4d4877

Browse files
committed
Squashed 'libbitcoinkernel-sys/bitcoin/' changes from 6c7a34f3b0bd..5c5704e73079
5c5704e73079 Merge bitcoin/bitcoin#33791: kernel: Use enumeration type for flags argument ed5720509f03 kernel: Use enumeration type for flags argument 50d106a4d6ac Merge bitcoin/bitcoin#33781: clang-tidy: Remove no longer needed NOLINT ffd7ca3c4688 Merge bitcoin/bitcoin#33780: guix: disable libsanitizer in Linux GCC build 33389f1144e6 Merge bitcoin-core/gui#899: Modernize custom filtering 038849e2e09b clang-tidy: Remove no longer needed NOLINT 5c41fa2918c8 guix: disable libsanitizer in Linux GCC build 4da01123df0f Merge bitcoin/bitcoin#30595: kernel: Introduce C header API 96614fff6327 Merge bitcoin/bitcoin#33714: random: scope environ extern to macOS, BSDs and Illumos 4e9bd579d3ed Merge bitcoin/bitcoin#33045: depends: disable variables, rules and suffixes. 5ffa63d6814d Merge bitcoin/bitcoin#33626: ci: run native fuzz with MSAN job 75baff98fcf9 Merge bitcoin/bitcoin#33744: ci: Fix lint runner selection (and docker cache) 2593ed1b5f4b Merge bitcoin/bitcoin#33574: doc: update Guix INSTALL.md 1cd8d9fe5cd5 Merge bitcoin/bitcoin#33445: ci: Update Clang in "tidy" job 56329beaee27 Merge bitcoin/bitcoin#32301: test: cover invalid codesep positions for signature in taproot 1e6e32fa8a64 ci: run native fuzz with MSAN job 3784d15bcd50 ci: use LLVM libcxx 21.1.5 e15e8cbadad5 qt: Modernize custom filtering 745eb053a41c Merge bitcoin-core/gui#901: Add createwallet, createwalletdescriptor, and migratewallet to history filter 52b1595850f6 depends: disable builtin variables 8b5a28fa7893 depends: disable builtin rules and suffixes. 7632e0ba312a ci: fix configure docker action inputs 746d36cc80f0 Merge bitcoin/bitcoin#33754: ci: gha: Set debug_pull_request_number_str annotation 25c45bb0d0bd Merge bitcoin/bitcoin#33567: node: change a tx-relay on/off flag to enum 422b468229f1 Merge bitcoin/bitcoin#33683: refactor/doc: Add blockman param to GetTransaction doc comment da6f041e39ef Merge bitcoin/bitcoin#31645: [IBD] coins: increase default UTXO flush batch size to 32 MiB 832a57673af7 Merge bitcoin/bitcoin#33749: test: ipc: resolve symlinks in `which capnp` 3cd4263bf664 Merge bitcoin/bitcoin#33753: test: Format strings in `test_runner` 78d4d36730d4 test: Format strings in `*.rs` fa9d0f994b45 ci: gha: Set debug_pull_request_number_str annotation 305384a0372a Merge bitcoin/bitcoin#33746: ci: Add missing python3-dev package for riscv64 8eda7210eb33 Merge bitcoin/bitcoin#33743: fuzz: refactor memcpy to std::ranges::copy to work around ubsan warn 51093d6ae1d4 test: resolve symlinks in which result for capnp 6f359695c36c Merge bitcoin/bitcoin#33698: test: Use same rpc timeout for authproxy and cli c281bb6837b0 Merge bitcoin/bitcoin#32924: test: add valid tx test with minimum-sized ECDSA signature (8 bytes DER-encoded) facf8b771a19 ci: Add missing python3-dev package for riscv64 b4d0288c467f doc: update Guix INSTALL.md 0b3b8a3be1a0 ci: fix lint docker caching fa4b52bd1618 fuzz: refactor memcpy to std::ranges::copy to work around ubsan warn 72511fd02e72 Merge bitcoin/bitcoin#33555: build: Bump clang minimum supported version to 17 79d6f458e230 random: scope environ extern to macOS, BSDs and Illumos 292ea0eb8982 Merge bitcoin/bitcoin#33677: ci: Retry image building once on failure dd82c6c5d09f Merge bitcoin/bitcoin#33693: ci: use pycapnp 2.2.1 5d784bebaff5 clang-tidy: Disable `ArrayBound` check in src/ipc and src/test 5efdb0ef3056 ci: Update Clang in "tidy" job 53b34c80c631 ci: use pycapnp 2.2.1 in mac native job 865432869c0d ci: remove Python version comment from mac config 1a1f46c22859 refactor/doc: Add blockman param to `GetTransaction` doc comment and reorder out param 66667d651229 test: Use same rpc timeout for authproxy and cli 5555bce994b6 ci: Document why IN_GETOPT_BIN env var is needed on macOS fabe516440c9 ci: Export the container id in python script fa6aa9f42faa ci: Retry image building once on failure fa4dbe04d782 ci: Allow overwriting check option in run() helper fa8e4de5c31d ci: Use os.environ[key] access when value must be set 07a926474b5a node: change a tx-relay on/off flag to enum 4e352efa2ce7 qt: add createwallet, createwalletdescriptor, and migratewallet to history filter fa0fa0f70087 refactor: Revert "disable self-assign warning for tests" faed118fb30f build: Bump clang minimum supported version to 17 b6f8c48946cb coins: increase default `dbbatchsize` to 32 MiB 8bbb7b8bf8e3 refactor: Extract default batch size into kernel 81e5c8385b9e test: cover invalid codesep positions for signature in taproot 5fa81e239a39 test: add valid tx test with minimum-sized ECDSA signature (8 bytes DER-encoded) git-subtree-dir: libbitcoinkernel-sys/bitcoin git-subtree-split: 5c5704e730796c6f31e2d7891bf6334674a04219
1 parent 29c3b09 commit c4d4877

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+397
-245
lines changed

.github/actions/configure-docker/action.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@ inputs:
44
cache-provider:
55
description: 'gha or cirrus cache provider'
66
required: true
7-
options:
8-
- gh
9-
- cirrus
107
runs:
118
using: 'composite'
129
steps:
10+
- name: Check inputs
11+
shell: bash
12+
run: |
13+
# We expect only gha or cirrus as inputs to cache-provider
14+
case "${{ inputs.cache-provider }}" in
15+
gha|cirrus)
16+
;;
17+
*)
18+
echo "::warning title=Unknown input to configure docker action::Provided value was ${{ inputs.cache-provider }}"
19+
;;
20+
esac
21+
1322
- name: Set up Docker Buildx
1423
uses: docker/setup-buildx-action@v3
1524
with:

.github/workflows/ci.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ jobs:
3535
outputs:
3636
provider: ${{ steps.runners.outputs.provider }}
3737
steps:
38+
- name: Annotate with pull request number
39+
# This annotation is machine-readable and can be used to assign a check
40+
# run to its corresponding pull request. Running in one check run is
41+
# sufficient for each check suite.
42+
run: |
43+
if [ "${{ github.event_name }}" = "pull_request" ]; then
44+
echo "::notice title=debug_pull_request_number_str::${{ github.event.number }}"
45+
fi
3846
- id: runners
3947
run: |
4048
if [[ "${REPO_USE_CIRRUS_RUNNERS}" == "${{ github.repository }}" ]]; then
@@ -157,11 +165,6 @@ jobs:
157165
brew install --quiet python@3 || brew link --overwrite python@3
158166
brew install --quiet coreutils ninja pkgconf gnu-getopt ccache boost libevent zeromq qt@6 qrencode capnp
159167
160-
- name: Install Python packages
161-
run: |
162-
git clone -b v2.1.0 https://github.com/capnproto/pycapnp
163-
pip3 install ./pycapnp -C force-bundled-libcapnp=True --break-system-packages
164-
165168
- name: Set Ccache directory
166169
run: echo "CCACHE_DIR=${RUNNER_TEMP}/ccache_dir" >> "$GITHUB_ENV"
167170

@@ -531,6 +534,12 @@ jobs:
531534
timeout-minutes: 120
532535
file-env: './ci/test/00_setup_env_native_tsan.sh'
533536

537+
- name: 'MSan, fuzz'
538+
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-md'
539+
fallback-runner: 'ubuntu-24.04'
540+
timeout-minutes: 150
541+
file-env: './ci/test/00_setup_env_native_fuzz_with_msan.sh'
542+
534543
- name: 'MSan, depends'
535544
cirrus-runner: 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-lg'
536545
fallback-runner: 'ubuntu-24.04'
@@ -559,7 +568,7 @@ jobs:
559568
run: sed -i "s|\${INSTALL_BCC_TRACING_TOOLS}|true|g" ./ci/test/00_setup_env_native_asan.sh
560569

561570
- name: Set mmap_rnd_bits
562-
if: ${{ env.CONTAINER_NAME == 'ci_native_tsan' || env.CONTAINER_NAME == 'ci_native_msan' }}
571+
if: ${{ env.CONTAINER_NAME == 'ci_native_tsan' || env.CONTAINER_NAME == 'ci_native_msan' || env.CONTAINER_NAME == 'ci_native_fuzz_msan' }}
563572
# Prevents crashes due to high ASLR entropy
564573
run: sudo sysctl -w vm.mmap_rnd_bits=28
565574

@@ -572,7 +581,7 @@ jobs:
572581
lint:
573582
name: 'lint'
574583
needs: runners
575-
runs-on: ${{ needs.runners.outputs.use-cirrus-runners == 'true' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-xs' || 'ubuntu-24.04' }}
584+
runs-on: ${{ needs.runners.outputs.provider == 'cirrus' && 'ghcr.io/cirruslabs/ubuntu-runner-amd64:24.04-xs' || 'ubuntu-24.04' }}
576585
if: ${{ vars.SKIP_BRANCH_PUSH != 'true' || github.event_name == 'pull_request' }}
577586
timeout-minutes: 20
578587
env:

ci/test/00_setup_env.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out}
6464
# The folder for previous release binaries.
6565
# This folder exists only on the ci guest, and on the ci host as a volume.
6666
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/prev_releases}
67-
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3 rsync git procps bison e2fsprogs cmake ninja-build}
67+
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential pkgconf curl ca-certificates ccache python3-dev rsync git procps bison e2fsprogs cmake ninja-build}
6868
export GOAL=${GOAL:-install}
6969
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_SCRATCH_DIR}/qa-assets}
7070
export CI_RETRY_EXE=${CI_RETRY_EXE:-"retry --"}

ci/test/00_setup_env_mac_native.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66

77
export LC_ALL=C.UTF-8
88

9-
# Homebrew's [email protected] is marked as externally managed (PEP 668).
10-
# Therefore, `--break-system-packages` is needed.
119
export CONTAINER_NAME="ci_mac_native" # macos does not use a container, but the env var is needed for logging
12-
export PIP_PACKAGES="--break-system-packages zmq"
10+
export PIP_PACKAGES="--break-system-packages pycapnp zmq"
1311
export GOAL="install deploy"
1412
export CMAKE_GENERATOR="Ninja"
1513
export BITCOIN_CONFIG="-DBUILD_GUI=ON -DWITH_ZMQ=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_TEST=ON -DREDUCE_EXPORTS=ON -DCMAKE_EXE_LINKER_FLAGS='-Wl,-stack_size -Wl,0x80000'"

ci/test/00_setup_env_native_alpine_musl.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_alpine_musl
1010
export CI_IMAGE_NAME_TAG="mirror.gcr.io/alpine:3.22"
11-
export CI_BASE_PACKAGES="build-base musl-dev pkgconf curl ccache make ninja git python3 py3-pip which patch xz procps rsync util-linux bison e2fsprogs cmake dash linux-headers"
11+
export CI_BASE_PACKAGES="build-base musl-dev pkgconf curl ccache make ninja git python3-dev py3-pip which patch xz procps rsync util-linux bison e2fsprogs cmake dash linux-headers"
1212
export PIP_PACKAGES="--break-system-packages pyzmq pycapnp"
1313
export DEP_OPTS="DEBUG=1"
1414
export GOAL="install"

ci/test/00_setup_env_native_nowallet_libbitcoinkernel.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
export LC_ALL=C.UTF-8
88

99
export CONTAINER_NAME=ci_native_nowallet_libbitcoinkernel
10-
export CI_IMAGE_NAME_TAG="mirror.gcr.io/debian:bookworm"
11-
# Use minimum supported python3.10 (or best-effort 3.11) and clang-16, see doc/dependencies.md
12-
export PACKAGES="python3-zmq python3-pip clang-16 llvm-16 libc++abi-16-dev libc++-16-dev"
10+
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
11+
# Use minimum supported python3.10 (or best-effort 3.12) and clang-17, see doc/dependencies.md
12+
export PACKAGES="python3-zmq python3-pip clang-17 llvm-17 libc++abi-17-dev libc++-17-dev"
1313
export PIP_PACKAGES="--break-system-packages pycapnp"
14-
export DEP_OPTS="NO_WALLET=1 CC=clang-16 CXX='clang++-16 -stdlib=libc++'"
14+
export DEP_OPTS="NO_WALLET=1 CC=clang-17 CXX='clang++-17 -stdlib=libc++'"
1515
export GOAL="install"
1616
export BITCOIN_CONFIG="-DREDUCE_EXPORTS=ON -DBUILD_UTIL_CHAINSTATE=ON -DBUILD_KERNEL_LIB=ON -DBUILD_KERNEL_TEST=ON -DBUILD_SHARED_LIBS=ON"

ci/test/00_setup_env_native_tidy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8
88

99
export CI_IMAGE_NAME_TAG="mirror.gcr.io/ubuntu:24.04"
1010
export CONTAINER_NAME=ci_native_tidy
11-
export TIDY_LLVM_V="20"
11+
export TIDY_LLVM_V="21"
1212
export APT_LLVM_V="${TIDY_LLVM_V}"
1313
export PACKAGES="clang-${TIDY_LLVM_V} libclang-${TIDY_LLVM_V}-dev llvm-${TIDY_LLVM_V}-dev libomp-${TIDY_LLVM_V}-dev clang-tidy-${TIDY_LLVM_V} jq libevent-dev libboost-dev libzmq3-dev systemtap-sdt-dev qt6-base-dev qt6-tools-dev qt6-l10n-tools libqrencode-dev libsqlite3-dev libcapnp-dev capnproto"
1414
export NO_DEPENDS=1

ci/test/01_base_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ if [ -n "$PIP_PACKAGES" ]; then
5757
fi
5858

5959
if [[ -n "${USE_INSTRUMENTED_LIBCPP}" ]]; then
60-
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-21.1.1" /llvm-project
60+
${CI_RETRY_EXE} git clone --depth=1 https://github.com/llvm/llvm-project -b "llvmorg-21.1.5" /llvm-project
6161

6262
cmake -G Ninja -B /cxx_build/ \
6363
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \

ci/test/02_run_container.py

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@
33
# Distributed under the MIT software license, see the accompanying
44
# file COPYING or https://opensource.org/license/mit/.
55

6+
from pathlib import Path
67
import os
78
import shlex
89
import subprocess
910
import sys
11+
import time
1012

1113

1214
def run(cmd, **kwargs):
1315
print("+ " + shlex.join(cmd), flush=True)
16+
kwargs.setdefault("check", True)
1417
try:
15-
return subprocess.run(cmd, check=True, **kwargs)
18+
return subprocess.run(cmd, **kwargs)
1619
except Exception as e:
1720
sys.exit(e)
1821

@@ -36,8 +39,8 @@ def main():
3639
# Append $USER to /tmp/env to support multi-user systems and $CONTAINER_NAME
3740
# to allow support starting multiple runs simultaneously by the same user.
3841
env_file = "/tmp/env-{u}-{c}".format(
39-
u=os.getenv("USER"),
40-
c=os.getenv("CONTAINER_NAME"),
42+
u=os.environ["USER"],
43+
c=os.environ["CONTAINER_NAME"],
4144
)
4245
with open(env_file, "w", encoding="utf8") as file:
4346
for k, v in os.environ.items():
@@ -64,7 +67,92 @@ def main():
6467
cmd_build += [os.environ["BASE_READ_ONLY_DIR"]]
6568

6669
print(f"Building {os.environ['CONTAINER_NAME']} image tag to run in")
67-
run(cmd_build)
70+
if run(cmd_build, check=False).returncode != 0:
71+
print(f"Retry building {os.environ['CONTAINER_NAME']} image tag after failure")
72+
time.sleep(3)
73+
run(cmd_build)
74+
75+
for suffix in ["ccache", "depends", "depends_sources", "previous_releases"]:
76+
run(["docker", "volume", "create", f"{os.environ['CONTAINER_NAME']}_{suffix}"], check=False)
77+
78+
CI_CCACHE_MOUNT = f"type=volume,src={os.environ['CONTAINER_NAME']}_ccache,dst={os.environ['CCACHE_DIR']}"
79+
CI_DEPENDS_MOUNT = f"type=volume,src={os.environ['CONTAINER_NAME']}_depends,dst={os.environ['DEPENDS_DIR']}/built"
80+
CI_DEPENDS_SOURCES_MOUNT = f"type=volume,src={os.environ['CONTAINER_NAME']}_depends_sources,dst={os.environ['DEPENDS_DIR']}/sources"
81+
CI_PREVIOUS_RELEASES_MOUNT = f"type=volume,src={os.environ['CONTAINER_NAME']}_previous_releases,dst={os.environ['PREVIOUS_RELEASES_DIR']}"
82+
CI_BUILD_MOUNT = []
83+
84+
if os.getenv("DANGER_CI_ON_HOST_FOLDERS"):
85+
# ensure the directories exist
86+
for create_dir in [
87+
os.environ["CCACHE_DIR"],
88+
f"{os.environ['DEPENDS_DIR']}/built",
89+
f"{os.environ['DEPENDS_DIR']}/sources",
90+
os.environ["PREVIOUS_RELEASES_DIR"],
91+
os.environ["BASE_BUILD_DIR"], # Unset by default, must be defined externally
92+
]:
93+
Path(create_dir).mkdir(parents=True, exist_ok=True)
94+
95+
CI_CCACHE_MOUNT = f"type=bind,src={os.environ['CCACHE_DIR']},dst={os.environ['CCACHE_DIR']}"
96+
CI_DEPENDS_MOUNT = f"type=bind,src={os.environ['DEPENDS_DIR']}/built,dst={os.environ['DEPENDS_DIR']}/built"
97+
CI_DEPENDS_SOURCES_MOUNT = f"type=bind,src={os.environ['DEPENDS_DIR']}/sources,dst={os.environ['DEPENDS_DIR']}/sources"
98+
CI_PREVIOUS_RELEASES_MOUNT = f"type=bind,src={os.environ['PREVIOUS_RELEASES_DIR']},dst={os.environ['PREVIOUS_RELEASES_DIR']}"
99+
CI_BUILD_MOUNT = [f"--mount=type=bind,src={os.environ['BASE_BUILD_DIR']},dst={os.environ['BASE_BUILD_DIR']}"]
100+
101+
if os.getenv("DANGER_CI_ON_HOST_CCACHE_FOLDER"):
102+
if not os.path.isdir(os.environ["CCACHE_DIR"]):
103+
print(f"Error: Directory '{os.environ['CCACHE_DIR']}' must be created in advance.")
104+
sys.exit(1)
105+
CI_CCACHE_MOUNT = f"type=bind,src={os.environ['CCACHE_DIR']},dst={os.environ['CCACHE_DIR']}"
106+
107+
run(["docker", "network", "create", "--ipv6", "--subnet", "1111:1111::/112", "ci-ip6net"], check=False)
108+
109+
if os.getenv("RESTART_CI_DOCKER_BEFORE_RUN"):
110+
print("Restart docker before run to stop and clear all containers started with --rm")
111+
run(["podman", "container", "rm", "--force", "--all"]) # Similar to "systemctl restart docker"
112+
113+
# Still prune everything in case the filtered pruning doesn't work, or if labels were not set
114+
# on a previous run. Belt and suspenders approach, should be fine to remove in the future.
115+
# Prune images used by --external containers (e.g. build containers) when
116+
# using podman.
117+
print("Prune all dangling images")
118+
run(["podman", "image", "prune", "--force", "--external"])
119+
120+
print(f"Prune all dangling {CI_IMAGE_LABEL} images")
121+
# When detecting podman-docker, `--external` should be added.
122+
run(["docker", "image", "prune", "--force", "--filter", f"label={CI_IMAGE_LABEL}"])
123+
124+
cmd_run = ["docker", "run", "--rm", "--interactive", "--detach", "--tty"]
125+
cmd_run += [
126+
"--cap-add=LINUX_IMMUTABLE",
127+
*shlex.split(os.getenv("CI_CONTAINER_CAP", "")),
128+
f"--mount=type=bind,src={os.environ['BASE_READ_ONLY_DIR']},dst={os.environ['BASE_READ_ONLY_DIR']},readonly",
129+
f"--mount={CI_CCACHE_MOUNT}",
130+
f"--mount={CI_DEPENDS_MOUNT}",
131+
f"--mount={CI_DEPENDS_SOURCES_MOUNT}",
132+
f"--mount={CI_PREVIOUS_RELEASES_MOUNT}",
133+
*CI_BUILD_MOUNT,
134+
f"--env-file={env_file}",
135+
f"--name={os.environ['CONTAINER_NAME']}",
136+
"--network=ci-ip6net",
137+
f"--platform={os.environ['CI_IMAGE_PLATFORM']}",
138+
os.environ["CONTAINER_NAME"],
139+
]
140+
141+
container_id = run(
142+
cmd_run,
143+
stdout=subprocess.PIPE,
144+
text=True,
145+
).stdout.strip()
146+
os.environ["CI_CONTAINER_ID"] = container_id
147+
148+
# GNU getopt is required for the CI_RETRY_EXE script
149+
if os.getenv("CI_OS_NAME") == "macos":
150+
prefix = run(
151+
["brew", "--prefix", "gnu-getopt"],
152+
stdout=subprocess.PIPE,
153+
text=True,
154+
).stdout.strip()
155+
os.environ["IN_GETOPT_BIN"] = f"{prefix}/bin/getopt"
68156

69157
run(["./ci/test/02_run_container.sh"]) # run the remainder
70158

ci/test/02_run_container.sh

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,76 +5,10 @@
55
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
66

77
export LC_ALL=C.UTF-8
8-
export CI_IMAGE_LABEL="bitcoin-ci-test"
98

109
set -o errexit -o pipefail -o xtrace
1110

1211
if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
13-
docker volume create "${CONTAINER_NAME}_ccache" || true
14-
docker volume create "${CONTAINER_NAME}_depends" || true
15-
docker volume create "${CONTAINER_NAME}_depends_sources" || true
16-
docker volume create "${CONTAINER_NAME}_previous_releases" || true
17-
18-
CI_CCACHE_MOUNT="type=volume,src=${CONTAINER_NAME}_ccache,dst=$CCACHE_DIR"
19-
CI_DEPENDS_MOUNT="type=volume,src=${CONTAINER_NAME}_depends,dst=$DEPENDS_DIR/built"
20-
CI_DEPENDS_SOURCES_MOUNT="type=volume,src=${CONTAINER_NAME}_depends_sources,dst=$DEPENDS_DIR/sources"
21-
CI_PREVIOUS_RELEASES_MOUNT="type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR"
22-
CI_BUILD_MOUNT=""
23-
24-
if [ "$DANGER_CI_ON_HOST_FOLDERS" ]; then
25-
# ensure the directories exist
26-
mkdir -p "${CCACHE_DIR}"
27-
mkdir -p "${DEPENDS_DIR}/built"
28-
mkdir -p "${DEPENDS_DIR}/sources"
29-
mkdir -p "${PREVIOUS_RELEASES_DIR}"
30-
mkdir -p "${BASE_BUILD_DIR}" # Unset by default, must be defined externally
31-
32-
CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=$CCACHE_DIR"
33-
CI_DEPENDS_MOUNT="type=bind,src=${DEPENDS_DIR}/built,dst=$DEPENDS_DIR/built"
34-
CI_DEPENDS_SOURCES_MOUNT="type=bind,src=${DEPENDS_DIR}/sources,dst=$DEPENDS_DIR/sources"
35-
CI_PREVIOUS_RELEASES_MOUNT="type=bind,src=${PREVIOUS_RELEASES_DIR},dst=$PREVIOUS_RELEASES_DIR"
36-
CI_BUILD_MOUNT="--mount type=bind,src=${BASE_BUILD_DIR},dst=${BASE_BUILD_DIR}"
37-
fi
38-
39-
if [ "$DANGER_CI_ON_HOST_CCACHE_FOLDER" ]; then
40-
if [ ! -d "${CCACHE_DIR}" ]; then
41-
echo "Error: Directory '${CCACHE_DIR}' must be created in advance."
42-
exit 1
43-
fi
44-
CI_CCACHE_MOUNT="type=bind,src=${CCACHE_DIR},dst=${CCACHE_DIR}"
45-
fi
46-
47-
docker network create --ipv6 --subnet 1111:1111::/112 ci-ip6net || true
48-
49-
if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then
50-
echo "Restart docker before run to stop and clear all containers started with --rm"
51-
podman container rm --force --all # Similar to "systemctl restart docker"
52-
53-
# Still prune everything in case the filtered pruning doesn't work, or if labels were not set
54-
# on a previous run. Belt and suspenders approach, should be fine to remove in the future.
55-
# Prune images used by --external containers (e.g. build containers) when
56-
# using podman.
57-
echo "Prune all dangling images"
58-
podman image prune --force --external
59-
fi
60-
echo "Prune all dangling $CI_IMAGE_LABEL images"
61-
# When detecting podman-docker, `--external` should be added.
62-
docker image prune --force --filter "label=$CI_IMAGE_LABEL"
63-
64-
# shellcheck disable=SC2086
65-
CI_CONTAINER_ID=$(docker run --cap-add LINUX_IMMUTABLE $CI_CONTAINER_CAP --rm --interactive --detach --tty \
66-
--mount "type=bind,src=$BASE_READ_ONLY_DIR,dst=$BASE_READ_ONLY_DIR,readonly" \
67-
--mount "${CI_CCACHE_MOUNT}" \
68-
--mount "${CI_DEPENDS_MOUNT}" \
69-
--mount "${CI_DEPENDS_SOURCES_MOUNT}" \
70-
--mount "${CI_PREVIOUS_RELEASES_MOUNT}" \
71-
${CI_BUILD_MOUNT} \
72-
--env-file /tmp/env-$USER-$CONTAINER_NAME \
73-
--name "$CONTAINER_NAME" \
74-
--network ci-ip6net \
75-
--platform="${CI_IMAGE_PLATFORM}" \
76-
"$CONTAINER_NAME")
77-
export CI_CONTAINER_ID
7812
export CI_EXEC_CMD_PREFIX="docker exec ${CI_CONTAINER_ID}"
7913
else
8014
echo "Running on host system without docker wrapper"
@@ -83,11 +17,6 @@ else
8317
mkdir -p "${PREVIOUS_RELEASES_DIR}"
8418
fi
8519

86-
if [ "$CI_OS_NAME" == "macos" ]; then
87-
IN_GETOPT_BIN="$(brew --prefix gnu-getopt)/bin/getopt"
88-
export IN_GETOPT_BIN
89-
fi
90-
9120
CI_EXEC () {
9221
$CI_EXEC_CMD_PREFIX bash -c "export PATH=\"/path_with space:${BINS_SCRATCH_DIR}:${BASE_ROOT_DIR}/ci/retry:\$PATH\" && cd \"${BASE_ROOT_DIR}\" && $*"
9322
}

0 commit comments

Comments
 (0)