Skip to content

Commit cdd4f62

Browse files
committed
feat: CI
1 parent 4cf54ae commit cdd4f62

File tree

14 files changed

+483
-6
lines changed

14 files changed

+483
-6
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* @samcm
2+
* @savid
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
2+
name: Run a checkpoint sync test
3+
description: Runs a consensus client and checkpoint syncs from the running checkpointz instance.
4+
5+
inputs:
6+
consensus:
7+
description: "The name of the consensus client to use (one of lighthouse, teku, prysm, nimbus, lodestar)."
8+
required: true
9+
network:
10+
description: "The name of the network to run the test against (one of ropsten, sepolia, prater/goerli)."
11+
required: true
12+
13+
14+
runs:
15+
using: composite
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Prepare environment
19+
shell: bash
20+
run: |
21+
mkdir $HOME/bin;
22+
export PATH=$HOME/bin:$PATH;
23+
echo "Running against ${{ inputs.network }} with ${{ inputs.consensus }}.";
24+
- name: Build checkpointz
25+
shell: bash
26+
run: |
27+
docker build . -t samcm/checkpointz:local;
28+
- name: Configure checkpointz
29+
shell: bash
30+
run: |
31+
cat <<EOF > checkpointz.yaml
32+
global:
33+
listenAddr: ":5555"
34+
logging: "debug" # panic,fatal,warm,info,debug,trace
35+
36+
beacon:
37+
upstreams:
38+
- name: state-provider
39+
address: https://${{ inputs.network }}-debug.checkpoint-sync.ethdevops.io
40+
timeoutSeconds: 30
41+
dataProvider: true
42+
checkpointz:
43+
mode: full
44+
caches:
45+
blocks:
46+
max_items: 500
47+
states:
48+
max_items: 5
49+
historical_epoch_count: 5
50+
EOF
51+
- name: Create log directories
52+
shell: bash
53+
run: |
54+
mkdir -p logs;
55+
- name: Create docker network
56+
shell: bash
57+
run: |
58+
docker network create eth
59+
- name: Run checkpointz
60+
shell: bash
61+
run: |
62+
echo "Starting checkpointz...";
63+
docker run -d --network eth -p 5555:5555 -v $(pwd):/data --name checkpointz samcm/checkpointz:local --config /data/checkpointz.yaml;
64+
docker logs checkpointz -f &> logs/checkpointz.log &
65+
docker logs checkpointz -f &
66+
echo "Checkpointz is running.";
67+
- name: Wait for checkpointz to have a finalized checkpoint
68+
shell: bash
69+
run: |
70+
echo "Waiting for checkpointz to have a finalized checkpoint...";
71+
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5555/eth/v1/beacon/states/finalized/finality_checkpoints)" != "200" ]]; do sleep 1; done';
72+
echo "Checkpointz has a finalized checkpoint.";
73+
- name: Wait for checkpointz to have the genesis block
74+
shell: bash
75+
run: |
76+
echo "Waiting for checkpointz to have the genesis block...";
77+
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:5555/eth/v2/beacon/blocks/0)" != "200" ]]; do sleep 1; done';
78+
echo "Checkpointz has the genesis block.";
79+
- name: Run teku client
80+
shell: bash
81+
if: ${{ inputs.consensus == 'teku' }}
82+
run: |
83+
echo "Starting Teku...";
84+
docker run -p 5052:5052 -d --name beacon --network eth -e TEKU_REST_API_ENABLED=true -e TEKU_P2P_PORT=9000 consensys/teku:latest --rest-api-port=5052 --network=${{ inputs.network }} --log-destination=CONSOLE --initial-state=http://checkpointz:5555/eth/v2/debug/beacon/states/finalized --ee-endpoint=http://102.10.10.1:8545
85+
echo "Teku is running.";
86+
- name: Run lighthouse client
87+
shell: bash
88+
if: ${{ inputs.consensus == 'lighthouse' }}
89+
run: |
90+
echo "Starting Lighthouse...";
91+
docker run -p 5052:5052 --network eth -d --name beacon sigp/lighthouse:latest lighthouse bn --network=${{ inputs.network }} --datadir=/data --checkpoint-sync-url=http://checkpointz:5555 --http --http-address=0.0.0.0
92+
echo "Lighthouse is running.";
93+
- name: Run prysm
94+
shell: bash
95+
if: ${{ inputs.consensus == 'prysm' }}
96+
run: |
97+
echo "Starting prysm...";
98+
docker run -d --name beacon --network eth -p 5052:5052 gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data --accept-terms-of-use --${{ inputs.network }} --clear-db --grpc-gateway-port=5052 --grpc-gateway-host=0.0.0.0 --http-web3provider=http://localhost:8545 --force-clear-db --checkpoint-sync-url=http://checkpointz:5555 --genesis-beacon-api-url=http://checkpointz:5555 --grpc-gateway-port=5052
99+
echo "Prysm is running.";
100+
- name: Run nimbus
101+
shell: bash
102+
if: ${{ inputs.consensus == 'nimbus' }}
103+
run: |
104+
echo "Starting nimbus...";
105+
docker run --name beacon --network eth statusim/nimbus-eth2:amd64-latest trustedNodeSync --network=${{ inputs.network }} --trusted-node-url=http://checkpointz:5555 --backfill=false
106+
echo "Nimbus is running.";
107+
- name: Run lodestar
108+
shell: bash
109+
if: ${{ inputs.consensus == 'lodestar' }}
110+
run: |
111+
echo "Starting lodestar...";
112+
docker run --name beacon -d --network eth -p 5052:5052 chainsafe/lodestar beacon --dataDir /data --network ${{ inputs.network }} --checkpointSyncUrl=http://checkpointz:5555 --rest --rest.address 0.0.0.0 --rest.port=5052
113+
echo "Lodestar is running.";
114+
- name: Wait for consensus client to have checkpoint synced
115+
shell: bash
116+
if: ${{ inputs.consensus != 'nimbus' }}
117+
run: |
118+
docker logs beacon -f &> logs/consensus.log &
119+
docker logs beacon -f &
120+
while true; do
121+
if [[ $(curl -s localhost:5052/eth/v1/node/syncing | jq '.data.head_slot|tonumber') -gt 1000 ]]; then
122+
break;
123+
fi
124+
sleep 1;
125+
done;
126+
- uses: actions/upload-artifact@v3
127+
if: ${{ always() }}
128+
with:
129+
name: ${{ inputs.network }}-${{ inputs.consensus }}-checkpointz.log
130+
path: logs/checkpointz.log
131+
- uses: actions/upload-artifact@v3
132+
if: ${{ always() }}
133+
with:
134+
name: ${{ inputs.network }}-${{ inputs.consensus }}-consensus.log
135+
path: logs/consensus.log

