Skip to content

Commit 80c1154

Browse files
stefantalpalaruzah
authored andcommitted
Windows binary release
CI: use both cores on GitHub Actions and set timeouts for the local testnet tests
1 parent 67e4a04 commit 80c1154

21 files changed

+228
-64
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,21 @@ jobs:
122122
echo "CFLAGS=$CFLAGS" >> $GITHUB_ENV
123123
fi
124124
125+
ncpu=
126+
case '${{ runner.os }}' in
127+
'Linux')
128+
ncpu=$(nproc)
129+
;;
130+
'macOS')
131+
ncpu=$(sysctl -n hw.ncpu)
132+
;;
133+
'Windows')
134+
ncpu=$NUMBER_OF_PROCESSORS
135+
;;
136+
esac
137+
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
138+
echo "ncpu=$ncpu" >> $GITHUB_ENV
139+
125140
- name: Install build dependencies (Linux i386)
126141
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
127142
run: |
@@ -218,23 +233,6 @@ jobs:
218233
shell: bash
219234
working-directory: nim-beacon-chain
220235
run: |
221-
ncpu=
222-
ext=
223-
case '${{ runner.os }}' in
224-
'Linux')
225-
ncpu=$(nproc)
226-
;;
227-
'macOS')
228-
ncpu=$(sysctl -n hw.ncpu)
229-
;;
230-
'Windows')
231-
ncpu=$NUMBER_OF_PROCESSORS
232-
ext=.exe
233-
;;
234-
esac
235-
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
236-
echo "::set-output name=ncpu::$ncpu"
237-
238236
make -j$ncpu ARCH_OVERRIDE=$PLATFORM CI_CACHE=NimBinaries V=1 update
239237
240238
- name: Get latest fixtures commit hash
@@ -284,11 +282,11 @@ jobs:
284282
shell: bash
285283
working-directory: nim-beacon-chain
286284
run: |
287-
./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 -- --verify-finalization --discv5:no
285+
./scripts/launch_local_testnet.sh --testnet 0 --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 --timeout 600 -- --verify-finalization --discv5:no
288286
289287
- name: Run nim-beacon-chain testnet1 (mainnet)
290288
if: matrix.target.TEST_KIND == 'finalization-mainnet'
291289
shell: bash
292290
working-directory: nim-beacon-chain
293291
run: |
294-
./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 -- --verify-finalization --discv5:no
292+
./scripts/launch_local_testnet.sh --testnet 1 --nodes 4 --stop-at-epoch 5 --log-level DEBUG --disable-htop --enable-logtrace --data-dir local_testnet0_data --base-port 9000 --base-rpc-port 7000 --base-metrics-port 8008 --timeout 2400 -- --verify-finalization --discv5:no

.github/workflows/release.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: Upload Release Asset
77

