-
Notifications
You must be signed in to change notification settings - Fork 1.7k
309 lines (296 loc) · 11.7 KB
/
solidity.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
name: Solidity
on:
merge_group:
push:
env:
NODE_OPTIONS: --max_old_space_size=7168
defaults:
run:
shell: bash
jobs:
changes:
name: Detect changes
runs-on: ubuntu-latest
outputs:
changes: ${{ steps.changes.outputs.src }}
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changes
with:
filters: |
src:
- 'contracts/**/*'
- '.github/workflows/solidity.yml'
split-tests:
name: Split Solidity Tests
runs-on: ubuntu-latest
outputs:
splits: ${{ steps.split.outputs.splits }}
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Generate splits
id: split
uses: ./.github/actions/split-tests
with:
config: ./contracts/ci.json
- name: Collect Metrics
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Split Solidity Tests
continue-on-error: true
solidity-coverage-splits:
needs: [changes, split-tests]
name: Solidity Coverage ${{ matrix.split.id }} ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
strategy:
fail-fast: false
matrix:
split: ${{ fromJson(needs.split-tests.outputs.splits) }}
runs-on: ubuntu20.04-4cores-16GB
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Setup Hardhat
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-hardhat
with:
namespace: coverage
- name: Run coverage
if: ${{ needs.changes.outputs.changes == 'true' }}
env:
SPLIT: ${{ matrix.split.coverageTests }}
shell: bash
run: pnpm coverage --testfiles "$SPLIT"
working-directory: contracts
- name: Push coverage
if: ${{ needs.changes.outputs.changes == 'true' }}
run: ./tools/bin/codecov -f ./contracts/coverage.json
- name: Rename coverage
if: ${{ needs.changes.outputs.changes == 'true' }}
run: mv ./contracts/coverage.json ./contracts/coverage-${{ matrix.split.idx }}.json
- name: Upload coverage
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: actions/upload-artifact@v3
with:
name: solidity-coverage-${{ matrix.split.idx }}
path: ./contracts/coverage-${{ matrix.split.idx }}.json
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Solidity Coverage ${{ matrix.split.id }}
continue-on-error: true
solidity-coverage:
needs: [changes, solidity-coverage-splits]
name: Solidity Coverage ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Make coverage directory
if: ${{ needs.changes.outputs.changes == 'true' }}
run: mkdir ./contracts/coverage-reports
- name: Download coverage
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: actions/download-artifact@v3
with:
path: ./contracts/coverage-reports
- name: Display structure of downloaded files
if: ${{ needs.changes.outputs.changes == 'true' }}
run: ls -R coverage-reports
working-directory: contracts
- name: Generate merged report
if: ${{ needs.changes.outputs.changes == 'true' }}
run: pnpm istanbul report text text-summary
working-directory: contracts
solidity-splits:
needs: [changes, split-tests]
name: Solidity ${{ matrix.split.id }} ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
strategy:
fail-fast: false
matrix:
split: ${{ fromJson(needs.split-tests.outputs.splits) }}
runs-on: ubuntu20.04-4cores-16GB
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Setup Hardhat
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-hardhat
with:
namespace: coverage
- name: Run tests
if: ${{ needs.changes.outputs.changes == 'true' }}
env:
SPLIT: ${{ matrix.split.tests }}
working-directory: contracts
run: pnpm test -- $SPLIT
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Solidity ${{ matrix.split.id }}
continue-on-error: true
solidity:
needs: [changes, solidity-splits]
name: Solidity
runs-on: ubuntu-latest
if: always()
steps:
- run: echo 'Solidity tests finished!'
- name: Check test results
run: |
if [[ "${{ needs.changes.result }}" = "failure" || "${{ needs.solidity-splits.result }}" = "failure" ]]; then
echo "One or more changes / solidity-splits jobs failed"
exit 1
else
echo "All test jobs passed successfully"
fi
- name: Collect Metrics
if: always()
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@8163dcea2f01a0a8fec84b284406ff7af1d2e1c0
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Solidity
continue-on-error: true
prepublish-test:
needs: [changes]
name: Prepublish Test ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Run Prepublish test
if: ${{ needs.changes.outputs.changes == 'true' }}
working-directory: contracts
run: pnpm prepublishOnly
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Prepublish Test
continue-on-error: true
native-compile:
needs: [changes]
name: Native Compilation ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Checkout diff-so-fancy
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
with:
repository: so-fancy/diff-so-fancy
ref: a673cb4d2707f64d92b86498a2f5f71c8e2643d5 # v1.4.3
path: diff-so-fancy
- name: Install diff-so-fancy
run: echo "$GITHUB_WORKSPACE/diff-so-fancy" >> $GITHUB_PATH
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
with:
prod: "true"
- name: Setup Go
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-go
- name: Run native compile and generate wrappers
if: ${{ needs.changes.outputs.changes == 'true' }}
run: make go-solidity-wrappers
- name: Verify local solc binaries
if: ${{ needs.changes.outputs.changes == 'true' }}
run: ./tools/ci/check_solc_hashes
- name: Check if Go solidity wrappers are updated
if: ${{ needs.changes.outputs.changes == 'true' }}
run: git diff --minimal --color --exit-code | diff-so-fancy
- name: Comment on fix instructions
env:
GITHUB_TOKEN: ${{ github.token }}
if: ${{ failure() }}
run: gh pr comment -b 'Go solidity wrappers are out-of-date, regenerate them via the `make go-solidity-wrappers` command'
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Native Compilation
continue-on-error: true
lint:
defaults:
run:
working-directory: contracts
needs: [changes]
name: Lint ${{ fromJSON('["(skipped)", ""]')[needs.changes.outputs.changes == 'true'] }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Run pnpm lint
if: ${{ needs.changes.outputs.changes == 'true' }}
run: pnpm lint
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Lint
continue-on-error: true
prettier:
defaults:
run:
working-directory: contracts
needs: [changes]
name: Prettier Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout the repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Setup NodeJS
if: ${{ needs.changes.outputs.changes == 'true' }}
uses: ./.github/actions/setup-nodejs
- name: Run prettier check
if: ${{ needs.changes.outputs.changes == 'true' }}
run: pnpm prettier:check
- name: Collect Metrics
if: ${{ needs.changes.outputs.changes == 'true' }}
id: collect-gha-metrics
uses: smartcontractkit/push-gha-metrics-action@90fcbaac8ebf86da9c4d55dba24f6fe3029f0e0b
with:
basic-auth: ${{ secrets.GRAFANA_CLOUD_BASIC_AUTH }}
hostname: ${{ secrets.GRAFANA_CLOUD_HOST }}
this-job-name: Prettier Formatting
continue-on-error: true