/
config.yml
397 lines (371 loc) · 13.4 KB
/
config.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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
workflows:
version: 2.1
node-multi-build:
jobs:
- check-coding-style
- node-v10
- node-v12
- node-v14
- node-v16:
run_coveralls: true
- node-v18
- hardhat-core-default-solc
- hardhat-core-latest-solc
- hardhat-sample-project
- truffle-sample-project
- cli-smoke-test
- solidity-solcjs-ext-test
version: 2.1
orbs:
shellcheck: circleci/shellcheck@volatile
commands:
show-npm-version:
steps:
- run:
name: Versions
command: npm version
update-npm:
steps:
- run:
name: Update globally available npm to the latest version
# Note: We need npm >= 8.3 which supports 'overrides' in package.json
command: npm install npm --global
install-dependencies:
parameters:
cache-id:
type: string
path:
type: string
default: .
package-manager:
type: string
default: npm
dependency-file:
type: string
default: package.json
steps:
- restore_cache:
key: <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
- run:
name: "<<parameters.package-manager>> install in <<parameters.path>>"
command: |
cd "<<parameters.path>>"
[[ -e node_modules/ ]] || <<parameters.package-manager>> install
- save_cache:
key: <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
paths:
- "<<parameters.path>>/node_modules/"
install-truffle-dependencies:
steps:
- run:
name: Store current Truffle commit ID in a variable
command: |
cd truffle/
echo "export _TRUFFLE_COMMIT_ID=$(git rev-parse --verify HEAD)" >> $BASH_ENV
- restore_cache:
key: truffle-dependency-cache-{{ checksum "truffle/yarn.lock" }}-{{ .Environment._TRUFFLE_COMMIT_ID }}
- run:
name: yarn install in truffle
command: |
cd truffle/
[[ -e node_modules/ ]] || yarn install
- save_cache:
key: truffle-dependency-cache-{{ checksum "truffle/yarn.lock" }}-{{ .Environment._TRUFFLE_COMMIT_ID }}
paths:
- truffle/
inject-solc-js-tarball:
description: "Recursively finds and replaces all instances of solc-js module installed in node_modules/ with the one from a tarball."
parameters:
path:
type: string
default: .
tarball-path:
type: string
default: solc-js.tgz
package-manager:
type: enum
enum: ["npm", "yarn"]
default: npm
steps:
- run:
name: "Sanity check: tarball exists and the target dir contains a JS project"
command: |
[[ -f "<<parameters.tarball-path>>" ]]
[[ -f "<<parameters.path>>/package.json" ]]
- run:
name: Inject solc-js from the tarball into dependencies at <<parameters.path>>
command: |
absolute_tarball_path=$(realpath "<<parameters.tarball-path>>")
cd "<<parameters.path>>"
mv package.json original-package.json
# NOTE: The 'overrides' feature requires npm >= 8.3. Yarn requires `resolutions` instead.
jq ". + {overrides: {solc: \"${absolute_tarball_path}\"}} + {resolutions: {solc: \"${absolute_tarball_path}\"}}" original-package.json > package.json
"<<parameters.package-manager>>" install
- run:
name: "Sanity check: all transitive dependencies successfully replaced with the tarball"
command: |
solc_version=$(jq --raw-output .version solc-js/package.json)
cd "<<parameters.path>>"
if "<<parameters.package-manager>>" list --pattern solc | grep 'solc@' | grep -v "solc@${solc_version}"; then
echo "Another version of solc-js is still present in the dependency tree."
exit 1
fi
provision-and-package-solcjs:
description: "Creates a package out of latest solc-js to test its installation as a dependency."
steps:
- checkout:
path: solc-js/
- install-dependencies:
cache-id: solc-js
path: solc-js
- run:
name: Package solc-js
command: |
cd solc-js/
npm run build:tarball
mv "$(npm run --silent tarballName)" ../solc-js.tgz
provision-hardhat-with-packaged-solcjs:
description: "Clones Hardhat repository and configures it to use a local clone of solc-js."
steps:
- run: git clone --depth 1 "https://github.com/nomiclabs/hardhat" hardhat/
- install-dependencies:
cache-id: hardhat
path: hardhat
package-manager: yarn
dependency-file: yarn.lock
- inject-solc-js-tarball:
path: hardhat/
package-manager: yarn
provision-truffle-with-packaged-solcjs:
description: "Clones Truffle repository and configures it to use a local clone of solc-js."
steps:
- run: git clone --depth 1 "https://github.com/trufflesuite/truffle" truffle/
- install-truffle-dependencies
- inject-solc-js-tarball:
path: truffle/
package-manager: yarn
jobs:
node-base: &node-base
working_directory: ~/solc-js
docker:
- image: cimg/node:current
parameters:
run_coveralls:
type: boolean
default: false
steps:
# We want the default npm here. Older one might not work with older node.js
- show-npm-version
- checkout
- install-dependencies:
cache-id: solc-js
- run:
name: install-npm
command: npm install
- run:
name: updateBinary
command: npm run updateBinary
- run:
name: test
command: npm run test
- when:
condition: <<parameters.run_coveralls>>
steps:
- run:
name: coveralls
command: npm run coveralls
check-coding-style:
docker:
- image: cimg/node:current
steps:
- show-npm-version
- checkout
- shellcheck/install
- install-dependencies:
cache-id: solc-js
- run:
name: Check for javascript/typescript coding style
command: npm run lint
- shellcheck/check:
ignore-dirs: |
./.git
./node_modules
./dist
hardhat-core-default-solc:
# Runs out of memory on 'medium'.
resource_class: medium+
docker:
- image: cimg/node:16.15
steps:
- show-npm-version
- provision-and-package-solcjs
- provision-hardhat-with-packaged-solcjs
- run:
name: Restore the default solc binary expected by Hardhat
command: |
# Hardhat downloader tests are hard-coded to expect the version that comes with the solc-js.
# We forced latest solc-js but we still want the default binary with it.
hardhat_default_solc_version=$(jq --raw-output '.dependencies.solc' hardhat/packages/hardhat-core/package.json)
mkdir hardhat-default-solc/
pushd hardhat-default-solc/
npm install "solc@${hardhat_default_solc_version}"
popd
ln -sf ../../../hardhat-default-solc/node_modules/solc/soljson.js hardhat/node_modules/solc/soljson.js
- run:
name: Run hardhat-core test suite with its default solc binary
command: |
cd hardhat/packages/hardhat-core
# TODO: yarn build should not be needed to run these tests. Remove it.
# See https://github.com/NomicFoundation/hardhat/issues/2486 for details.
yarn build
yarn test
hardhat-core-latest-solc:
docker:
- image: cimg/node:16.15
steps:
- show-npm-version
- provision-and-package-solcjs
- provision-hardhat-with-packaged-solcjs
- run:
name: Run hardhat-core test suite with latest solc
command: |
HARDHAT_TESTS_SOLC_PATH="${PWD}/solc-js/soljson.js"
HARDHAT_TESTS_SOLC_VERSION=$(jq --raw-output .version solc-js/package.json)
export HARDHAT_TESTS_SOLC_PATH HARDHAT_TESTS_SOLC_VERSION
cd hardhat/packages/hardhat-core
yarn test
hardhat-sample-project:
docker:
- image: cimg/node:16.15
steps:
- show-npm-version
- provision-and-package-solcjs
- run: git clone --depth 1 "https://github.com/nomiclabs/hardhat-hackathon-boilerplate" boilerplate/
- run:
# Leaving package-lock.json causes a weird error in arborist when npm is used again after
# `npm install`: 'The "from" argument must be of type string. Received undefined'
name: Neutralize package-lock.json
command: rm boilerplate/package-lock.json
- install-dependencies:
cache-id: hardhat-hackathon-boilerplate
path: boilerplate
- run:
name: Update to the latest Hardhat release
command: |
# We can just use a release here because injection does not require rebuilding it.
cd boilerplate/
npm update hardhat
- inject-solc-js-tarball:
path: boilerplate/
- run:
name: Configure the boilerplate project to force Hardhat not to use a native binary
command: |
solc_version=$(jq --raw-output .version solc-js/package.json)
cd boilerplate/
sed -i 's|pragma solidity [^;]\+;|pragma solidity *;|g' contracts/Token.sol
{
echo "const {TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD} = require('hardhat/builtin-tasks/task-names');"
echo "const assert = require('assert');"
echo
echo "subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, async (args, hre, runSuper) => {"
echo " assert(args.solcVersion == '${solc_version}', 'Unexpected solc version: ' + args.solcVersion);"
echo " return {"
echo " compilerPath: '$(realpath "../solc-js/soljson.js")',"
echo " isSolcJs: true,"
echo " version: args.solcVersion,"
echo " longVersion: args.solcVersion"
echo " };"
echo "})"
echo "module.exports = {solidity: '${solc_version}'};"
} >> hardhat.config.js
- run:
name: Build and test the boilerplate project with local Hardhat
command: |
cd boilerplate/
npm run test
truffle-sample-project:
docker:
- image: cimg/node:16.15
steps:
- update-npm
- show-npm-version
- provision-and-package-solcjs
- run: sudo apt update
- run: sudo apt install python3 python-is-python3 --assume-yes --no-install-recommends
- provision-truffle-with-packaged-solcjs
- run:
name: Unbox MetaCoin
command: |
mkdir metacoin/
cd metacoin/
node ../truffle/node_modules/.bin/truffle unbox metacoin
- run:
name: Strip version pragmas
command: sed -i 's|pragma solidity [^;]\+;|pragma solidity *;|g' $(find metacoin/{contracts,test}/ -name "*.sol")
- run:
name: Build and test the sample project with local Truffle and its default solc
command: |
cd metacoin/
node ../truffle/node_modules/.bin/truffle test
- run:
name: Build and test the sample project with local Truffle and latest solc
command: |
cd metacoin/
# `truffle test` compiles the project but artifacts go into /tmp/
! [[ -e build/ ]]
echo "module.exports['compilers'] = {solc: {version: '$(realpath ../truffle/node_modules/solc/)'}}" >> truffle-config.js
node ../truffle/node_modules/.bin/truffle test
cli-smoke-test:
docker:
- image: cimg/node:current
steps:
- show-npm-version
- provision-and-package-solcjs
- run:
name: "CLI smoke test (repository)"
command: |
cd solc-js
dist/solc.js --version
echo "contract C {}" > C.sol
dist/solc.js C.sol --bin
[[ -f C_sol_C.bin ]]
- run:
name: "CLI smoke test (package)"
command: |
mkdir package/
cd package/
npm install ../solc-js.tgz
npx solcjs --version
echo "contract C {}" > C.sol
npx solcjs C.sol --bin
[[ -f C_sol_C.bin ]]
solidity-solcjs-ext-test:
docker:
- image: circleci/node
steps:
- show-npm-version
- checkout:
path: solc-js/
- run: git clone --depth 1 "https://github.com/ethereum/solidity" solidity/
- run: cd solidity/ && curl "https://binaries.soliditylang.org/bin/soljson-nightly.js" --location --output soljson.js
- run: cd solidity/ && test/externalTests/solc-js/solc-js.sh "$(realpath soljson.js)" "$(scripts/get_version.sh)" "$(realpath ../solc-js/)"
node-v10:
<<: *node-base
docker:
- image: cimg/node:10.24
node-v12:
<<: *node-base
docker:
- image: cimg/node:12.22
node-v14:
<<: *node-base
docker:
- image: cimg/node:14.19
node-v16:
<<: *node-base
docker:
- image: cimg/node:16.15
node-v18:
<<: *node-base
docker:
- image: cimg/node:18.3