Skip to content

Commit fa31bc3

Browse files
author
MarcoFalke
committed
ci: Remove dependence on travis, use it as fallback env
1 parent fa0aac0 commit fa31bc3

File tree

9 files changed

+91
-40
lines changed

9 files changed

+91
-40
lines changed

.travis.yml

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,10 @@ stages:
4040
- extended-lint
4141
env:
4242
global:
43-
- MAKEJOBS=-j3
44-
- RUN_UNIT_TESTS=true
45-
- RUN_FUNCTIONAL_TESTS=true
46-
- RUN_FUZZ_TESTS=false
47-
- DOCKER_NAME_TAG=ubuntu:18.04
48-
- BOOST_TEST_RANDOM=1$TRAVIS_BUILD_ID
49-
- CCACHE_SIZE=100M
50-
- CCACHE_TEMPDIR=/tmp/.ccache-temp
51-
- CCACHE_COMPRESS=1
52-
- CCACHE_DIR=$HOME/.ccache
53-
- BASE_OUTDIR=$TRAVIS_BUILD_DIR/out
54-
- SDK_URL=https://bitcoincore.org/depends-sources/sdks
55-
- WINEDEBUG=fixme-all
56-
- DOCKER_PACKAGES="build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git ca-certificates ccache"
43+
- CI_RETRY_EXE="travis_retry"
5744
- CACHE_ERR_MSG="Error! Initial build successful, but not enough time remains to run later build stages and tests. Please manually re-run this job by using the travis restart button or asking a bitcoin maintainer to restart. The next run should not time out because the build cache has been saved."
5845
before_install:
46+
- set -o errexit; source ./ci/test/00_setup_env.sh
5947
- set -o errexit; source ./ci/test/03_before_install.sh
6048
install:
6149
- set -o errexit; source ./ci/test/04_install.sh
@@ -71,7 +59,6 @@ script:
7159
- if [ $CONTINUE = "1" ]; then set -o errexit; source ./ci/test/06_script_b.sh; else set +o errexit; echo "$CACHE_ERR_MSG"; false; fi
7260
after_script:
7361
- echo $TRAVIS_COMMIT_RANGE
74-
- echo $TRAVIS_COMMIT_LOG
7562
jobs:
7663
include:
7764

ci/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
This directory contains scripts for each build step in each build stage.
44

