forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 1
175 lines (147 loc) · 5.4 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
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- develop
jobs:
test:
name: Go Tests
runs-on: ubuntu-8
# Creates a redis container for redis tests
services:
redis:
image: redis
ports:
- 6379:6379
strategy:
fail-fast: false
matrix:
test-mode: [defaults, race, challenge]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install dependencies
run: sudo apt update && sudo apt install -y wabt gotestsum
- name: Setup nodejs
uses: actions/setup-node@v2
with:
node-version: '16'
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'
- name: Install go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Install wasm-ld
run: |
sudo apt-get update && sudo apt-get install -y lld-10
sudo ln -s /usr/bin/wasm-ld-10 /usr/local/bin/wasm-ld
- name: Install rust wasm32-unknown-unknown
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
- name: Install rust wasm32-wasi
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-wasi
- name: Install rust stable
uses: actions-rs/toolchain@v1
id: install-rust
with:
profile: minimal
toolchain: stable
override: true
- name: Cache Build Products
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}-${{ matrix.test-mode }}
restore-keys: ${{ runner.os }}-go-
- name: Cache Rust Build Products
uses: actions/cache@v3
with:
path: |
~/.cargo/registry/
~/.cargo/git/
arbitrator/target/
arbitrator/wasm-libraries/target/
arbitrator/wasm-libraries/soft-float/SoftFloat/build
target/etc/initial-machine-cache/
key: ${{ runner.os }}-cargo-${{ steps.install-rust.outputs.rustc_hash }}-min-${{ hashFiles('arbitrator/Cargo.lock') }}-${{ matrix.test-mode }}
restore-keys: ${{ runner.os }}-cargo-${{ steps.install-rust.outputs.rustc_hash }}-
- name: Cache cbrotli
uses: actions/cache@v3
id: cache-cbrotli
with:
path: |
target/include/brotli/
target/lib-wasm/
target/lib/libbrotlicommon-static.a
target/lib/libbrotlienc-static.a
target/lib/libbrotlidec-static.a
key: ${{ runner.os }}-brotli-${{ hashFiles('build-brotli.sh') }}-${{ hashFiles('.github/workflows/arbitrator-ci.yaml') }}-${{ matrix.test-mode }}
restore-keys: ${{ runner.os }}-brotli-
- name: Build cbrotli-local
if: steps.cache-cbrotli.outputs.cache-hit != 'true'
run: ./build-brotli.sh -l
- name: Setup emsdk
if: steps.cache-cbrotli.outputs.cache-hit != 'true'
uses: mymindstorm/setup-emsdk@v11
with:
# Make sure to set a version number!
version: 3.1.6
# This is the name of the cache folder.
# The cache folder will be placed in the build directory,
# so make sure it doesn't conflict with anything!
actions-cache-folder: 'emsdk-cache'
no-cache: true
- name: Build cbrotli-wasm
if: steps.cache-cbrotli.outputs.cache-hit != 'true'
run: ./build-brotli.sh -w
- name: Build
run: make build test-go-deps -j
- name: Build all lint dependencies
run: make -j build-node-deps
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
skip-go-installation: true
skip-pkg-cache: true
- name: Set environment variables
run: |
mkdir -p target/tmp
echo "TMPDIR=$(pwd)/target/tmp" >> "$GITHUB_ENV"
echo "GOMEMLIMIT=6GB" >> "$GITHUB_ENV"
echo "GOGC=80" >> "$GITHUB_ENV"
- name: run tests without race detection
if: matrix.test-mode == 'defaults'
run: gotestsum --format short-verbose -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8
- name: run tests with race detection
if: matrix.test-mode == 'race'
run: gotestsum --format short-verbose -- ./... -race -parallel=8
- name: run redis tests
if: matrix.test-mode == 'defaults'
run: gotestsum --format short-verbose -- -p 1 -run TestRedis -tags redistest ./arbnode/... ./system_tests/... -coverprofile=coverage-redis.txt -covermode=atomic -coverpkg=./...
- name: run challenge tests
if: matrix.test-mode == 'challenge'
run: gotestsum --format short-verbose -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -parallel=8 -tags=challengetest -run=TestChallenge
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
if: matrix.test-mode == 'defaults'
with:
fail_ci_if_error: false
files: ./coverage.txt,./coverage-redis.txt
verbose: false
token: ${{ secrets.CODECOV_TOKEN }}