88
jobs:
99
build-amd64:
10-
name: AMD64 release asset
10+
name: Linux AMD64 release asset
1111
runs-on: ubuntu-latest
1212
steps:
1313
- name: Create release
@@ -54,7 +54,7 @@ jobs:
5454
docker push statusim/nimbus-eth2:amd64-${TAG}
5555
docker push statusim/nimbus-eth2:amd64-latest
5656
build-arm64:
57-
name: ARM64 release asset
57+
name: Linux ARM64 release asset
5858
runs-on: ubuntu-latest
5959
steps:
6060
- name: Install packages
@@ -91,7 +91,7 @@ jobs:
9191
asset_name: ${{ steps.make_dist.outputs.linux_arm64_archive }}
9292
asset_content_type: application/gzip
9393
build-arm:
94-
name: ARM release asset
94+
name: Linux ARM release asset
9595
runs-on: ubuntu-latest
9696
steps:
9797
- name: Install packages
@@ -127,4 +127,34 @@ jobs:
127127
asset_path: ./dist/${{ steps.make_dist.outputs.linux_arm_archive }}
128128
asset_name: ${{ steps.make_dist.outputs.linux_arm_archive }}
129129
asset_content_type: application/gzip
130+
build-win64:
131+
name: Windows AMD64 release asset
132+
runs-on: ubuntu-latest
133+
steps:
134+
- name: Checkout code
135+
uses: actions/checkout@v2
136+
- name: Build project
137+
id: make_dist
138+
run: |
139+
make dist-win64
140+
cd dist
141+
echo "::set-output name=windows_amd64_archive::"$(echo nimbus-eth2_Windows_amd64_*.tar.gz)
142+
- name: Fetch latest release
143+
id: fetch_release
144+
uses: InsonusK/[email protected]
145+
with:
146+
myToken: ${{ github.token }}
147+
view_top: 1
148+
- name: Check release version
149+
run: |
150+
[[ "refs/tags/${{ steps.fetch_release.outputs.tag_name }}" == "${{ github.ref }}" ]]
151+
- name: Upload release asset
152+
uses: actions/upload-release-asset@v1
153+
env:
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
with:
156+
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.fetch_release.outputs.id }}/assets{?name,label}
157+
asset_path: ./dist/${{ steps.make_dist.outputs.windows_amd64_archive }}
158+
asset_name: ${{ steps.make_dist.outputs.windows_amd64_archive }}
159+
asset_content_type: application/gzip
130160

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019-2020 Status Research & Development GmbH. Licensed under
1+
# Copyright (c) 2019-2021 Status Research & Development GmbH. Licensed under
22
# either of:
33
# - Apache License, version 2.0
44
# - MIT license
@@ -81,6 +81,7 @@ TOOLS_CSV := $(subst $(SPACE),$(COMMA),$(TOOLS))
8181
dist-amd64 \
8282
dist-arm64 \
8383
dist-arm \
84+
dist-win64 \
8485
dist \
8586
benchmarks
8687

@@ -396,10 +397,15 @@ dist-arm:
396397
MAKE="$(MAKE)" \
397398
scripts/make_dist.sh arm
398399

400+
dist-win64:
401+
MAKE="$(MAKE)" \
402+
scripts/make_dist.sh win64
403+
399404
dist:
400405
$(MAKE) dist-amd64
401406
$(MAKE) dist-arm64
402407
$(MAKE) dist-arm
408+
$(MAKE) dist-win64
403409

404410
#- this simple test will show any missing dynamically-linked Glibc symbols in the target distro
405411
dist-test:

beacon_chain/network_metadata.nim

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Copyright (c) 2020-2021 Status Research & Development GmbH
2+
# Licensed and distributed under either of
3+
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
4+
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
5+
# at your option. This file may not be copied, modified, or distributed except according to those terms.
6+
17
import
28
tables, strutils, os,
39
stew/shims/macros, nimcrypto/hash,
@@ -68,7 +74,7 @@ type
6874
incompatibilityDesc*: string
6975

7076
const
71-
eth2testnetsDir = currentSourcePath.parentDir / ".." / "vendor" / "eth2-testnets"
77+
eth2testnetsDir = currentSourcePath.parentDir.replace('\\', '/') & "/../vendor/eth2-testnets"
7278

7379
const presetValueLoaders = genExpr(nnkBracket):
7480
for constName in PresetValue:
@@ -107,12 +113,12 @@ proc loadEth2NetworkMetadata*(path: string): Eth2NetworkMetadata
107113
{.raises: [CatchableError, Defect].} =
108114
try:
109115
let
110-
genesisPath = path / "genesis.ssz"
111-
genesisDepositsSnapshotPath = path / "genesis_deposit_contract_snapshot.ssz"
112-
configPath = path / "config.yaml"
113-
depositContractPath = path / "deposit_contract.txt"
114-
depositContractBlockPath = path / "deposit_contract_block.txt"
115-
bootstrapNodesPath = path / "bootstrap_nodes.txt"
116+
genesisPath = path & "/genesis.ssz"
117+
genesisDepositsSnapshotPath = path & "/genesis_deposit_contract_snapshot.ssz"
118+
configPath = path & "/config.yaml"
119+
depositContractPath = path & "/deposit_contract.txt"
120+
depositContractBlockPath = path & "/deposit_contract_block.txt"
121+
bootstrapNodesPath = path & "/bootstrap_nodes.txt"
116122

