@@ -83,20 +83,34 @@ commands:
83
83
tarball-path :
84
84
type : string
85
85
default : solc-js.tgz
86
- install-command :
87
- type : string
88
- default : npm install
86
+ package-manager :
87
+ type : enum
88
+ enum : ["npm", "yarn"]
89
+ default : npm
89
90
steps :
90
91
- run :
91
- name : Inject solc-js from the tarball into dependencies at <<parameters.path>>
92
+ name : " Sanity check: tarball exists and the target dir contains a JS project "
92
93
command : |
93
94
[[ -f "<<parameters.tarball-path>>" ]]
95
+ [[ -f "<<parameters.path>>/package.json" ]]
96
+ - run :
97
+ name : Inject solc-js from the tarball into dependencies at <<parameters.path>>
98
+ command : |
94
99
absolute_tarball_path=$(realpath "<<parameters.tarball-path>>")
95
- for solc_module in $(find "<<parameters.path>>" -type d -path "*/node_modules/solc"); do
96
- pushd "${solc_module}/../.."
97
- <<parameters.install-command>> "$absolute_tarball_path" --ignore-workspace-root-check
98
- popd
99
- done
100
+ cd "<<parameters.path>>"
101
+ mv package.json original-package.json
102
+ # NOTE: The 'overrides' feature requires npm >= 8.3. Yarn requires `resolutions` instead.
103
+ jq ". + {overrides: {solc: \"${absolute_tarball_path}\"}} + {resolutions: {solc: \"${absolute_tarball_path}\"}}" original-package.json > package.json
104
+ "<<parameters.package-manager>>" install
105
+ - run :
106
+ name : " Sanity check: all transitive dependencies successfully replaced with the tarball"
107
+ command : |
108
+ solc_version=$(jq --raw-output .version solc-js/package.json)
109
+ cd "<<parameters.path>>"
110
+ if "<<parameters.package-manager>>" list --pattern solc | grep 'solc@' | grep -v "solc@${solc_version}"; then
111
+ echo "Another version of solc-js is still present in the dependency tree."
112
+ exit 1
113
+ fi
100
114
101
115
provision-and-package-solcjs :
102
116
description : " Creates a package out of latest solc-js to test its installation as a dependency."
@@ -124,26 +138,16 @@ commands:
124
138
dependency-file : yarn.lock
125
139
- inject-solc-js-tarball :
126
140
path : hardhat/
127
- install-command : yarn add
141
+ package-manager : yarn
128
142
129
143
provision-truffle-with-packaged-solcjs :
130
144
description : " Clones Truffle repository and configures it to use a local clone of solc-js."
131
145
steps :
132
146
- run : git clone --depth 1 "https://github.com/trufflesuite/truffle" truffle/
133
147
- install-truffle-dependencies
134
148
- inject-solc-js-tarball :
135
- path : truffle/node_modules/
136
- install-command : yarn add
137
- - run :
138
- name : Neutralize any copies of solc-js outside of node_modules/
139
- command : |
140
- # NOTE: Injecting solc-js into node_modules/ dirs located under truffle/packages/ causes
141
- # an error 'Tarball is not in network and can not be located in cache'. These are not
142
- # supposed to be used but let's remove them just in case.
143
- find truffle/ \
144
- -path "*/solc/wrapper.js" \
145
- -not -path "truffle/node_modules/*" \
146
- -printf "%h\n" | xargs --verbose rm -r
149
+ path : truffle/
150
+ package-manager : yarn
147
151
148
152
jobs :
149
153
node-base : &node-base
@@ -185,7 +189,18 @@ jobs:
185
189
- provision-and-package-solcjs
186
190
- provision-hardhat-with-packaged-solcjs
187
191
- run :
188
- name : Run hardhat-core test suite with its default solc
192
+ name : Restore the default solc binary expected by Hardhat
193
+ command : |
194
+ # Hardhat downloader tests are hard-coded to expect the version that comes with the solc-js.
195
+ # We forced latest solc-js but we still want the default binary with it.
196
+ hardhat_default_solc_version=$(jq --raw-output '.dependencies.solc' hardhat/packages/hardhat-core/package.json)
197
+ mkdir hardhat-default-solc/
198
+ pushd hardhat-default-solc/
199
+ npm install "solc@${hardhat_default_solc_version}"
200
+ popd
201
+ ln -sf ../../../hardhat-default-solc/node_modules/solc/soljson.js hardhat/node_modules/solc/soljson.js
202
+ - run :
203
+ name : Run hardhat-core test suite with its default solc binary
189
204
command : |
190
205
cd hardhat/packages/hardhat-core
191
206
# TODO: yarn build should not be needed to run these tests. Remove it.
0 commit comments