55
Currently three stages `lint`, `extended_lint` and `test` are defined. Each stage has its own lifecycle, similar to the
6-
[Travis CI lifecycle](https://docs.travis-ci.com/user/job-lifecycle#the-job-lifecycle). Every script in here is named
6+
[Travis CI lifecycle](https://docs.travis-ci.com/user/job-lifecycle#the-job-lifecycle). Every script in here is named
77
and numbered according to which stage and lifecycle step it belongs to.
88

9+
### Running a stage locally
10+
11+
To allow for a wide range of tested environments, but also ensure reproducibility to some extent, the test stage
12+
requires `docker` to be installed. To install all requirements on Ubuntu, run
13+
14+
```
15+
sudo apt install docker.io ccache bash git
16+
```
17+
18+
To run the test stage,
19+
20+
```
21+
./ci/test_run_all.sh
22+
```
23+
24+
Be aware that the tests will be build and run in-place, so please run at your own risk.

ci/retry/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Help:
3535
-m, --min=secs Exponenetial Backoff: minimum sleep amount (seconds): Default 0.3
3636
-x, --max=secs Exponenetial Backoff: maximum sleep amount (seconds): Default 60
3737
-f, --fail="script +cmds" Fail Script: run in case of final failure
38-
38+
3939
### Examples
4040

4141
No problem:

ci/retry/retry

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ GETOPT_BIN=$IN_GETOPT_BIN
44
GETOPT_BIN=${GETOPT_BIN:-getopt}
55

66
__sleep_amount() {
7-
if [ -n "$constant_sleep" ]; then
7+
if [ -n "$constant_sleep" ]; then
88
sleep_time=$constant_sleep
99
else
1010
#TODO: check for awk
@@ -159,5 +159,5 @@ EOF
159159
done
160160

161161
retry "$max_tries" "$min_sleep" "$max_sleep" "$constant_sleep" "$fail_script" "$@"
162-
162+
163163
fi

ci/test/00_setup_env.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
echo "Setting default values in env"
10+
11+
BASE_ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ >/dev/null 2>&1 && pwd )
12+
export BASE_ROOT_DIR
13+
14+
export MAKEJOBS=${MAKEJOBS:--j3}
15+
export HOST=${HOST:-x86_64-unknown-linux-gnu}
16+
export RUN_UNIT_TESTS=${RUN_UNIT_TESTS:-true}
17+
export RUN_FUNCTIONAL_TESTS=${RUN_FUNCTIONAL_TESTS:-true}
18+
export RUN_FUZZ_TESTS=${RUN_FUZZ_TESTS:-false}
19+
export DOCKER_NAME_TAG=${DOCKER_NAME_TAG:-ubuntu:18.04}
20+
export BOOST_TEST_RANDOM=${BOOST_TEST_RANDOM:-1$TRAVIS_BUILD_ID}
21+
export CCACHE_SIZE=${CCACHE_SIZE:-100M}
22+
export CCACHE_TEMPDIR=${CCACHE_TEMPDIR:-/tmp/.ccache-temp}
23+
export CCACHE_COMPRESS=${CCACHE_COMPRESS:-1}
24+
export CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache}
25+
export BASE_BUILD_DIR=${BASE_BUILD_DIR:-${TRAVIS_BUILD_DIR:-$BASE_ROOT_DIR}}
26+
export BASE_OUTDIR=${BASE_OUTDIR:-$BASE_BUILD_DIR/out/$HOST}
27+
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
28+
export WINEDEBUG=${WINEDEBUG:-fixme-all}
29+
export DOCKER_PACKAGES=${DOCKER_PACKAGES:-build-essential libtool autotools-dev automake pkg-config bsdmainutils curl ca-certificates ccache python3}
30+
export GOAL=${GOAL:-install}
31+
export DIR_QA_ASSETS=${DIR_QA_ASSETS:-${BASE_BUILD_DIR}/qa-assets}
32+
export PATH=${BASE_ROOT_DIR}/ci/retry:$PATH
33+
export CI_RETRY_EXE=${CI_RETRY_EXE:retry}

ci/test/04_install.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,32 @@ export LC_ALL=C.UTF-8
99
free -m -h
1010
echo "Number of CPUs (nproc): $(nproc)"
1111

12-
travis_retry docker pull "$DOCKER_NAME_TAG"
12+
ccache echo "Creating ccache dir if it didn't already exist"
1313

14-
export DIR_FUZZ_IN=${TRAVIS_BUILD_DIR}/qa-assets
15-
git clone https://github.com/bitcoin-core/qa-assets ${DIR_FUZZ_IN}
16-
export DIR_FUZZ_IN=${DIR_FUZZ_IN}/fuzz_seed_corpus/
14+
${CI_RETRY_EXE} docker pull "$DOCKER_NAME_TAG"
1715

18-
mkdir -p "${TRAVIS_BUILD_DIR}/sanitizer-output/"
16+
if [ ! -d ${DIR_QA_ASSETS} ]; then
17+
git clone https://github.com/bitcoin-core/qa-assets ${DIR_QA_ASSETS}
18+
fi
19+
export DIR_FUZZ_IN=${DIR_QA_ASSETS}/fuzz_seed_corpus/
20+
21+
mkdir -p "${BASE_BUILD_DIR}/sanitizer-output/"
1922
export ASAN_OPTIONS=""
20-
export LSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/lsan"
21-
export TSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/tsan:log_path=${TRAVIS_BUILD_DIR}/sanitizer-output/tsan"
22-
export UBSAN_OPTIONS="suppressions=${TRAVIS_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1"
23+
export LSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/lsan"
24+
export TSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/tsan:log_path=${BASE_BUILD_DIR}/sanitizer-output/tsan"
25+
export UBSAN_OPTIONS="suppressions=${BASE_BUILD_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1"
2326
env | grep -E '^(BITCOIN_CONFIG|CCACHE_|WINEDEBUG|LC_ALL|BOOST_TEST_RANDOM|CONFIG_SHELL|(ASAN|LSAN|TSAN|UBSAN)_OPTIONS)' | tee /tmp/env
2427
if [[ $HOST = *-mingw32 ]]; then
2528
DOCKER_ADMIN="--cap-add SYS_ADMIN"
2629
elif [[ $BITCOIN_CONFIG = *--with-sanitizers=*address* ]]; then # If ran with (ASan + LSan), Docker needs access to ptrace (https://github.com/google/sanitizers/issues/764)
2730
DOCKER_ADMIN="--cap-add SYS_PTRACE"
2831
fi
29-
DOCKER_ID=$(docker run $DOCKER_ADMIN -idt --mount type=bind,src=$TRAVIS_BUILD_DIR,dst=$TRAVIS_BUILD_DIR --mount type=bind,src=$CCACHE_DIR,dst=$CCACHE_DIR -w $TRAVIS_BUILD_DIR --env-file /tmp/env $DOCKER_NAME_TAG)
32+
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)
3033

