-
Notifications
You must be signed in to change notification settings - Fork 8
227 lines (217 loc) · 6.74 KB
/
ci.yaml
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
name: Contracts CI
on:
push:
branches: [main]
pull_request:
branches: [main]
types: [opened, reopened, synchronize, ready_for_review]
jobs:
setup:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
name: setup
outputs:
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }}
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- run: npm run build
- name: Lint
run: |
npm run check:contracts
npm run check:scripts
- name: Verify interface ids
run: npm run natspec-interface-id
- id: set-test-chunks
name: Set Chunks
run: echo "test-chunks=$(jq -c '.' test/util/test-chunks.txt)" >> $GITHUB_OUTPUT
- id: set-test-chunk-ids
name: Set Chunk IDs
run: |
echo "test-chunk-ids=$( echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT
env:
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }}
test:
needs: setup
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
env:
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }}
name: test (chunk ${{ matrix.chunk }})
strategy:
matrix:
chunk: ${{ fromJson(needs.setup.outputs['test-chunk-ids']) }}
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: Install Dependencies
run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- name: Compile Contracts
run: npm run build
- name: Contract Sizing
run: npm run size
- name: Unit Tests
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx hardhat test
env:
CHUNKS: ${{ needs.setup.outputs['test-chunks'] }}
integration-test:
needs: setup
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
env:
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }}
name: "test:integration"
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: Install Dependencies
run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- name: Integration tests
run: npx hardhat test test/integration/*.js
coverage:
needs: setup
if: ${{ !github.event.pull_request.draft }}
env:
GAS_REPORTER_COINMARKETCAP_API_KEY: ${{ secrets.COINMARKETCAP_API_KEY }}
name: code coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: Install Dependencies
run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- name: Code coverage
run: npm run coverage
- name: Upload code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: coverage/
- name: Check Code Coverage
shell: bash
run: |
MAX_SKIPPED=1 # at this moment msgData() in BosonVoucher is not covered
{ read TOTAL; read COVERED; read COVERAGE; } <<< $(jq '.total.lines.total, .total.lines.covered, .total.lines.pct' coverage/coverage-summary.json)
SKIPPED=$(($TOTAL - $COVERED))
echo "solidity code coverage is '$COVERAGE'"
if (( $(echo "$SKIPPED > $MAX_SKIPPED" | bc -l) )); then echo "Fail: number of skipped statements '$SKIPPED' is higher than configured '$MAX_SKIPPED'" >&2; exit 1; fi
echo "Number of skipped statements '$SKIPPED' is within configured '$MAX_SKIPPED'"
report-coverage:
needs: coverage
runs-on: ubuntu-latest
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
name: "report: coverage"
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: npm install
run: npm install
- name: Download code coverage results
uses: actions/download-artifact@v3
with:
name: code-coverage-report
path: coverage/
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage/lcov.info
deploy-dry-run:
needs: setup
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
name: "deploy: dry run"
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: Install Dependencies
run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- name: Deploy suite locally
run: npm run deploy-suite:hardhat
- name: Cancelling tests in case of failure
if: failure()
uses: andymckay/cancel-action@0.2
analyze:
needs: setup
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3.1.0
- name: Setup node
uses: actions/setup-node@v3.5.1
with:
node-version: 16.14.x
cache: "npm"
- name: Install Dependencies
run: npm install
- name: Prepare Environment
shell: bash
run: |
cp .env.example .env
- name: Slither analyzer
uses: crytic/slither-action@v0.3.0
id: slither
with:
node-version: 16
sarif: results.sarif
fail-on: none
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.slither.outputs.sarif }}