Skip to content

Commit 064f789

Browse files
MarcoFalkesidhujag
MarcoFalke
authored and
sidhujag
committed
Merge bitcoin#17423: ci: Make ci system read-only on the git work tree
fa7523d ci: Extend docs (MarcoFalke) fa493ef ci: Make ci system read-only on the git work tree (MarcoFalke) fab1333 ci: Remove git from required packages on host (MarcoFalke) fa00393 ci: Make all filesystem operations inside docker (MarcoFalke) Pull request description: Running the ci completely in a docker, without leaving any traces on the host system is not possible right now because the ccache and depends dir needs to be propagated back and picked up by the host for caching. Fixes bitcoin#17372 ACKs for top commit: JeremyRubin: tested ACK fa7523d Tree-SHA512: 4bce1a0f883bcbdb34abf409bdbc80d420c5da2045d2f9c5536ac433f9e5b490f23df084546c8c049f688b487572bbfc4f9c4029e9e672f4d9279739d066ed2e
1 parent bb4caf9 commit 064f789

6 files changed

+39
-20
lines changed

ci/README.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ and numbered according to which stage and lifecycle step it belongs to.
88

99
### Running a stage locally
1010

11+
Be aware that the tests will be built and run in-place, so please run at your own risk.
12+
If the repository is not a fresh git clone, you might have to clean files from previous builds or test runs first.
13+
14+
The ci needs to perform various sysadmin tasks such as installing packages or writing to the user's home directory.
15+
While most of the actions are done inside a docker container, this is not possible for all. Thus, cache directories,
16+
such as the depends cache or ccache, are mounted as read-write into the docker container. While it should be fine to run
17+
the ci system locally on you development box, the ci scripts can generally be assumed to have received less review and
18+
testing compared to other parts of the codebase. If you want to keep the work tree clean, you might want to run the ci
19+
system in a virtual machine with a Linux operating system of your choice.
20+
1121
To allow for a wide range of tested environments, but also ensure reproducibility to some extent, the test stage
1222
requires `docker` to be installed. To install all requirements on Ubuntu, run
1323

1424
```
15-
sudo apt install docker.io bash git
25+
sudo apt install docker.io bash
1626
```
1727

1828
To run the default test stage,
@@ -26,6 +36,3 @@ To run the test stage with a specific configuration,
2636
```
2737
FILE_ENV="./ci/test/00_setup_env_arm.sh" ./ci/test_run_all.sh
2838
```
29-
30-
Be aware that the tests will be build and run in-place, so please run at your own risk.
31-
If the repository is not a fresh git clone, you might have to clean files from previous builds or test runs first.

ci/test/00_setup_env.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export BASE_BUILD_DIR=${BASE_BUILD_DIR:-$BASE_ROOT_DIR}
4444
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_BUILD_DIR/out/$HOST}
4545
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
4646
export WINEDEBUG=${WINEDEBUG:-fixme-all}
47-
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3}
47+
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3 rsync git}
4848
export GOAL=${GOAL:-install}
4949
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_BUILD_DIR}/qa-assets}
5050
export PATH=${BASE_ROOT_DIR}/ci/retry:$PATH

ci/test/04_install.sh

+19-7
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ fi
3333
mkdir -p "${BASE_SCRATCH_DIR}"
3434
mkdir -p "${CCACHE_DIR}"
3535

36-
if [ ! -d ${DIR_QA_ASSETS} ]; then
37-
git clone https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
38-
fi
39-
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/
40-
41-
mkdir -p "${BASE_BUILD_DIR}/sanitizer-output/"
4236
export ASAN_OPTIONS="detect_stack_use_after_return=1"
4337
export LSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/lsan"
4438
export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan:log_path=${BASE_BUILD_DIR}/sanitizer-output/tsan"
@@ -54,7 +48,13 @@ if [ -z "$RUN_CI_ON_HOST" ]; then
5448
echo "Creating $DOCKER_NAME_TAG container to run in"
5549
${CI_RETRY_EXE} docker pull "$DOCKER_NAME_TAG"
5650

57-
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt --mount type=bind,src=$BASE_BUILD_DIR,dst=$BASE_BUILD_DIR --mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR -w $BASE_BUILD_DIR --env-file /tmp/env $DOCKER_NAME_TAG)
51+
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt \
52+
--mount type=bind,src=$BASE_BUILD_DIR,dst=/ro_base,readonly \
53+
--mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR \
54+
--mount type=bind,src=$BASE_BUILD_DIR/depends,dst=$BASE_BUILD_DIR/depends \
55+
-w $BASE_BUILD_DIR \
56+
--env-file /tmp/env \
57+
$DOCKER_NAME_TAG)
5858