3134
DOCKER_EXEC () {
3235
docker exec $DOCKER_ID bash -c "cd $PWD && $*"
3336
}
3437

35-
travis_retry DOCKER_EXEC apt-get update
36-
travis_retry DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES $DOCKER_PACKAGES
38+
${CI_RETRY_EXE} DOCKER_EXEC apt-get update
39+
${CI_RETRY_EXE} DOCKER_EXEC apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES $DOCKER_PACKAGES
3740

ci/test/06_script_a.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66

77
export LC_ALL=C.UTF-8
88

9-
TRAVIS_COMMIT_LOG=$(git log --format=fuller -1)
10-
export TRAVIS_COMMIT_LOG
11-
12-
OUTDIR=$BASE_OUTDIR/$TRAVIS_PULL_REQUEST/$TRAVIS_JOB_NUMBER-$HOST
13-
BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$TRAVIS_BUILD_DIR/depends/$HOST --bindir=$OUTDIR/bin --libdir=$OUTDIR/lib"
9+
BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$BASE_BUILD_DIR/depends/$HOST --bindir=$BASE_OUTDIR/bin --libdir=$BASE_OUTDIR/lib"
1410
if [ -z "$NO_DEPENDS" ]; then
1511
DOCKER_EXEC ccache --max-size=$CCACHE_SIZE
1612
fi
@@ -23,7 +19,7 @@ else
2319
fi
2420
END_FOLD
2521

26-
mkdir build
22+
mkdir -p build
2723
cd build || (echo "could not enter build directory"; exit 1)
2824

2925
BEGIN_FOLD configure
@@ -41,10 +37,10 @@ DOCKER_EXEC ./configure --cache-file=../config.cache $BITCOIN_CONFIG_ALL $BITCOI
4137
END_FOLD
4238

4339
set -o errtrace
44-
trap 'DOCKER_EXEC "cat ${TRAVIS_BUILD_DIR}/sanitizer-output/* 2> /dev/null"' ERR
40+
trap 'DOCKER_EXEC "cat ${BASE_BUILD_DIR}/sanitizer-output/* 2> /dev/null"' ERR
4541

4642
BEGIN_FOLD build
4743
DOCKER_EXEC make $MAKEJOBS $GOAL || ( echo "Build failure. Verbose build follows." && DOCKER_EXEC make $GOAL V=1 ; false )
4844
END_FOLD
4945

50-
cd ${TRAVIS_BUILD_DIR} || (echo "could not enter travis build dir $TRAVIS_BUILD_DIR"; exit 1)
46+
cd ${BASE_BUILD_DIR} || (echo "could not enter travis build dir $BASE_BUILD_DIR"; exit 1)

ci/test/06_script_b.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ cd "build/bitcoin-$HOST" || (echo "could not enter distdir build/bitcoin-$HOST";
1010

1111
if [ "$RUN_UNIT_TESTS" = "true" ]; then
1212
BEGIN_FOLD unit-tests
13-
DOCKER_EXEC LD_LIBRARY_PATH=$TRAVIS_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1
13+
DOCKER_EXEC LD_LIBRARY_PATH=$BASE_BUILD_DIR/depends/$HOST/lib make $MAKEJOBS check VERBOSE=1
1414
END_FOLD
1515
fi
1616

@@ -26,4 +26,4 @@ if [ "$RUN_FUZZ_TESTS" = "true" ]; then
2626
END_FOLD
2727
fi
2828

29-
cd ${TRAVIS_BUILD_DIR} || (echo "could not enter travis build dir $TRAVIS_BUILD_DIR"; exit 1)
29+
cd ${BASE_BUILD_DIR} || (echo "could not enter travis build dir $BASE_BUILD_DIR"; exit 1)

ci/test_run_all.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright (c) 2019 The Bitcoin Core developers
4+
# Distributed under the MIT software license, see the accompanying
5+
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
6+
7+
export LC_ALL=C.UTF-8
8+
9+
echo "Setting default values in env"
10+
11+
set -o errexit; source ./ci/test/00_setup_env.sh
12+
set -o errexit; source ./ci/test/03_before_install.sh
13+
set -o errexit; source ./ci/test/04_install.sh
14+
set -o errexit; source ./ci/test/05_before_script.sh
15+
set -o errexit; source ./ci/test/06_script_a.sh
16+
set -o errexit; source ./ci/test/06_script_b.sh

0 commit comments

Comments
 (0)