Skip to content

Commit 24fee30

Browse files
authored
Add support for Gitlab CI (#3149)
* Add .gitlab-ci.yml * Use | instead of > for multiline commands This honor new-lines and makes ; unnecessary * Use ubuntu:bionic as base image * Move cache initialization before apt-get installs * Cache apt packages * Move installation of wget and unzip up as we need it for the cache * Prevent apt from deleting caches * Collect test logs into artifact * Make combine_logs.py always look for the template in the correct dir * Move final cache stuff into after_script * Reintroduce PYTHON_DEBUG=1, but only for .travis.yml * Install jinja2 in Travis builder image * Enable ChainLocks after quorums have been created Creating 4 quorums causes a lot of blocks to be created and signed by ChainLocks, which then causes timeouts later. * Increase timeout in wallet-dump.py test The first dumpwallet is quite slow sometimes, which then makes the later called dumpwallet throw a wallet locked exception.
1 parent b4e19f8 commit 24fee30

File tree

8 files changed

+173
-5
lines changed

8 files changed

+173
-5
lines changed

.gitlab-ci.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
image: "ubuntu:bionic"
2+
3+
variables:
4+
DOCKER_DRIVER: overlay2
5+
6+
cache:
7+
# Cache by branch/tag and job name
8+
# Gitlab can't use caches from parent pipelines when doing the first build in a PR, so we use artifacts to copy
9+
# caches into PRs
10+
key: ${CI_COMMIT_REF_SLUG}-${CI_JOB_NAME}${CI_EXTERNAL_PULL_REQUEST_IID}
11+
paths:
12+
- $CI_PROJECT_DIR/cache
13+
14+
stages:
15+
- build
16+
17+
.build_template: &build_template
18+
stage: build
19+
before_script:
20+
- export BUILD_TARGET="$CI_JOB_NAME"
21+
- echo BUILD_TARGET=$BUILD_TARGET
22+
- source ./ci/matrix.sh
23+
24+
# The ubuntu base image has apt configured to delete caches after each invocation, which is something that is not desirable for us
25+
- rm /etc/apt/apt.conf.d/docker-clean
26+
- apt-get update
27+
- apt-get install -y wget unzip
28+
29+
# Init cache
30+
- export CACHE_DIR=$CI_PROJECT_DIR/cache
31+
- mkdir -p $CACHE_DIR
32+
- |
33+
if [ "$CI_COMMIT_REF_SLUG" != "develop" -a "$CI_COMMIT_TAG" == "" ]; then
34+
if [ ! -d $CACHE_DIR/ccache ]; then
35+
echo "Downloading cache from develop branch"
36+
if wget -O cache-artifact.zip https://gitlab.com/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME/-/jobs/artifacts/develop/download?job=$CI_JOB_NAME; then
37+
unzip cache-artifact.zip
38+
rm cache-artifact.zip
39+
mv cache-artifact/* $CACHE_DIR/
40+
else
41+
echo "Failed to download cache"
42+
fi
43+
else
44+
echo "Not touching cache (was initialized from previous build)"
45+
fi
46+
else
47+
echo "Not touching cache (building develop branch or tag)"
48+
fi
49+
# Create missing cache dirs
50+
- mkdir -p $CACHE_DIR/ccache && mkdir -p $CACHE_DIR/depends && mkdir -p $CACHE_DIR/sdk-sources && mkdir -p $CACHE_DIR/apt
51+
# Keep this as it makes caching related debugging easier
52+
- ls -lah $CACHE_DIR && ls -lah $CACHE_DIR/depends && ls -lah $CACHE_DIR/ccache && ls -lah $CACHE_DIR/apt
53+
- mv $CACHE_DIR/apt/* /var/cache/apt/archives/ || true
54+
55+
# Install base packages
56+
- apt-get dist-upgrade -y
57+
- apt-get install -y git g++ autotools-dev libtool m4 automake autoconf pkg-config zlib1g-dev libssl1.0-dev curl ccache bsdmainutils cmake
58+
- apt-get install -y python3 python3-dev python3-pip
59+
60+
# jinja2 is needed for combine_logs.py
61+
- pip3 install jinja2
62+
63+
# Setup some environment variables
64+
- if [ "$CI_EXTERNAL_PULL_REQUEST_IID" != "" ]; then export PULL_REQUEST="true"; else export PULL_REQUEST="false"; fi
65+
- export COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
66+
- export JOB_NUMBER="$CI_JOB_ID"
67+
- export HOST_SRC_DIR=$CI_PROJECT_DIR
68+
- echo PULL_REQUEST=$PULL_REQUEST COMMIT_RANGE=$COMMIT_RANGE HOST_SRC_DIR=$HOST_SRC_DIR CACHE_DIR=$CACHE_DIR
69+
- echo "Commit log:" && git log --format=fuller -1
70+
71+
# Build dash_hash
72+
- git clone https://github.com/dashpay/dash_hash
73+
- cd dash_hash && python3 setup.py install
74+
75+
# Install build target specific packages
76+
- echo PACKAGES=$PACKAGES
77+
- if [ -n "$DPKG_ADD_ARCH" ]; then dpkg --add-architecture "$DPKG_ADD_ARCH" ; fi
78+
- if [ -n "$PACKAGES" ]; then apt-get update && apt-get install -y --no-install-recommends --no-upgrade $PACKAGES; fi
79+
80+
# Move apt packages into cache
81+
- mv /var/cache/apt/archives/* $CACHE_DIR/apt/ || true
82+
83+
# Make mingw use correct threading libraries
84+
- update-alternatives --set i686-w64-mingw32-gcc /usr/bin/i686-w64-mingw32-gcc-posix || true
85+
- update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix || true
86+
- update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix || true
87+
- update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix || true
88+
89+
script:
90+
- export BUILD_TARGET="$CI_JOB_NAME"
91+
- cd $CI_PROJECT_DIR
92+
- ./ci/build_depends.sh
93+
- ./ci/build_src.sh
94+
- ./ci/test_unittests.sh
95+
- ./ci/test_integrationtests.sh
96+
97+
after_script:
98+
# Copy all cache files into cache-artifact so that they get uploaded. We only do this for develop so that artifacts
99+
# stay minimal for PRs and branches (we never need them)
100+
- mkdir $CI_PROJECT_DIR/cache-artifact
101+
- mkdir -p $CI_PROJECT_DIR/testlogs
102+
- |
103+
if [ "$CI_COMMIT_REF_SLUG" = "develop" ]; then
104+
cp -ra $CACHE_DIR/* $CI_PROJECT_DIR/cache-artifact/
105+
fi
106+
107+
# We're actually only interested in the develop branch creating the cache artifact, but there is no way to control this
108+
# until https://gitlab.com/gitlab-org/gitlab-foss/issues/25478 gets implemented. Until then, we use an expiration time of
109+
# 3 days and rely on daily builds to refresh the cache artifacts. We also keep non-develop artifacts at minimum size
110+
artifacts:
111+
name: cache-artifact
112+
when: always
113+
paths:
114+
- $CI_PROJECT_DIR/cache-artifact
115+
- $CI_PROJECT_DIR/testlogs
116+
expire_in: 3 days
117+
118+
arm-linux:
119+
<<: *build_template
120+
121+
win32:
122+
<<: *build_template
123+
124+
win64:
125+
<<: *build_template
126+
127+
linux32:
128+
<<: *build_template
129+
130+
linux64:
131+
<<: *build_template
132+
133+
linux64_nowallet:
134+
<<: *build_template
135+
136+
linux64_release:
137+
<<: *build_template
138+
139+
mac:
140+
<<: *build_template

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ install:
125125
- export HOST_SRC_DIR=$TRAVIS_BUILD_DIR
126126
- export HOST_CACHE_DIR=$HOME/cache
127127
- export TRAVIS_COMMIT_LOG=`git log --format=fuller -1`
128+
- export PYTHON_DEBUG=1
128129
- source ./ci/matrix.sh
129130
- mkdir -p $HOST_CACHE_DIR/docker && mkdir -p $HOST_CACHE_DIR/ccache && mkdir -p $HOST_CACHE_DIR/depends && mkdir -p $HOST_CACHE_DIR/sdk-sources
130131
# Keep this as it makes caching related debugging easier

ci/Dockerfile.builder

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ RUN apt-get update && apt-get install -y python3-pip
1414

1515
# Python stuff
1616
RUN pip3 install pyzmq # really needed?
17+
RUN pip3 install jinja2
1718

1819
# dash_hash
1920
RUN git clone https://github.com/dashpay/dash_hash

ci/matrix.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export DOCKER_RUN_IN_BUILDER="docker run -t --rm -w $SRC_DIR $DOCKER_RUN_ARGS $B
2727
# Default values for targets
2828
export GOAL="install"
2929
export SDK_URL=${SDK_URL:-https://bitcoincore.org/depends-sources/sdks}
30-
export PYTHON_DEBUG=1
3130
export MAKEJOBS="-j4"
3231

3332
export RUN_UNITTESTS=false

ci/test_integrationtests.sh

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,30 @@ export LD_LIBRARY_PATH=$BUILD_DIR/depends/$HOST/lib
1717

1818
cd build-ci/dashcore-$BUILD_TARGET
1919

20-
./test/functional/test_runner.py --coverage --quiet $PASS_ARGS
20+
set +e
21+
./test/functional/test_runner.py --coverage --quiet --nocleanup --tmpdir=$(pwd)/testdatadirs $PASS_ARGS
22+
RESULT=$?
23+
set -e
24+
25+
echo "Collecting logs..."
26+
BASEDIR=$(ls testdatadirs)
27+
if [ "$BASEDIR" != "" ]; then
28+
mkdir testlogs
29+
for d in $(ls testdatadirs/$BASEDIR | grep -v '^cache$'); do
30+
mkdir testlogs/$d
31+
./test/functional/combine_logs.py -c ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.log
32+
./test/functional/combine_logs.py --html ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.html
33+
cd testdatadirs/$BASEDIR/$d
34+
LOGFILES="$(find . -name 'debug.log' -or -name "test_framework.log")"
35+
cd ../../..
36+
for f in $LOGFILES; do
37+
d2="testlogs/$d/$(dirname $f)"
38+
mkdir -p $d2
39+
cp testdatadirs/$BASEDIR/$d/$f $d2/
40+
done
41+
done
42+
fi
43+
44+
mv testlogs ../../
45+
46+
exit $RESULT

test/functional/combine_logs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def print_logs(log_events, color=False, html=False):
106106
except ImportError:
107107
print("jinja2 not found. Try `pip install jinja2`")
108108
sys.exit(1)
109-
print(jinja2.Environment(loader=jinja2.FileSystemLoader('./'))
109+
print(jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__))))
110110
.get_template('combined_log_template.html')
111111
.render(title="Combined Logs from testcase", log_events=[event._asdict() for event in log_events]))
112112

test/functional/llmq-chainlocks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ def run_test(self):
2929
sync_blocks(self.nodes, timeout=60*5)
3030

3131
self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
32-
self.nodes[0].spork("SPORK_19_CHAINLOCKS_ENABLED", 0)
3332
self.wait_for_sporks_same()
3433

3534
self.log.info("Mining 4 quorums")
3635
for i in range(4):
3736
self.mine_quorum()
3837

38+
self.nodes[0].spork("SPORK_19_CHAINLOCKS_ENABLED", 0)
39+
3940
self.log.info("Mine single block, wait for chainlock")
4041
self.nodes[0].generate(1)
4142
self.wait_for_chainlocked_block_all_nodes(self.nodes[0].getbestblockhash())

test/functional/wallet-dump.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def run_test (self):
100100
#encrypt wallet, restart, unlock and dump
101101
self.nodes[0].node_encrypt_wallet('test')
102102
self.start_node(0)
103-
self.nodes[0].walletpassphrase('test', 10)
103+
self.nodes[0].walletpassphrase('test', 30)
104104
# Should be a no-op:
105105
self.nodes[0].keypoolrefill()
106106
self.nodes[0].dumpwallet(tmpdir + "/node0/wallet.encrypted.dump")

0 commit comments

Comments
 (0)