117123
runtimePreset = if fileExists(configPath):
118124
extractRuntimePreset(configPath, readPresetFile(configPath))
@@ -164,27 +170,27 @@ proc loadEth2NetworkMetadata*(path: string): Eth2NetworkMetadata
164170
incompatibilityDesc: err.msg)
165171

166172
const
167-
mainnetMetadataDir = eth2testnetsDir / "shared" / "mainnet"
173+
mainnetMetadataDir = eth2testnetsDir & "/shared/mainnet"
168174

169175
mainnetMetadata* = when const_preset == "mainnet":
170176
Eth2NetworkMetadata(
171177
incompatible: false, # TODO: This can be more accurate if we verify
172178
# that there are no constant overrides
173179
eth1Network: some mainnet,
174180
runtimePreset: mainnetRuntimePreset,
175-
bootstrapNodes: readFile(mainnetMetadataDir / "bootstrap_nodes.txt").splitLines,
181+
bootstrapNodes: readFile(mainnetMetadataDir & "/bootstrap_nodes.txt").splitLines,
176182
depositContractAddress: Eth1Address.fromHex "0x00000000219ab540356cBB839Cbe05303d7705Fa",
177183
depositContractDeployedAt: BlockHashOrNumber.init "11052984",
178-
genesisData: readFile(mainnetMetadataDir / "genesis.ssz"),
179-
genesisDepositsSnapshot: readFile(mainnetMetadataDir / "genesis_deposit_contract_snapshot.ssz"))
184+
genesisData: readFile(mainnetMetadataDir & "/genesis.ssz"),
185+
genesisDepositsSnapshot: readFile(mainnetMetadataDir & "/genesis_deposit_contract_snapshot.ssz"))
180186
else:
181187
Eth2NetworkMetadata(
182188
incompatible: true,
183189
incompatibilityDesc: "This build is compiled with the " & const_preset & " const preset. " &
184190
"It's not compatible with mainnet")
185191

186192
template eth2testnet(path: string): Eth2NetworkMetadata =
187-
loadEth2NetworkMetadata(eth2testnetsDir / path)
193+
loadEth2NetworkMetadata(eth2testnetsDir & "/" & path)
188194

189195
const
190196
pyrmontMetadata* = eth2testnet "shared/pyrmont"

beacon_chain/spec/keystore.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ macro wordListArray*(filename: static string,
217217
minWordLen: static int = 0,
218218
maxWordLen: static int = high(int)): untyped =
219219
result = newTree(nnkBracket)
220-
var words = slurp(filename).splitLines()
220+
var words = slurp(filename.replace('\\', '/')).splitLines()
221221
for word in words:
222222
if word.len >= minWordLen and word.len <= maxWordLen:
223223
result.add newCall("cstring", newLit(word))

docker/dist/Dockerfile.win64

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# The build is reproducible only if this base image stays the same.
2+
FROM statusteam/nimbus_beacon_node:dist_base_20210202230118_win64@sha256:47b8ea60a35bd45355f0490677c04a9b42df56b5041cbf64da8ad233511a55d5
3+
4+
SHELL ["/bin/bash", "-c"]
5+
6+
ARG USER_ID
7+
ARG GROUP_ID
8+
9+
RUN addgroup --gid ${GROUP_ID} user; \
10+
adduser --disabled-password --gecos '' --uid ${USER_ID} --gid ${GROUP_ID} user;
11+
12+
USER user
13+
14+
STOPSIGNAL SIGINT
15+
16+
COPY "entry_point.sh" "/home/user/"
17+
ENTRYPOINT ["/home/user/entry_point.sh", "Windows_amd64"]
18+

