diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5a712f8eda..a8fe6da33a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,7 @@ jobs: "e2e_ganache", "e2e_mosaic", "e2e_browsers", + "e2e_gnosis_dex" ] env: TEST: ${{ matrix.testCmd }} diff --git a/package.json b/package.json index 94bc27e4da7..e83fd5e9ff9 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "test:e2e:truffle": "./scripts/e2e.truffle.sh", "test:e2e:mosaic": "./scripts/e2e.mosaic.sh", "test:e2e:ganache:core": "./scripts/e2e.ganache.core.sh", + "test:e2e:gnosis:dex": "./scripts/e2e.gnosis.dex.sh", "ci": "./scripts/ci.sh", "cov:clean": "rm -rf .nyc_output; rm -rf coverage", "cov:merge_reports": "nyc report --reporter=lcov --reporter=html" diff --git a/scripts/ci.sh b/scripts/ci.sh index aa1b905fe02..1ebfaf1a6ab 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -24,7 +24,7 @@ elif [ "$TEST" = "unit_and_e2e_clients" ]; then npm run test:e2e:geth:insta npm run test:e2e:geth:auto npm run test:unit - npm run cov:merge_reports + npm run cov:merge_reports elif [ "$TEST" = "e2e_browsers" ]; then @@ -54,4 +54,9 @@ elif [ "$TEST" = "e2e_ganache" ]; then npm run test:e2e:publish npm run test:e2e:ganache:core +elif [ "$TEST" = "e2e_gnosis_dex" ]; then + + npm run test:e2e:publish + npm run test:e2e:gnosis:dex + fi diff --git a/scripts/e2e.gnosis.dex.sh b/scripts/e2e.gnosis.dex.sh new file mode 100755 index 00000000000..3cb581d0419 --- /dev/null +++ b/scripts/e2e.gnosis.dex.sh @@ -0,0 +1,57 @@ +# ------------------------------------------------------------------------------------------- +# Run gnosis/dex-react using a candidate branch of web3 which has been published to a +# proxy npm registry in `e2e.npm.publish.sh` +# +# The test's purpose is to verify web3 latest state runs successfully on an actively +# developed production project which uses. +# + react +# + webpack production build +# + typescript compilation +# + ~200 jest tests +# -------------------------------------------------------------------------------------------- + +# Exit immediately on error +set -o errexit + +# To mimic `npm install web3` correctly, this test does not install Web3's dev deps. +# However, we need the npm package `semver` to coerce yarn resolutions correctly. +# It must be installed as a dev dep or Node complains. We also need web3's package.json +# to resolve the current version + patch increment. So some file renaming is necessary here... +cp package.json original.package.json +rm package.json +rm package-lock.json +npm init --yes +npm install --save-dev semver + +# Install mosaic and set yarn resolutions to virtually published patch version +git clone https://github.com/gnosis/dex-react.git +scripts/js/resolutions.js dex-react +cd dex-react + +# Install via registry and verify +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +echo "Installing updated web3 via virtual registry " +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + +yarn --registry http://localhost:4873 + +yarn list web3 +yarn list web3-utils +yarn list web3-core +yarn list web3-core-promievent + +cat ./package.json + +# Build +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +echo "Running gnosis/dex-react: build " +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + +npm run build + +# Test +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +echo "Running gnosis/dex-react: test " +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + +npm test diff --git a/scripts/e2e.truffle.sh b/scripts/e2e.truffle.sh deleted file mode 100755 index 1fd5640416c..00000000000 --- a/scripts/e2e.truffle.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -# -------------------------------------------------------------------------------- -# NB: This script temporarily removed from CI while truffle remains on Web3@1.2.1. -# To re-enable, add a `e2e_truffle` job to the matrix in `.github/workflows/test.yml`. -# -------------------------------------------------------------------------------- - -# ------------------------------------------------------------------------- -# Run @truffle/contract's unit tests using a candidate branch of web3 -# which has been published to a proxy npm registry in `e2e.npm.publish.sh` -# ------------------------------------------------------------------------- - -# Exit immediately on error -set -o errexit - -# Install test specific dependencies -npm install -g geth-dev-assistant@0.1.3 - -# Launch geth -npm run geth - -# Install truffle -git clone https://github.com/trufflesuite/truffle.git -cd truffle -yarn bootstrap - -yarn config set registry http://localhost:4873 - -echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" -echo "Updating Web3 across all @truffle " -echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" - -lerna add web3@e2e --registry http://localhost:4873 - -echo ">>>>>>>>>>>>>>>>>>>>>>>>>>" -echo "Updating @truffle/contract" -echo ">>>>>>>>>>>>>>>>>>>>>>>>>>" - -cd packages/contract - -yarn remove web3-core-promievent -yarn remove web3-eth-abi -yarn remove web3-utils - -# Geth tests -GETH=true npm test diff --git a/scripts/js/resolutions.js b/scripts/js/resolutions.js index dc602acff5e..9690556fd55 100755 --- a/scripts/js/resolutions.js +++ b/scripts/js/resolutions.js @@ -28,28 +28,51 @@ const targetPackage = require(targetPackagePath); // in e2e.npm.publish.sh) const version = semver.inc(web3Package.version, 'minor'); -targetPackage.resolutions = { - "@nomiclabs/**/web3": `${version}`, - "@nomiclabs/**/web3-bzz": `${version}`, - "@nomiclabs/**/web3-core-helpers": `${version}`, - "@nomiclabs/**/web3-core-method": `${version}`, - "@nomiclabs/**/web3-core-promievent": `${version}`, - "@nomiclabs/**/web3-core-requestmanager": `${version}`, - "@nomiclabs/**/web3-core-subscriptions": `${version}`, - "@nomiclabs/**/web3-core": `${version}`, - "@nomiclabs/**/web3-eth-abi": `${version}`, - "@nomiclabs/**/web3-eth-accounts": `${version}`, - "@nomiclabs/**/web3-eth-contract": `${version}`, - "@nomiclabs/**/web3-eth-ens": `${version}`, - "@nomiclabs/**/web3-eth-iban": `${version}`, - "@nomiclabs/**/web3-eth-personal": `${version}`, - "@nomiclabs/**/web3-eth": `${version}`, - "@nomiclabs/**/web3-net": `${version}`, - "@nomiclabs/**/web3-providers-http": `${version}`, - "@nomiclabs/**/web3-providers-ipc": `${version}`, - "@nomiclabs/**/web3-providers-ws": `${version}`, - "@nomiclabs/**/web3-shh": `${version}`, - "@nomiclabs/**/web3-utils": `${version}` +const web3Modules = [ + "web3", + "web3-bzz", + "web3-core-helpers", + "web3-core-method", + "web3-core-promievent", + "web3-core-requestmanager", + "web3-core-subscriptions", + "web3-core", + "web3-eth-abi", + "web3-eth-accounts", + "web3-eth-contract", + "web3-eth-ens", + "web3-eth-iban", + "web3-eth-personal", + "web3-eth", + "web3-net", + "web3-providers-http", + "web3-providers-ipc", + "web3-providers-ws", + "web3-shh", + "web3-utils" +]; + + +targetPackage.resolutions = {}; + +// Coerce every version of web3 in the sub-dependency tree to +// the virtually published version +for ( const mod of web3Modules ){ + targetPackage.resolutions[`*/**/${mod}`] = version; +} + +// Remove any outer-level web3 modules so yarn flat-packs a single +// set of web3 modules at the outerlevel +if (targetPackage.devDependencies){ + for ( const mod of web3Modules ){ + delete targetPackage.devDependencies[mod]; + } +} + +if (targetPackage.dependencies){ + for ( const mod of web3Modules ){ + delete targetPackage.dependencies[mod]; + } } console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");