5959
DOCKER_EXEC () {
6060
docker exec $DOCKER_ID bash -c "export PATH=$BASE_SCRATCH_DIR/bins/:\$PATH && cd $PWD && $*"
@@ -83,6 +83,18 @@ if [ "$TRAVIS_OS_NAME" != "osx" ]; then
8383
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -y $PACKAGES $DOCKER_PACKAGES
8484
fi
8585

86+
if [ ! -d ${DIR_QA_ASSETS} ]; then
87+
DOCKER_EXEC git clone https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
88+
fi
89+
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/
90+
91+
DOCKER_EXEC mkdir -p "${BASE_BUILD_DIR}/sanitizer-output/"
92+
93+
if [ -z "$RUN_CI_ON_HOST" ]; then
94+
echo "Create $BASE_BUILD_DIR"
95+
DOCKER_EXEC rsync -a /ro_base/ $BASE_BUILD_DIR
96+
fi
97+
8698
if [ "$USE_BUSY_BOX" = "true" ]; then
8799
echo "Setup to use BusyBox utils"
88100
DOCKER_EXEC mkdir -p $BASE_SCRATCH_DIR/bins/

ci/test/05_before_script.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ else
1313
DOCKER_EXEC echo \> \$HOME/.syscoin
1414
fi
1515

16-
mkdir -p depends/SDKs depends/sdk-sources
16+
DOCKER_EXEC mkdir -p depends/SDKs depends/sdk-sources
1717

1818
if [ -n "$OSX_SDK" ] && [ ! -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
1919
curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
2020
fi
2121
if [ -n "$OSX_SDK" ] && [ -f depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz ]; then
22-
tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
22+
DOCKER_EXEC tar -C depends/SDKs -xf depends/sdk-sources/MacOSX${OSX_SDK}.sdk.tar.gz
2323
fi
2424
if [[ $HOST = *-mingw32 ]]; then
2525
DOCKER_EXEC update-alternatives --set $HOST-g++ \$\(which $HOST-g++-posix\)

ci/test/06_script_a.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,22 @@ else
1919
fi
2020
END_FOLD
2121

22+
# Create folder on host and docker, so that `cd` works
2223
mkdir -p build
24+
DOCKER_EXEC mkdir -p build
2325

2426
# Temporarily disable errexit, because Travis macOS fails without error message
2527
set +o errexit
2628
cd build || (echo "could not enter build directory"; exit 1)
2729
set -o errexit
2830

2931
BEGIN_FOLD configure
30-
DOCKER_EXEC ../configure --cache-file=config.cache $SYSCOIN_CONFIG_ALL $SYSCOIN_CONFIG || ( cat config.log && false)
32+
DOCKER_EXEC ../configure --cache-file=config.cache $SYSCOIN_CONFIG_ALL $SYSCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
3133
END_FOLD
3234

3335
BEGIN_FOLD distdir
36+
# Create folder on host and docker, so that `cd` works
37+
mkdir -p "bitcoin-$HOST"
3438
DOCKER_EXEC make distdir VERSION=$HOST
3539
END_FOLD
3640

@@ -39,7 +43,7 @@ cd "syscoin-$HOST" || (echo "could not enter distdir syscoin-$HOST"; exit 1)
3943
set -o errexit
4044

4145
BEGIN_FOLD configure
42-
DOCKER_EXEC ./configure --cache-file=../config.cache $SYSCOIN_CONFIG_ALL $SYSCOIN_CONFIG || ( cat config.log && false)
46+
DOCKER_EXEC ./configure --cache-file=../config.cache $SYSCOIN_CONFIG_ALL $SYSCOIN_CONFIG || ( (DOCKER_EXEC cat config.log) && false)
4347
END_FOLD
4448

4549
set -o errtrace

ci/test/06_script_b.sh

-4
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,3 @@ if [ "$RUN_FUZZ_TESTS" = "true" ]; then
4848
DOCKER_EXEC test/fuzz/test_runner.py -l DEBUG ${DIR_FUZZ_IN}
4949
END_FOLD
5050
fi
51-
52-
set +o errexit
53-
cd ${BASE_BUILD_DIR} || (echo "could not enter travis build dir $BASE_BUILD_DIR"; exit 1)
54-
set -o errexit

0 commit comments

Comments
 (0)