@@ -12,6 +12,7 @@ workflows:
12
12
- hardhat-core-latest-solc
13
13
- hardhat-sample-project
14
14
- truffle-sample-project
15
+ - cli-smoke-test
15
16
16
17
version : 2.1
17
18
@@ -22,6 +23,13 @@ commands:
22
23
name : Versions
23
24
command : npm version
24
25
26
+ update-npm :
27
+ steps :
28
+ - run :
29
+ name : Update globally available npm to the latest version
30
+ # Note: We need npm >= 8.3 which supports 'overrides' in package.json
31
+ command : sudo npm install npm --global
32
+
25
33
install-dependencies :
26
34
parameters :
27
35
cache-id :
@@ -76,20 +84,34 @@ commands:
76
84
tarball-path :
77
85
type : string
78
86
default : solc-js.tgz
79
- install-command :
80
- type : string
81
- default : npm install
87
+ package-manager :
88
+ type : enum
89
+ enum : ["npm", "yarn"]
90
+ default : npm
82
91
steps :
83
92
- run :
84
- name : Inject solc-js from the tarball into dependencies at <<parameters.path>>
93
+ name : " Sanity check: tarball exists and the target dir contains a JS project "
85
94
command : |
86
95
[[ -f "<<parameters.tarball-path>>" ]]
96
+ [[ -f "<<parameters.path>>/package.json" ]]
97
+ - run :
98
+ name : Inject solc-js from the tarball into dependencies at <<parameters.path>>
99
+ command : |
87
100
absolute_tarball_path=$(realpath "<<parameters.tarball-path>>")
88
- for solc_module in $(find "<<parameters.path>>" -type d -path "*/node_modules/solc"); do
89
- pushd "${solc_module}/../.."
90
- <<parameters.install-command>> "$absolute_tarball_path" --ignore-workspace-root-check
91
- popd
92
- done
101
+ cd "<<parameters.path>>"
102
+ mv package.json original-package.json
103
+ # NOTE: The 'overrides' feature requires npm >= 8.3. Yarn requires `resolutions` instead.
104
+ jq ". + {overrides: {solc: \"${absolute_tarball_path}\"}} + {resolutions: {solc: \"${absolute_tarball_path}\"}}" original-package.json > package.json
105
+ "<<parameters.package-manager>>" install
106
+ - run :
107
+ name : " Sanity check: all transitive dependencies successfully replaced with the tarball"
108
+ command : |
109
+ solc_version=$(jq --raw-output .version solc-js/package.json)
110
+ cd "<<parameters.path>>"
111
+ if "<<parameters.package-manager>>" list --pattern solc | grep 'solc@' | grep -v "solc@${solc_version}"; then
112
+ echo "Another version of solc-js is still present in the dependency tree."
113
+ exit 1
114
+ fi
93
115
94
116
provision-and-package-solcjs :
95
117
description : " Creates a package out of latest solc-js to test its installation as a dependency."
@@ -117,26 +139,16 @@ commands:
117
139
dependency-file : yarn.lock
118
140
- inject-solc-js-tarball :
119
141
path : hardhat/
120
- install-command : yarn add
142
+ package-manager : yarn
121
143
122
144
provision-truffle-with-packaged-solcjs :
123
145
description : " Clones Truffle repository and configures it to use a local clone of solc-js."
124
146
steps :
125
147
- run : git clone --depth 1 "https://github.com/trufflesuite/truffle" truffle/
126
148
- install-truffle-dependencies
127
149
- inject-solc-js-tarball :
128
- path : truffle/node_modules/
129
- install-command : yarn add
130
- - run :
131
- name : Neutralize any copies of solc-js outside of node_modules/
132
- command : |
133
- # NOTE: Injecting solc-js into node_modules/ dirs located under truffle/packages/ causes
134
- # an error 'Tarball is not in network and can not be located in cache'. These are not
135
- # supposed to be used but let's remove them just in case.
136
- find truffle/ \
137
- -path "*/solc/wrapper.js" \
138
- -not -path "truffle/node_modules/*" \
139
- -printf "%h\n" | xargs --verbose rm -r
150
+ path : truffle/
151
+ package-manager : yarn
140
152
141
153
jobs :
142
154
node-base : &node-base
@@ -148,6 +160,7 @@ jobs:
148
160
type : boolean
149
161
default : false
150
162
steps :
163
+ # We want the default npm here. Older one might not work with older node.js
151
164
- show-npm-version
152
165
- checkout
153
166
- install-dependencies :
@@ -172,11 +185,23 @@ jobs:
172
185
docker :
173
186
- image : circleci/node:16
174
187
steps :
188
+ - update-npm
175
189
- show-npm-version
176
190
- provision-and-package-solcjs
177
191
- provision-hardhat-with-packaged-solcjs
178
192
- run :
179
- name : Run hardhat-core test suite with its default solc
193
+ name : Restore the default solc binary expected by Hardhat
194
+ command : |
195
+ # Hardhat downloader tests are hard-coded to expect the version that comes with the solc-js.
196
+ # We forced latest solc-js but we still want the default binary with it.
197
+ hardhat_default_solc_version=$(jq --raw-output '.dependencies.solc' hardhat/packages/hardhat-core/package.json)
198
+ mkdir hardhat-default-solc/
199
+ pushd hardhat-default-solc/
200
+ npm install "solc@${hardhat_default_solc_version}"
201
+ popd
202
+ ln -sf ../../../hardhat-default-solc/node_modules/solc/soljson.js hardhat/node_modules/solc/soljson.js
203
+ - run :
204
+ name : Run hardhat-core test suite with its default solc binary
180
205
command : |
181
206
cd hardhat/packages/hardhat-core
182
207
# TODO: yarn build should not be needed to run these tests. Remove it.
@@ -188,6 +213,7 @@ jobs:
188
213
docker :
189
214
- image : circleci/node:16
190
215
steps :
216
+ - update-npm
191
217
- show-npm-version
192
218
- provision-and-package-solcjs
193
219
- provision-hardhat-with-packaged-solcjs
@@ -205,6 +231,7 @@ jobs:
205
231
docker :
206
232
- image : circleci/node:16
207
233
steps :
234
+ - update-npm
208
235
- show-npm-version
209
236
- provision-and-package-solcjs
210
237
- run : git clone --depth 1 "https://github.com/nomiclabs/hardhat-hackathon-boilerplate" boilerplate/
@@ -258,6 +285,7 @@ jobs:
258
285
docker :
259
286
- image : circleci/node:12
260
287
steps :
288
+ - update-npm
261
289
- show-npm-version
262
290
- provision-and-package-solcjs
263
291
- provision-truffle-with-packaged-solcjs
@@ -284,6 +312,35 @@ jobs:
284
312
echo "module.exports['compilers'] = {solc: {version: '$(realpath node_modules/solc/)'}}" > truffle-config.js
285
313
node ../truffle/node_modules/.bin/truffle test
286
314
315
+ cli-smoke-test :
316
+ docker :
317
+ - image : circleci/node:17
318
+ steps :
319
+ - update-npm
320
+ - show-npm-version
321
+ - provision-and-package-solcjs
322
+ - run :
323
+ name : " CLI smoke test (repository)"
324
+ command : |
325
+ cd solc-js
326
+ dist/solc.js --version
327
+
328
+ echo "contract C {}" > C.sol
329
+ dist/solc.js C.sol --bin
330
+ [[ -f C_sol_C.bin ]]
331
+ - run :
332
+ name : " CLI smoke test (package)"
333
+ command : |
334
+ mkdir package/
335
+ cd package/
336
+ npm install ../solc-js.tgz
337
+
338
+ npx solcjs --version
339
+
340
+ echo "contract C {}" > C.sol
341
+ npx solcjs C.sol --bin
342
+ [[ -f C_sol_C.bin ]]
343
+
287
344
node-v10 :
288
345
<< : *node-base
289
346
docker :
0 commit comments