Skip to content

Commit 141115a

Browse files
Merge bitcoin/bitcoin#27033: ci: Cache stuff in volumes, not host folders
fa8e92c doc: Update ci docs (721217.xyz) 5fffff5 ci: Cache stuff in volumes, not host folders (MarcoFalke) Pull request description: Storing cached stuff in host system folders may lead to unexpected issues when the ci-built stuff is used for a non-ci build or a ci task leaks into another ci task. ACKs for top commit: john-moffett: ACK fa8e92c Tree-SHA512: 8b0c9019452fbe507a272c1037c3dce3c178c21f85ab1096ed3372ad9d4b3c7aa27d89e5bf80c9a6260ea652e0268be0cbe61d6a4fcb3add569fa38076d32287
2 parents a631659 + fa8e92c commit 141115a

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

ci/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Be aware that the tests will be built and run in-place, so please run at your ow
88
If the repository is not a fresh git clone, you might have to clean files from previous builds or test runs first.
99

1010
The ci needs to perform various sysadmin tasks such as installing packages or writing to the user's home directory.
11-
While most of the actions are done inside a docker container, this is not possible for all. Thus, cache directories,
12-
such as the depends cache, previous release binaries, or ccache, are mounted as read-write into the docker container. While it should be fine to run
11+
While it should be fine to run
1312
the ci system locally on you development box, the ci scripts can generally be assumed to have received less review and
1413
testing compared to other parts of the codebase. If you want to keep the work tree clean, you might want to run the ci
1514
system in a virtual machine with a Linux operating system of your choice.

ci/test/00_setup_env.sh

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

99
# The root dir.
1010
# The ci system copies this folder.
11-
# This is where the depends build is done.
1211
BASE_ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ >/dev/null 2>&1 && pwd )
1312
export BASE_ROOT_DIR
1413
# The depends dir.
15-
# This folder exists on the ci host and ci guest. Changes are propagated back and forth.
14+
# This folder exists only on the ci guest, and on the ci host as a volume.
1615
export DEPENDS_DIR=${DEPENDS_DIR:-$BASE_ROOT_DIR/depends}
1716
# A folder for the ci system to put temporary files (ccache, datadirs for tests, ...)
1817
# This folder only exists on the ci host.
@@ -58,12 +57,14 @@ export CCACHE_SIZE=${CCACHE_SIZE:-100M}
5857
export CCACHE_TEMPDIR=${CCACHE_TEMPDIR:-/tmp/.ccache-temp}
5958
export CCACHE_COMPRESS=${CCACHE_COMPRESS:-1}
6059
# The cache dir.
61-
# This folder exists on the ci host and ci guest. Changes are propagated back and forth.
60+
# This folder exists only on the ci guest, and on the ci host as a volume.
6261
export CCACHE_DIR=${CCACHE_DIR:-$BASE_SCRATCH_DIR/.ccache}
6362
# Folder where the build result is put (bin and lib).
6463
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_SCRATCH_DIR/out/$HOST}
6564
# Folder where the build is done (dist and out-of-tree build).
6665
export BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_SCRATCH_DIR/build}
66+
# The folder for previous release binaries.
67+
# This folder exists only on the ci guest, and on the ci host as a volume.
6768
export PREVIOUS_RELEASES_DIR=${PREVIOUS_RELEASES_DIR:-$BASE_ROOT_DIR/releases/$HOST}
6869
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
6970
export CI_BASE_PACKAGES=${CI_BASE_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git procps bison}

ci/test/04_install.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
3939
--build-arg "FILE_ENV=${FILE_ENV}" \
4040
--tag="${CONTAINER_NAME}" \
4141
"${BASE_ROOT_DIR}"
42+
docker volume create "${CONTAINER_NAME}_ccache" || true
43+
docker volume create "${CONTAINER_NAME}_depends" || true
44+
docker volume create "${CONTAINER_NAME}_previous_releases" || true
4245

4346
if [ -n "${RESTART_CI_DOCKER_BEFORE_RUN}" ] ; then
4447
echo "Restart docker before run to stop and clear all containers started with --rm"
@@ -48,9 +51,9 @@ if [ -z "$DANGER_RUN_CI_ON_HOST" ]; then
4851
# shellcheck disable=SC2086
4952
CI_CONTAINER_ID=$(docker run $CI_CONTAINER_CAP --rm --interactive --detach --tty \
5053
--mount type=bind,src=$BASE_ROOT_DIR,dst=/ro_base,readonly \
51-
--mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR \
52-
--mount type=bind,src=$DEPENDS_DIR,dst=$DEPENDS_DIR \
53-
--mount type=bind,src=$PREVIOUS_RELEASES_DIR,dst=$PREVIOUS_RELEASES_DIR \
54+
--mount "type=volume,src=${CONTAINER_NAME}_ccache,dst=$CCACHE_DIR" \
55+
--mount "type=volume,src=${CONTAINER_NAME}_depends,dst=$DEPENDS_DIR" \
56+
--mount "type=volume,src=${CONTAINER_NAME}_previous_releases,dst=$PREVIOUS_RELEASES_DIR" \
5457
-w $BASE_ROOT_DIR \
5558
--env-file /tmp/env \
5659
--name $CONTAINER_NAME \

0 commit comments

Comments
 (0)