@@ -8,8 +8,136 @@ workflows:
8
8
- node-v16 :
9
9
run_coveralls : true
10
10
- node-v17
11
+ - hardhat-core-default-solc
12
+ - hardhat-core-latest-solc
13
+ - hardhat-sample-project
14
+ - truffle-sample-project
11
15
12
16
version : 2.1
17
+
18
+ commands :
19
+ show-npm-version :
20
+ steps :
21
+ - run :
22
+ name : Versions
23
+ command : npm version
24
+
25
+ install-dependencies :
26
+ parameters :
27
+ cache-id :
28
+ type : string
29
+ path :
30
+ type : string
31
+ default : .
32
+ package-manager :
33
+ type : string
34
+ default : npm
35
+ dependency-file :
36
+ type : string
37
+ default : package.json
38
+ steps :
39
+ - restore_cache :
40
+ key : <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
41
+ - run :
42
+ name : " <<parameters.package-manager>> install in <<parameters.path>>"
43
+ command : |
44
+ cd "<<parameters.path>>"
45
+ [[ -e node_modules/ ]] || <<parameters.package-manager>> install
46
+ - save_cache :
47
+ key : <<parameters.cache-id>>-dependency-cache-v2-{{ .Environment.CIRCLE_JOB }}-{{ checksum "<<parameters.path>>/<<parameters.dependency-file>>" }}
48
+ paths :
49
+ - " <<parameters.path>>/node_modules/"
50
+
51
+ install-truffle-dependencies :
52
+ steps :
53
+ - run :
54
+ name : Store current Truffle commit ID in a variable
55
+ command : |
56
+ cd truffle/
57
+ echo "export _TRUFFLE_COMMIT_ID=$(git rev-parse --verify HEAD)" >> $BASH_ENV
58
+ - restore_cache :
59
+ key : truffle-dependency-cache-{{ checksum "truffle/yarn.lock" }}-{{ .Environment._TRUFFLE_COMMIT_ID }}
60
+ - run :
61
+ name : yarn install in truffle
62
+ command : |
63
+ cd truffle/
64
+ [[ -e node_modules/ ]] || yarn install
65
+ - save_cache :
66
+ key : truffle-dependency-cache-{{ checksum "truffle/yarn.lock" }}-{{ .Environment._TRUFFLE_COMMIT_ID }}
67
+ paths :
68
+ - truffle/
69
+
70
+ inject-solc-js-tarball :
71
+ description : " Recursively finds and replaces all instances of solc-js module installed in node_modules/ with the one from a tarball."
72
+ parameters :
73
+ path :
74
+ type : string
75
+ default : .
76
+ tarball-path :
77
+ type : string
78
+ default : solc-js.tgz
79
+ install-command :
80
+ type : string
81
+ default : npm install
82
+ steps :
83
+ - run :
84
+ name : Inject solc-js from the tarball into dependencies at <<parameters.path>>
85
+ command : |
86
+ [[ -f "<<parameters.tarball-path>>" ]]
87
+ 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
93
+
94
+ provision-and-package-solcjs :
95
+ description : " Creates a package out of latest solc-js to test its installation as a dependency."
96
+ steps :
97
+ - checkout :
98
+ path : solc-js/
99
+ - install-dependencies :
100
+ cache-id : solc-js
101
+ path : solc-js
102
+ - run :
103
+ name : Package solc-js
104
+ command : |
105
+ cd solc-js/
106
+ npm run build:tarball
107
+ mv "$(npm run --silent tarballName)" ../solc-js.tgz
108
+
109
+ provision-hardhat-with-packaged-solcjs :
110
+ description : " Clones Hardhat repository and configures it to use a local clone of solc-js."
111
+ steps :
112
+ - run : git clone --depth 1 "https://github.com/nomiclabs/hardhat" hardhat/
113
+ - install-dependencies :
114
+ cache-id : hardhat
115
+ path : hardhat
116
+ package-manager : yarn
117
+ dependency-file : yarn.lock
118
+ - inject-solc-js-tarball :
119
+ path : hardhat/
120
+ install-command : yarn add
121
+
122
+ provision-truffle-with-packaged-solcjs :
123
+ description : " Clones Truffle repository and configures it to use a local clone of solc-js."
124
+ steps :
125
+ - run : git clone --depth 1 "https://github.com/trufflesuite/truffle" truffle/
126
+ - install-truffle-dependencies
127
+ - 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
140
+
13
141
jobs :
14
142
node-base : &node-base
15
143
working_directory : ~/solc-js
@@ -20,12 +148,10 @@ jobs:
20
148
type : boolean
21
149
default : false
22
150
steps :
23
- - run :
24
- name : Versions
25
- command : npm version
151
+ - show-npm-version
26
152
- checkout
27
- - restore_cache :
28
- key : dependency- cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}
153
+ - install-dependencies :
154
+ cache-id : solc-js
29
155
- run :
30
156
name : install-npm
31
157
command : npm install
@@ -41,10 +167,119 @@ jobs:
41
167
- run :
42
168
name : coveralls
43
169
command : npm run coveralls
44
- - save_cache :
45
- key : dependency-cache-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package.json" }}
46
- paths :
47
- - ./node_modules
170
+
171
+ hardhat-core-default-solc :
172
+ docker :
173
+ - image : circleci/node:16
174
+ steps :
175
+ - show-npm-version
176
+ - provision-and-package-solcjs
177
+ - provision-hardhat-with-packaged-solcjs
178
+ - run :
179
+ name : Run hardhat-core test suite with its default solc
180
+ command : |
181
+ cd hardhat/packages/hardhat-core
182
+ yarn test
183
+
184
+ hardhat-core-latest-solc :
185
+ docker :
186
+ - image : circleci/node:16
187
+ steps :
188
+ - show-npm-version
189
+ - provision-and-package-solcjs
190
+ - provision-hardhat-with-packaged-solcjs
191
+ - run :
192
+ name : Run hardhat-core test suite with latest solc
193
+ command : |
194
+ HARDHAT_TESTS_SOLC_PATH="${PWD}/solc-js/soljson.js"
195
+ HARDHAT_TESTS_SOLC_VERSION=$(jq --raw-output .version solc-js/package.json)
196
+ export HARDHAT_TESTS_SOLC_PATH HARDHAT_TESTS_SOLC_VERSION
197
+
198
+ cd hardhat/packages/hardhat-core
199
+ yarn test
200
+
201
+ hardhat-sample-project :
202
+ docker :
203
+ - image : circleci/node:16
204
+ steps :
205
+ - show-npm-version
206
+ - provision-and-package-solcjs
207
+ - run : git clone --depth 1 "https://github.com/nomiclabs/hardhat-hackathon-boilerplate" boilerplate/
208
+ - run :
209
+ # Leaving package-lock.json causes a weird error in arborist when npm is used again after
210
+ # `npm install`: 'The "from" argument must be of type string. Received undefined'
211
+ name : Neutralize package-lock.json
212
+ command : rm boilerplate/package-lock.json
213
+ - install-dependencies :
214
+ cache-id : hardhat-hackathon-boilerplate
215
+ path : boilerplate
216
+ - run :
217
+ name : Update to the latest Hardhat release
218
+ command : |
219
+ # We can just use a release here because injection does not require rebuilding it.
220
+ cd boilerplate/
221
+ npm update hardhat
222
+ - inject-solc-js-tarball :
223
+ path : boilerplate/
224
+ - run :
225
+ name : Configure the boilerplate project to force Hardhat not to use a native binary
226
+ command : |
227
+ solc_version=$(jq --raw-output .version solc-js/package.json)
228
+
229
+ cd boilerplate/
230
+
231
+ sed -i 's|pragma solidity [^;]\+;|pragma solidity *;|g' contracts/Token.sol
232
+
233
+ {
234
+ echo "const {TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD} = require('hardhat/builtin-tasks/task-names');"
235
+ echo "const assert = require('assert');"
236
+ echo
237
+ echo "subtask(TASK_COMPILE_SOLIDITY_GET_SOLC_BUILD, async (args, hre, runSuper) => {"
238
+ echo " assert(args.solcVersion == '${solc_version}', 'Unexpected solc version: ' + args.solcVersion);"
239
+ echo " return {"
240
+ echo " compilerPath: '$(realpath "../solc-js/soljson.js")',"
241
+ echo " isSolcJs: true,"
242
+ echo " version: args.solcVersion,"
243
+ echo " longVersion: args.solcVersion"
244
+ echo " };"
245
+ echo "})"
246
+ echo "module.exports = {solidity: '${solc_version}'};"
247
+ } >> hardhat.config.js
248
+ - run :
249
+ name : Build and test the boilerplate project with local Hardhat
250
+ command : |
251
+ cd boilerplate/
252
+ npm run test
253
+
254
+ truffle-sample-project :
255
+ docker :
256
+ - image : circleci/node:12
257
+ steps :
258
+ - show-npm-version
259
+ - provision-and-package-solcjs
260
+ - provision-truffle-with-packaged-solcjs
261
+ - run :
262
+ name : Unbox MetaCoin
263
+ command : |
264
+ mkdir metacoin/
265
+ cd metacoin/
266
+ node ../truffle/node_modules/.bin/truffle unbox metacoin
267
+ - run :
268
+ name : Strip version pragmas
269
+ command : sed -i 's|pragma solidity [^;]\+;|pragma solidity *;|g' $(find metacoin/{contracts,test}/ -name "*.sol")
270
+ - run :
271
+ name : Build and test the sample project with local Truffle and its default solc
272
+ command : |
273
+ cd metacoin/
274
+ node ../truffle/node_modules/.bin/truffle test
275
+ - run :
276
+ name : Build and test the sample project with local Truffle and latest solc
277
+ command : |
278
+ cd metacoin/
279
+ # `truffle test` compiles the project but artifacts go into /tmp/
280
+ ! [[ -e build/ ]] || false
281
+ echo "module.exports['compilers'] = {solc: {version: '$(realpath node_modules/solc/)'}}" > truffle-config.js
282
+ node ../truffle/node_modules/.bin/truffle test
48
283
49
284
node-v10 :
50
285
<< : *node-base
0 commit comments