-
Notifications
You must be signed in to change notification settings - Fork 17
375 lines (315 loc) · 10.6 KB
/
main.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# This is a basic workflow to help you get started with Actions
name: Build and test
on:
push:
branches-ignore:
- 'docs-v*'
pull_request:
branches-ignore:
- 'docs-v*'
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test-contracts:
runs-on: ubuntu-latest
env:
working-directory: ./proxy
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install PYTHON
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install NODE JS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install project
working-directory: ${{env.working-directory}}
run: |
yarn install
- name: Install slither
working-directory: ${{env.working-directory}}
run: pip3 install -r scripts/requirements.txt
- name: Lint solidity
working-directory: ${{env.working-directory}}
run: yarn lint
- name: Compile typescript
working-directory: ${{env.working-directory}}
run: yarn tsc
- name: Lint typescript
working-directory: ${{env.working-directory}}
run: yarn eslint
- name: Slither checks
working-directory: ${{env.working-directory}}
run: yarn slither
- name: Gas calculation test
working-directory: ${{env.working-directory}}
run: npx hardhat test gas/calculateGas.ts
- name: Test upgrade
run: bash ./proxy/scripts/test_upgrade.sh
- name: Run tests
working-directory: ${{env.working-directory}}
run: |
npx hardhat coverage --solcoverjs .solcover.js
bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info -t $CODECOV_TOKEN || echo "Codecov did not collect coverage reports"
test-predeployed:
runs-on: ubuntu-latest
defaults:
run:
working-directory: proxy
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install PYTHON
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install NODE JS
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install project
run: |
yarn install
npm run compile
- name: Install python testing staff
run: pip3 install -r predeployed/test/requirements.txt
- name: Install geth
run: |
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt install ethereum
- name: Build predeployed pip package
env:
VERSION: "0.0.0"
run: |
python3 -m pip install build==0.4.0
./predeployed/scripts/build_package.sh
- name: Test predeployed pip package
env:
PYTHONPATH: src
run: |
killall -9 node || true # stop any ganache-cli, etc
killall -9 geth || true # stop any geth, etc
echo "-------------- checking occupied ports"
netstat -ltnp
echo "-------------- running tests"
./predeployed/test/prepare_environment.sh
./predeployed/test/test.sh
- name: Test ABIs generation
env:
VERSION: "0.0.0"
run: |
python3 -m venv predeployed/scripts/venv
source predeployed/scripts/venv/bin/activate
pip install predeployed/dist/ima_predeployed-*.whl
python predeployed/scripts/generate_abi.py > data/ima-$VERSION-predeployed-abi.json
test-agent:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: SYSTEM VERSION CHECKS
run: |
echo ------------ GIT_CURRENT_BRANCH
export GIT_CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo $GIT_CURRENT_BRANCH
echo ------------ GIT_SYMBOLIC_BRANCH
export GIT_SYMBOLIC_BRANCH=$(git symbolic-ref --short HEAD)
echo $GIT_SYMBOLIC_BRANCH
echo ------------ GITHUB_WORKFLOW
echo $GITHUB_WORKFLOW
echo ------------ GITHUB_RUN_ID
echo $GITHUB_RUN_ID
echo ------------ GITHUB_RUN_NUMBER
echo $GITHUB_RUN_NUMBER
echo ------------ GITHUB_ACTION
echo $GITHUB_ACTION
echo ------------ GITHUB_ACTIONS
echo $GITHUB_ACTIONS
echo ------------ GITHUB_ACTOR
echo $GITHUB_ACTOR
echo ------------ GITHUB_REPOSITORY
echo $GITHUB_REPOSITORY
echo ------------ GITHUB_EVENT_NAME
echo $GITHUB_EVENT_NAME
echo ------------ GITHUB_EVENT_PATH
echo $GITHUB_EVENT_PATH
echo ------------ GITHUB_WORKSPACE
echo $GITHUB_WORKSPACE
echo ------------ GITHUB_SHA
echo $GITHUB_SHA
echo ------------ GITHUB_REF
echo $GITHUB_REF
echo ------------ GITHUB_HEAD_REF
echo $GITHUB_HEAD_REF
echo ------------ GITHUB_BASE_REF
echo $GITHUB_BASE_REF
echo ------------ user
echo $USER
echo ------------ home
echo $HOME
echo ------------ path
echo $PATH
echo ------------ pwd
pwd
echo ------------ unix name - a
uname -a || true
echo ------------ unix name - r
uname -r || true
echo ------------ lsb
lsb_release -a || true
echo ------------ hostnamectl
hostnamectl || true
echo ------------ /etc/os-release
cat /etc/os-release || true
echo ------------ /proc/version
cat /proc/version || true
echo ------------ lscpu
lscpu || true
- name: ESLINT
run: |
sudo npm install -g eslint
eslint --version
- name: INSTALL PREREQUISITES - ROOT - PACKAGES
run: |
yarn install
ls -1
- name: JS LINT CHECK EVERYTHING IN AGENT AND NPMS WITH ESLINT
run: |
yarn run lint-check
echo "Looks like no JS code formatting errors so far)"
- name: PY CHECKS
run: |
echo ------------ python version check
which python || echo "----> Looks like python was not installed, next command will fail"
python --version
echo ------------ python3 version check
which python3 || echo "----> Looks like python3 was not installed, next command will fail"
python3 --version
- name: INSTALL PREREQUISITES - PY
run: |
echo ------------ py3 installs
sudo apt-get install python3-pip python3-setuptools python3-dev
echo ------------ py3 wheel - apt
sudo apt-get install python3-wheel
echo ------------ py3 wheel - pip
pip3 install wheel
echo ------------ slither analyzer install
#pip3 install slither-analyzer==0.8.3
pip3 install -r proxy/scripts/requirements.txt
echo ------------ slither search attempt
sudo find / -name slither || true
echo ------------ slither location detection - after install
export PATH=$PATH:/home/$USER/.local/bin
which slither || echo "----> Looks like slither was not installed, next command will fail"
echo ------------ slither version check - after install
slither --version || true
- name: INSTALL PREREQUISITES - AGENT - PACKAGES
run: |
cd agent
yarn install
cd ..
- name: INSTALL PREREQUISITES - SKALE-IMA - PACKAGES
run: |
cd npms/skale-ima
yarn install
cd ../..
- name: INSTALL PREREQUISITES - SKALE-OWASP - PACKAGES
run: |
cd npms/skale-owasp
yarn install
cd ../..
test-integration:
runs-on: ubuntu-latest
env:
working-directory: ./test
steps:
- uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Compile contracts
working-directory: ./proxy
run: |
yarn install
- name: Install agent
run: |
cd agent
yarn install
cd ../npms/skale-ima
yarn install
- name: Start background ganache
run: |
cd proxy
npx ganache --miner.blockGasLimit 12000000 --logging.quiet --chain.allowUnlimitedContractSize --wallet.defaultBalance 2000000 --wallet.accountKeysPath ../test/accounts.json &
- name: Prepare test (PY part)
working-directory: ${{env.working-directory}}
run: |
python3 ../scripts/config_from_accounts.py accounts.json config.json
pip3 install -r requirements.txt
- name: Run test (PY part)
working-directory: ${{env.working-directory}}
run: |
python3 test.py
- name: Prepare test (JS part)
working-directory: ${{env.working-directory}}
run: |
yarn install
- name: Run test (JS part)
working-directory: ${{env.working-directory}}
run: |
yarn test