forked from flare-foundation/flare-smart-contracts-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
262 lines (225 loc) · 6.08 KB
/
.gitlab-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
# Prevent duplicate pipelines (MR and BRANCH pipelines, when a MR is opened for the given branch)
workflow:
rules:
- if: '$CI_OPEN_MERGE_REQUESTS != null && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "webide")'
when: never
- when: always
default:
tags: [ flarenetwork ]
variables:
YARN_CACHE_DIR: .yarn-cache
##
## PARTIALS
##
.partials:
cache-nodejs:
key:
files: [ yarn.lock ]
paths:
- $YARN_CACHE_DIR
- node_modules/
policy: pull
##
## SCANNERS
##
include:
- template: Jobs/SAST.latest.gitlab-ci.yml
- template: Jobs/Dependency-Scanning.latest.gitlab-ci.yml
- template: Jobs/Secret-Detection.latest.gitlab-ci.yml
sast:
needs: []
dependency_scanning:
needs: []
.secret-analyzer:
needs: []
scanner-slither:
image: node:18
timeout: 7 minutes
needs: []
cache: [ !reference [.partials, cache-nodejs] ]
variables:
PIP_BREAK_SYSTEM_PACKAGES: "1"
before_script:
- apt-get update 1> /dev/null
- apt-get install -y python3-pip 1> /dev/null
- pip3 install slither-analyzer 1> /dev/null
- yarn install --frozen-lockfile --cache-folder $YARN_CACHE_DIR
- rm -f ./slither.json ./slither_badge.json
script:
- slither . --json=./slither.json 2>/dev/null || true; node scripts/slither-parse.js ./slither.json
artifacts:
when: always
expire_in: 7 days
paths: [ slither.json ]
##
##
##
build-smart-contracts:
stage: build
needs: []
image: node:18
timeout: 10 minutes
before_script:
- yarn install --frozen-lockfile --cache-folder $YARN_CACHE_DIR
script:
- yarn c
cache:
- key:
files: [ yarn.lock ]
paths:
- $YARN_CACHE_DIR
- node_modules/
policy: pull-push
artifacts:
paths:
- typechain
- typechain-truffle
- typechain-web3
expire_in: 1 week
##
## UNIT TESTS
##
.test-node-sc:
image: node:18
timeout: 5 minutes
needs:
- job: build-smart-contracts
artifacts: true
cache: [ !reference [.partials, cache-nodejs] ]
variables:
DEPLOYER_PRIVATE_KEY: "0xc5e8f61d1ab959b397eecc0a37a6517b8e67a0e7cf1f4bce5591f3ed80199122"
GENESIS_GOVERNANCE_PRIVATE_KEY: "0x50777f5a3ce16445e63411bf1e865a2a11d5ca3c4cbc1de00808a52180bd8d3c"
GOVERNANCE_PRIVATE_KEY: "0xd49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb"
GOVERNANCE_PUBLIC_KEY: "0xeAD9C93b79Ae7C1591b1FB5323BD777E86e150d4"
GOVERNANCE_EXECUTOR_PUBLIC_KEY: "0xE5904695748fe4A84b40b3fc79De2277660BD1D3"
before_script:
- yarn install --frozen-lockfile --cache-folder $YARN_CACHE_DIR 1>/dev/null
test-unit-hardhat:
extends: .test-node-sc
parallel:
matrix:
- TEST_ARG:
- ./test/unit/protocol/coding/coding.test.ts
- ./test/unit/protocol/implementation/RewardManager.test.ts
- ./test/unit/protocol/implementation/Submission.test.ts
- ./test/unit/fastUpdates/lib/Bn256.test.ts
- ./test/unit/fastUpdates/lib/FixedPointArithmetic.test.ts
- ./test/unit/fastUpdates/lib/Sortition.test.ts
script:
- yarn hardhat test --network hardhat ${TEST_ARG}
test-unit-hardhat-md:
extends: test-unit-hardhat
timeout: 10 minutes
tags: [ flarenetwork-md ]
parallel:
matrix:
- TEST_ARG:
- ./test/unit/protocol/implementation/Relay.test.ts
- ./test/unit/fastUpdates/implementation/FastUpdateIncentiveManager.test.ts
- ./test/unit/fastUpdates/implementation/FastUpdater.test.ts
test-contract-end-to-end:
extends: .test-node-sc
tags: [ flarenetwork-md ]
script:
- yarn hardhat test ./test/integration/EndToEnd.test.ts
test-linter:
extends: .test-node-sc
script:
- yarn lint
test-linter-forge:
extends: .test-node-sc
script:
- yarn lint-forge
test-unit-forge:
extends: .test-node-sc
timeout: 4 minutes
image: ghcr.io/foundry-rs/foundry
before_script:
- forge install
script:
- forge test -vvv
##
## COVERAGE
##
coverage-hardhat:
image: node:18
needs: []
timeout: 20 minutes
tags: [ flarenetwork-md ]
cache: [ !reference [.partials, cache-nodejs] ]
before_script:
- yarn install --frozen-lockfile --cache-folder $YARN_CACHE_DIR 1>/dev/null
script:
- yarn run coverage
- cp coverage/cobertura-coverage.xml coverage-hardhat-cobertura.xml
artifacts:
name: coverage-hardhat
when: always
expire_in: 1 month
paths:
- ./coverage/
- ./coverage.json
- coverage-hardhat-cobertura.xml
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
coverage-forge-node_modules:
stage: .pre
needs: []
image: node:18
timeout: 7 minutes
before_script:
- apt-get update -y 1>/dev/null
- apt-get install -y zip 1>/dev/null
script:
- |
set -o pipefail
yarn install --frozen-lockfile --cache-folder $YARN_CACHE_DIR 1>/dev/null
find node_modules -name '*.sol' | xargs zip node_modules.sol.zip
artifacts:
expire_in: 5 minutes
paths:
- node_modules.sol.zip
coverage-forge:
image: ghcr.io/foundry-rs/foundry
needs:
- job: coverage-forge-node_modules
artifacts: true
tags: [ flarenetwork-md ]
timeout: 3 minutes
before_script:
- forge install
- unzip node_modules.sol.zip
script:
- forge coverage --report summary --report lcov
artifacts:
expire_in: 30 days
paths:
- lcov.info
coverage-forge-reports:
image: node:18-alpine
timeout: 3 minutes
needs:
- job: coverage-forge
artifacts: true
before_script:
- echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk add --no-cache python3 py3-pip lcov 1>/dev/null
- pip3 install --break-system-packages lcov_cobertura 1>/dev/null
script:
- node scripts/forge-lcov-prune.js
- genhtml lcov.info.pruned --branch-coverage --output-dir coverage-forge
- lcov_cobertura lcov.info.pruned --output coverage-forge-cobertura.xml
- lcov --summary lcov.info.pruned --rc branch_coverage=1
coverage: '/ lines[\ .:]+\d+\.\d+%/' # https://regex101.com/r/KVj9Dr/1
artifacts:
expire_in: 30 days
paths:
- lcov.info.pruned
- coverage-forge
- coverage-forge-cobertura.xml
reports:
coverage_report:
coverage_format: cobertura
path: coverage-forge-cobertura.xml