-
Notifications
You must be signed in to change notification settings - Fork 61
246 lines (234 loc) Β· 7.74 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
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
name: 'CI'
on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- '**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-lint-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-lint-${{ env.cache-name }}-
- run: npm ci
- run: npm install -g solhint
- run: solhint contracts/**/*.sol
tests_full:
runs-on: ubuntu-latest
steps:
- name: "step-log-ref"
run: |
echo "[C] github.ref: ${{github.ref}}"
- name: "step-log-event_name "
run: |
echo "[C] github.event_name : ${{github.event_name }}"
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
- run: npm ci
- name: Run Hardhat
run: |
npx hardhat node &
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Run tests
run: npm run test:full:cover
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/
slither:
name: Slither Analysis
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Run Slither
uses: crytic/slither-action@v0.1.0
continue-on-error: true
id: slither
with:
node-version: 16
sarif: results.sarif
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}`
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v1
with:
sarif_file: ${{ steps.slither.outputs.sarif }}
coverage:
runs-on: ubuntu-latest
needs: [tests_full]
if: ${{ success() && github.actor != 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: coverage
path: coverage/
- uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
if: "${{ env.CC_TEST_REPORTER_ID != '' }}"
with:
coverageLocations: |
${{ github.workspace }}/coverage/lcov.info:lcov
check_deployment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
# Env var expansion workaround
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set ADDRESS_FILE
run: echo "ADDRESS_FILE=${HOME}/.ocean/ocean-contracts/artifacts/address.json" >> $GITHUB_ENV
- name: Build local docker file
run: docker build -t 'oceanprotocol/ocean-contracts:test' .
- name: Checkout Barge
uses: actions/checkout@v3
with:
repository: 'oceanprotocol/barge'
path: 'barge'
- name: Run Ganache with Barge
working-directory: ${{ github.workspace }}/barge
run: |
bash -x start_ocean.sh --no-aquarius --no-elasticsearch --no-provider --no-dashboard 2>&1 > start_ocean.log &
env:
CONTRACTS_VERSION: test
- run: npm ci
- name: Wait for contracts deployment
working-directory: ${{ github.workspace }}/barge
run: |
for i in $(seq 1 250); do
sleep 5
[ -f "$HOME/.ocean/ocean-contracts/artifacts/ready" ] && break
done
ls -la "$HOME/.ocean/ocean-contracts/artifacts/"
- run: cat ${HOME}/.ocean/ocean-contracts/artifacts/address.json
- name: docker logs
run: docker logs ocean-ocean-contracts-1
- run: node scripts/check_deployment.js
publish-npm:
needs: [lint, tests_full,check_deployment]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- name: Delete useless files
run: rm -rf ./artifacts/build-info/*
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
publish-pypi:
runs-on: ubuntu-latest
needs: [lint, tests_full,check_deployment]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: "step-log-ref"
run: |
echo "[C] github.ref: ${{github.ref}}"
- name: "step-log-event_name "
run: |
echo "[C] github.event_name : ${{github.event_name }}"
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '20'
- name: Cache node_modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-test-unit-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-test-unit-${{ env.cache-name }}-
- run: npm ci
- name: Compile contracts
run: |
npx hardhat compile --force
env:
ALCHEMY_URL: ${{secrets.ALCHEMY_URL}}
- name: Delete dbg files
run: find ./artifacts/* -name "*.dbg.json" -type f -delete
- name: Delete useless files
run: rm -rf ./artifacts/build-info/*
- name: Copy artifacts to root folder
run: find ./artifacts/contracts -name '*.json' -exec mv '{}' './artifacts/' ';'
- name: Remove folders from artifacts
run: find ./artifacts -maxdepth 1 -mindepth 1 -type d -exec rm -rf '{}' \;
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Create __init__.py files
run: |
find artifacts -type d -exec touch '{}'/__init__.py ';'
find addresses -type d -exec touch '{}'/__init__.py ';'
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}