-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (139 loc) · 5.29 KB
/
test-itcoin-fbft.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Test itcoin-fbft
on:
push:
branches:
- main
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
tests:
runs-on: ubuntu-22.04
steps:
- name: Install the build toolchain (gcc-12)
run: |
sudo apt install --no-install-recommends -y \
autoconf \
automake \
bsdextrautils \
ca-certificates \
cmake \
g++-12 \
gcc-12 \
git \
jq \
libtool \
make \
openssh-client \
parallel \
pkg-config \
python3 \
xxd \
zlib1g-dev
- name: Install the build and runtime dependencies
run: |
sudo apt install --no-install-recommends -y \
libargtable2-dev \
libboost-filesystem1.74-dev \
libboost-log1.74-dev \
libboost-program-options1.74-dev \
libboost-test1.74-dev \
libboost-thread1.74-dev \
libcurl4-openssl-dev \
libdb5.3++-dev \
libevent-dev \
libsqlite3-dev \
libssl-dev \
libzmq3-dev \
swi-prolog
- name: Checkout itcoin-fbft
uses: actions/checkout@v3
with:
fetch-depth: 1
path: itcoin-fbft
- name: Checkout itcoin-core
uses: actions/checkout@v3
with:
repository: bancaditalia/itcoin-core
fetch-depth: 1
path: itcoin-core
- name: save the revision id of itcoin-core in env variable ITCOIN_CORE_REVISION_ID
run: |
cd itcoin-core
printf "ITCOIN_CORE_REVISION_ID=%s\n" $(git rev-parse HEAD) | tee --append "${GITHUB_ENV}"
- name: Prepare the build
run: |
mkdir -p itcoin-fbft/build
cd itcoin-fbft/build
cmake \
-DCMAKE_C_COMPILER=$(which gcc-12) \
-DCMAKE_CXX_COMPILER=$(which g++-12) \
-DITCOIN_CORE_SRC_DIR=../../itcoin-core \
..
- name: retrieve the names of the itcoin-core libraries that need to be cached
run: |
cd itcoin-fbft/build
# modified from: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "ITCOIN_CORE_LIBRARIES<<${EOF}" | tee --append "${GITHUB_ENV}"
# Let's use a subshell so that "set -o pipefail" does not mess with
# the runner's environment.
#
# Also, GitHub runner's /bin/sh does not support "echo -e", which we
# need, so we have to explicitly force the use of "/bin/bash"
(set -o pipefail ; make SHELL=/bin/bash print_itcoin_core_libraries | grep -v "Built target" | tee --append "${GITHUB_ENV}")
echo "${EOF}" | tee --append "${GITHUB_ENV}"
- name: Cache itcoin-core artifacts for version ${{ env.ITCOIN_CORE_REVISION_ID }}
id: cache-itcoin-core
uses: actions/cache@v3
with:
key: ${{ env.ITCOIN_CORE_REVISION_ID }}
path: |
${{ env.ITCOIN_CORE_LIBRARIES }}
${{ github.workspace }}/itcoin-core/src/bitcoin-cli
${{ github.workspace }}/itcoin-core/src/bitcoind
${{ github.workspace }}/itcoin-core/src/config/bitcoin-config.h
${{ github.workspace }}/itcoin-core/src/secp256k1/libsecp256k1-config.h
${{ github.workspace }}/itcoin-fbft/build/thirdparty/itcoin-core-repo-status
- name: build itcoin-fbft
run: |
cd itcoin-fbft/build
make -j $(nproc)
- name: start infrastructure in background, wait until started
run: |
cd itcoin-fbft/infra
./reset-infra.sh 10
./start-infra.sh &
# Concurrently for each node N in (0..4), failing at the first error:
# - invoke bitcoin-cli N uptime
# - if the invocation fails, retry with exponential backoff at most 6
# times
# - if a bitcoin-cli invocation becomes unresponsive, it is timed out
# after 30 seconds and is considered a failure (eventually retried)
parallel --halt-on-error now,fail=1 \
./retry --min=0.5 --max=15 --tries=6 -- \
timeout --kill-after=40 30 \
./bitcoin-cli.sh {1} uptime \
::: {0..3}
- name: Run tests (failure will be detected in next step)
continue-on-error: true
id: tests
run: |
cd itcoin-fbft/build
make test
- name: Summarize test outcome. Fail and print log if tests failed.
run: |
# summary
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
echo -n "itcoin-fbft tests: "
if [[ ${{ steps.tests.outcome }} == "success" ]]; then
printf "${GREEN}SUCCESS${NC}\n"
exit 0
fi
# if we arrive here, the tests failed
printf "${RED}FAIL${NC} (${{ steps.tests.outcome }})\n"
echo "Contents of build/Testing/Temporary/LastTest.log:"
cat /home/runner/work/itcoin-fbft/itcoin-fbft/itcoin-fbft/build/Testing/Temporary/LastTest.log
exit 1