-
Notifications
You must be signed in to change notification settings - Fork 115
318 lines (291 loc) · 11.8 KB
/
ci.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Nimbus
# Copyright (c) 2020-2023 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
name: Nimbus CI
on:
push:
paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**',
'fluffy/**', '.github/workflows/fluffy.yml',
'nimbus_verified_proxy/**', '.github/workflows/nimbus_verified_proxy.yml',
]
# Disable `pull_request`. Experimenting with using only `push` for PRs.
#pull_request:
# paths-ignore: ['doc/**', 'docs/**', '**/*.md', 'hive_integration/**']
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
max-parallel: 20
matrix:
target:
- os: linux
cpu: amd64
evmc: evmc
#- os: linux
# cpu: i386
# evmc: evmc
- os: macos
cpu: amd64
evmc: evmc
- os: windows
cpu: amd64
evmc: evmc
- os: linux
cpu: amd64
evmc: nimvm
#- os: linux
# cpu: i386
# evmc: nimvm
- os: windows
cpu: amd64
evmc: nimvm
- os: macos
cpu: amd64
evmc: nimvm
include:
- target:
os: linux
builder: ubuntu-20.04
- target:
os: macos
builder: macos-11
- target:
os: windows
builder: windows-latest
defaults:
run:
shell: bash
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.evmc }}'
runs-on: ${{ matrix.builder }}
steps:
- name: Checkout nimbus-eth1
uses: actions/checkout@v3
- name: Derive environment variables
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
PLATFORM=x64
GOARCH=amd64
USE_MIRACL=0
else
PLATFORM=x86
GOARCH=386
USE_MIRACL=1
fi
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "USE_MIRACL=${USE_MIRACL}" >> $GITHUB_ENV
# libminiupnp / natpmp
if [[ '${{ runner.os }}' == 'Linux' && '${{ matrix.target.cpu }}' == 'i386' ]]; then
export CFLAGS="${CFLAGS} -m32 -mno-adx"
echo "CFLAGS=${CFLAGS}" >> $GITHUB_ENV
fi
ncpu=''
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=${NUMBER_OF_PROCESSORS}
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=${ncpu}" >> $GITHUB_ENV
if [[ '${{ matrix.target.evmc }}' == 'evmc' ]]; then
echo "ENABLE_EVMC=1" >> $GITHUB_ENV
else
echo "ENABLE_EVMC=0" >> $GITHUB_ENV
fi
- name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
run: |
sudo dpkg --add-architecture i386
sudo apt-fast update -qq
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
--no-install-recommends -yq gcc-multilib g++-multilib \
libz-dev:i386 libbz2-dev:i386 libssl-dev:i386 libpcre3-dev:i386
mkdir -p external/bin
cat << EOF > external/bin/gcc
#!/bin/bash
exec $(which gcc) -m32 "\$@"
EOF
cat << EOF > external/bin/g++
#!/bin/bash
exec $(which g++) -m32 "\$@"
EOF
chmod 755 external/bin/gcc external/bin/g++
echo '${{ github.workspace }}/external/bin' >> $GITHUB_PATH
- name: Install build dependencies (Macos)
# Some home brew modules were reported missing
if: runner.os == 'Macos'
run: |
HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gnu-getopt
brew link --force gnu-getopt
- name: Restore rocksdb from cache (Macos/Linux)
if: runner.os != 'Windows'
id: rocksdb-cache
uses: actions/cache@v3
with:
path: rocks-db-cache-${{ matrix.target.cpu }}
key: 'rocksdb-v2-${{ matrix.target.os }}-${{ matrix.target.cpu }}'
- name: Build and install rocksdb (Linux i386)
# no librocksdb-dev:i386
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
run: |
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_rocksdb.sh
bash build_rocksdb.sh rocks-db-cache-${{ matrix.target.cpu }}
- name: Install rocksdb (Linux amd64)
# mysterious illegal instruction error if we build our own librocksdb
if: runner.os == 'Linux' && matrix.target.cpu == 'amd64'
run: |
sudo apt-get -q update
sudo apt-get install -y librocksdb-dev libpcre3-dev
- name: Build and install rocksdb (Macos)
if: runner.os == 'Macos'
run: |
HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install ccache
echo "/usr/local/opt/ccache/libexec" >> ${GITHUB_PATH}
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_rocksdb.sh
bash build_rocksdb.sh rocks-db-cache-${{ matrix.target.cpu }}
- name: Restore llvm-mingw (Windows) from cache
if: runner.os == 'Windows'
id: windows-mingw-cache
uses: actions/cache@v3
with:
path: external/mingw-${{ matrix.target.cpu }}
key: 'mingw-llvm-17-${{ matrix.target.cpu }}'
- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v3
with:
path: external/dlls-${{ matrix.target.cpu }}
# according to docu, idle caches are kept for up to 7 days
# so change dlls# to force new cache contents (for some number #)
key: dlls0-${{ matrix.target.cpu }}
- name: Install llvm-mingw dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
mkdir -p external
MINGW_BASE="https://github.com/mstorsjo/llvm-mingw/releases/download/20230905"
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-x86_64.zip"
ARCH=64
else
MINGW_URL="$MINGW_BASE/llvm-mingw-20230905-ucrt-i686.zip"
ARCH=32
fi
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.zip"
7z x -y "external/mingw-${{ matrix.target.cpu }}.zip" -oexternal/mingw-${{ matrix.target.cpu }}/
mv external/mingw-${{ matrix.target.cpu }}/**/* ./external/mingw-${{ matrix.target.cpu }}
- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
ROCKSDBSUB=x64
else
ROCKSDBSUB=x86
fi
DLLPATH=external/dlls-${{ matrix.target.cpu }}
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -o"$DLLPATH"
# ROCKSDB
curl -L "https://github.com/status-im/nimbus-deps/releases/download/nimbus-deps/nimbus-deps.zip" -o external/nimbus-deps.zip
7z x -y external/nimbus-deps.zip
cp "./$ROCKSDBSUB/librocksdb.dll" "$DLLPATH/librocksdb.dll"
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
run: |
echo '${{ github.workspace }}'"/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo '${{ github.workspace }}'"/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
- name: Get latest nimbus-build-system commit hash
id: versions
run: |
getHash() {
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
}
nbsHash=$(getHash status-im/nimbus-build-system)
echo "nimbus_build_system=$nbsHash" >> $GITHUB_OUTPUT
- name: Restore prebuilt Nim from cache
id: nim-cache
uses: actions/cache@v3
with:
path: NimBinCache
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimbus_build_system }}-${{ matrix.target.evmc }}'
- name: Build Nim and Nimbus-eth1 dependencies
run: |
make -j${ncpu} ARCH_OVERRIDE=${PLATFORM} CI_CACHE=NimBinCache update-from-ci
- name: Run nimbus-eth1 tests (Windows)
if: runner.os == 'Windows'
run: |
gcc --version
DEFAULT_MAKE_FLAGS="-j${ncpu} ENABLE_EVMC=${ENABLE_EVMC} ENABLE_VMLOWMEM=${ENABLE_VMLOWMEM}"
mingw32-make ${DEFAULT_MAKE_FLAGS}
build/nimbus.exe --help
# give us more space
find . -type d -name ".git" -exec rm -rf {} +
find . -type d -name "nimcache" -exec rm -rf {} +
mingw32-make ${DEFAULT_MAKE_FLAGS} test
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
mingw32-make ${DEFAULT_MAKE_FLAGS}
fi
- name: Run nimbus-eth1 tests (Linux)
if: runner.os == 'Linux'
run: |
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/lib"
DEFAULT_MAKE_FLAGS="-j${ncpu} USE_MIRACL=${USE_MIRACL} ENABLE_EVMC=${ENABLE_EVMC}"
env CC=gcc make ${DEFAULT_MAKE_FLAGS}
build/nimbus --help
# CC, GOARCH, and CGO_ENABLED are needed to select correct compiler 32/64 bit
if [[ '${{ matrix.target.cpu }}' == 'i386' ]]; then
# hide CI failures
env CC=gcc GOARCH=${GOARCH} CXX=g++ CGO_ENABLED=1 make ${DEFAULT_MAKE_FLAGS} test || true
else
# pushd vendor/nimbus-eth2
# env NIMBUSEL_BINARY=../../build/nimbus NIMBUSEL_GENESIS=scripts/nimbusel_genesis.json \
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
env CC=gcc GOARCH=${GOARCH} CXX=g++ CGO_ENABLED=1 make ${DEFAULT_MAKE_FLAGS} test
fi
- name: Run nimbus-eth1 tests (Macos)
if: runner.os == 'Macos'
run: |
export ZERO_AR_DATE=1 # avoid timestamps in binaries
DEFAULT_MAKE_FLAGS="-j${ncpu} ENABLE_EVMC=${ENABLE_EVMC}"
make ${DEFAULT_MAKE_FLAGS}
build/nimbus --help
# "-static" option will not work for osx unless static system libraries are provided
# pushd vendor/nimbus-eth2
# env NIMBUSEL_BINARY=../../build/nimbus NIMBUSEL_GENESIS=scripts/nimbusel_genesis.json \
# ./scripts/launch_local_testnet.sh --nodes=3 --stop-at-epoch=7 \
# --disable-htop --reuse-binaries --run-nimbus-el --dl-eth2 --verbose --kill-old-processes
# popd
make ${DEFAULT_MAKE_FLAGS} test
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
- name: Check copyright year
if: ${{ !cancelled() }} && github.event_name == 'pull_request'
run: |
bash scripts/check_copyright_year.sh