.github/workflows/golangci-lint.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: golangci-lint
2+
on:
3+
# push:
4+
# tags:
5+
# - v*
6+
# branches:
7+
# - master
8+
pull_request:
9+
permissions:
10+
contents: read
11+
# Optional: allow read access to pull request. Use with `only-new-issues` option.
12+
# pull-requests: read
13+
jobs:
14+
golangci:
15+
name: lint
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/setup-go@v3
19+
with:
20+
go-version: 1.18
21+
- uses: actions/checkout@v3
22+
- name: golangci-lint
23+
uses: golangci/golangci-lint-action@v3
24+
with:
25+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
26+
version: latest
27+
28+
# Optional: working directory, useful for monorepos
29+
# working-directory: somedir
30+
31+
# Optional: golangci-lint command line arguments.
32+
# args: --issues-exit-code=0
33+
34+
# Optional: show only new issues if it's a pull request. The default value is `false`.
35+
# only-new-issues: true
36+
37+
# Optional: if set to true then the all caching functionality will be complete disabled,
38+
# takes precedence over all other caching options.
39+
# skip-cache: true
40+
41+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
42+
# skip-pkg-cache: true
43+
44+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
45+
# skip-build-cache: true

.github/workflows/goreleaser.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
-
18+
name: Set up Go
19+
uses: actions/setup-go@v3
20+
-
21+
name: Set up NodeJS
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
-
26+
name: Login to DockerHub
27+
uses: docker/login-action@v1
28+
with:
29+
username: ${{ secrets.DOCKERHUB_USERNAME }}
30+
password: ${{ secrets.DOCKERHUB_TOKEN }}
31+
-
32+
name: Run GoReleaser
33+
uses: goreleaser/goreleaser-action@v3
34+
with:
35+
distribution: goreleaser
36+
version: latest
37+
args: release --rm-dist
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Go Test
2+
3+
on:
4+
pull_request:
5+
6+
workflow_dispatch:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
full_ci:
11+
strategy:
12+
matrix:
13+
go_version: [ 1.18.x ]
14+
15+
runs-on: ubuntu-20.04
16+
17+
steps:
18+
- name: checkout
19+
uses: actions/checkout@v2
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v3
23+
with:
24+
go-version: ${{ matrix.go_version }}
25+
26+
- name: run tests
27+
run: go test -json ./... > test.json
28+
29+
- name: Annotate tests
30+
if: always()
31+
uses: guyarb/[email protected]
32+
with:
33+
test-results: test.json
34+

.gitignore

Whitespace-only changes.

.golangci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
linters-settings:
2+
errcheck:
3+
check-type-assertions: true
4+
goconst:
5+
min-len: 2
6+
min-occurrences: 3
7+
gocritic:
8+
enabled-tags:
9+
- diagnostic
10+
- experimental
11+
- opinionated
12+
- performance
13+
- style
14+
govet:
15+
check-shadowing: true
16+
nolintlint:
17+
require-explanation: true
18+
require-specific: true
19+
20+
linters:
21+
disable-all: true
22+
enable:
23+
- bodyclose
24+
- deadcode
25+
- depguard
26+
- dogsled
27+
- dupl
28+
- errcheck
29+
- exportloopref
30+
- goconst
31+
- gocritic
32+
- gofmt
33+
- goimports
34+
- gocyclo
35+
- gosec
36+
- gosimple
37+
- govet
38+
- misspell
39+
- nolintlint
40+
- nakedret
41+
- prealloc
42+
- revive
43+
- staticcheck
44+
- structcheck
45+
- stylecheck
46+
- thelper
47+
- tparallel
48+
- typecheck
49+
- unconvert
50+
- varcheck
51+
- whitespace
52+
- wsl
53+
54+
run:
55+
issues-exit-code: 1

0 commit comments

Comments
 (0)