docker/dist/README-Windows.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Windows-specific requirements
2+
3+
Run the wrapper scripts from a [Git for Windows](https://gitforwindows.org/) Bash shell.
4+
5+
If you run the beacon node binary directly, prefix it with "winpty -- ". It
6+
will increase the chance of Ctrl+C working inside that "mintty" terminal emulator.
7+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This Docker image can change from one build to another, because the upstream
2+
# Debian/Ubuntu package index is continuously updated and we have to run
3+
# `apt-get update` in here.
4+
#
5+
# The only way to make this a part of our reproducible build system is to build
6+
# it once, upload it to Docker Hub and make sure it's being pulled regularly so
7+
# it's not deleted after 6 months of inactivity.
8+
9+
FROM ubuntu:20.04
10+
11+
SHELL ["/bin/bash", "-c"]
12+
13+
ENV DEBIAN_FRONTEND=noninteractive TZ="Etc/UTC"
14+
RUN \
15+
apt-get -qq update \
16+
&& apt-get -qq -y install git gnupg software-properties-common lsb &>/dev/null \
17+
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9 \
18+
&& add-apt-repository "deb [arch=amd64] https://pkg.mxe.cc/repos/apt $(lsb_release -sc) main" \
19+
&& apt-get -qq update \
20+
&& apt-get -qq -y install mxe-x86-64-w64-mingw32.static-cc &>/dev/null \
21+
&& apt-get -qq clean \
22+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
23+

docker/dist/base_image/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ IMAGE_NAME := statusteam/nimbus_beacon_node:$(IMAGE_TAG)
77
build-amd64 \
88
build-arm64 \
99
build-arm \
10+
build-win64 \
1011
push-amd64 \
1112
push-arm64 \
12-
push-arm
13+
push-arm \
14+
push-win64
1315

1416
build-amd64:
1517
$(CURDIR)/make_base_image.sh amd64 "$(IMAGE_NAME)"
@@ -20,6 +22,9 @@ build-arm64:
2022
build-arm:
2123
$(CURDIR)/make_base_image.sh arm "$(IMAGE_NAME)_arm"
2224

25+
build-win64:
26+
$(CURDIR)/make_base_image.sh win64 "$(IMAGE_NAME)_win64"
27+
2328
# You probably don't want to recreate and push these base images to Docker Hub,
2429
# because when older images expire and get deleted, it will no longer be possible
2530
# to reproduce old releases.
@@ -33,3 +38,6 @@ build-arm:
3338
#push-arm: build-arm
3439
# docker push $(IMAGE_NAME)_arm
3540

41+
#push-win64: build-win64
42+
# docker push $(IMAGE_NAME)_win64
43+

docker/dist/base_image/make_base_image.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Copyright (c) 2020 Status Research & Development GmbH. Licensed under
3+
# Copyright (c) 2020-2021 Status Research & Development GmbH. Licensed under
44
# either of:
55
# - Apache License, version 2.0
66
# - MIT license
@@ -23,7 +23,7 @@ fi
2323
ARCH="${1}"
2424
DOCKER_TAG="${2}"
2525

26-
if [[ "${ARCH}" == "amd64" ]]; then
26+
if [[ "${ARCH}" == "amd64" || "${ARCH}" == "win64" ]]; then
2727
USE_QEMU=0
2828
else
2929
USE_QEMU=1
@@ -63,8 +63,6 @@ DOCKER_BUILDKIT=1 \
6363
docker build \
6464
-t ${DOCKER_TAG} \
6565
--progress=plain \
66-
--build-arg USER_ID=$(id -u) \
67-
--build-arg GROUP_ID=$(id -g) \
6866
${DOCKER_EXTRA_ARGS} \
6967
-f Dockerfile.${ARCH} .
7068

0 commit comments

Comments
 (0)