Re-enable e2e zeppelin & metacoin (#396)

* Handle truffle.library require cases

* Fix sanity-check paths
truffle-plugin
cgewecke 5 years ago
parent e75a631445
commit df1c7b307b
  1. 8
      .circleci/config.yml
  2. 38
      dist/truffle.plugin.js
  3. 4
      lib/app.js
  4. 15
      lib/ui.js
  5. 1
      package.json
  6. 14
      scripts/run-metacoin.sh
  7. 21
      scripts/run-zeppelin.sh
  8. 17
      yarn.lock

@ -74,9 +74,10 @@ workflows:
build: build:
jobs: jobs:
- unit-test - unit-test
# TODO: re-enable - e2e-zeppelin
#- e2e-zeppelin - e2e-metacoin
#- e2e-metacoin # TODO: re-enable.
# At the moment we're using forks so this is pointless
#nightly: #nightly:
# triggers: # triggers:
# - schedule: # - schedule:
@ -86,6 +87,5 @@ workflows:
# only: # only:
# - master # - master
# jobs: # jobs:
# TODO: re-enable
#- e2e-zeppelin #- e2e-zeppelin
#- e2e-colony #- e2e-colony

@ -34,6 +34,7 @@ const dir = require('node-dir');
const Web3 = require('web3'); const Web3 = require('web3');
const util = require('util'); const util = require('util');
const globby = require('globby'); const globby = require('globby');
const globalModules = require('global-modules');
async function plugin(truffleConfig){ async function plugin(truffleConfig){
let app; let app;
@ -59,7 +60,7 @@ async function plugin(truffleConfig){
return app.ui.report('truffle-help') return app.ui.report('truffle-help')
} }
truffle = loadTruffleLibrary(); truffle = loadTruffleLibrary(app);
} catch (err) { } catch (err) {
throw err; throw err;
@ -152,13 +153,36 @@ function tests(truffle){
} }
function loadTruffleLibrary(){ function loadTruffleLibrary(app){
try { return require("truffle") } catch(err) {};
try { return require("./truffle.library")} catch(err) {}; // Case: from local node_modules
try {
const lib = require("truffle");
app.ui.report('truffle-local');
return lib;
} catch(err) {};
// Case: global
try {
const globalTruffle = path.join(globalModules, 'truffle');
const lib = require(globalTruffle);
app.ui.report('truffle-global');
return lib;
} catch(err) {};
// Default: fallback
try {
app.ui.report('truffle-warn');
return require("./truffle.library")}
catch(err) {
const msg = app.ui.generate('truffle-fail', [err]);
throw new Error(msg);
};
// TO DO: throw error? This point should never be reached.
// Validate that truffle.ganache exists? Have checked that
// a non-existent prop defaults to the ganache-core-sc fallback FWIW.
} }
/** /**

@ -261,11 +261,11 @@ class App {
this.cleanUp("Couldn't find a 'contracts' folder to instrument."); this.cleanUp("Couldn't find a 'contracts' folder to instrument.");
} }
if (shell.test('-e', path.join(this.cwd, this.contractsDir))){ if (shell.test('-e', this.contractsDir)){
shell.rm('-Rf', this.contractsDir); shell.rm('-Rf', this.contractsDir);
} }
if (shell.test('-e', path.join(this.cwd, this.artifactsDir))){ if (shell.test('-e', this.artifactsDir)){
shell.rm('-Rf', this.artifactsDir); shell.rm('-Rf', this.artifactsDir);
} }
} }

@ -26,6 +26,13 @@ class UI {
`${c.red('Check the provider option syntax in solidity-coverage docs.')}\n`+ `${c.red('Check the provider option syntax in solidity-coverage docs.')}\n`+
`:warning: ${c.red('Using ganache-core-sc (eq. core v2.7.0) instead.')}\n`, `:warning: ${c.red('Using ganache-core-sc (eq. core v2.7.0) instead.')}\n`,
'truffle-local': `\n${ct} ${c.grey('Using Truffle library from local node_modules.')}\n`,
'truffle-global': `\n${ct} ${c.grey('Using Truffle library from global node_modules.')}\n`,
'truffle-warn': `:warning: ${c.red('Unable to require Truffle library locally or globally. ')} `+
`${c.red('Expected to find installed Truffle >= v5.0.31 ...')}\n` +
`:warning: ${c.red('Using fallback Truffle library instead (v5.0.31)')}\n`,
'truffle-help': `Usage: truffle run coverage [options]\n\n` + 'truffle-help': `Usage: truffle run coverage [options]\n\n` +
`Options:\n` + `Options:\n` +
` --file: path (or glob) to subset of JS test files. (Quote your globs)\n` + ` --file: path (or glob) to subset of JS test files. (Quote your globs)\n` +
@ -55,8 +62,14 @@ class UI {
* @param {String[]} args info to inject into template * @param {String[]} args info to inject into template
* @return {String} message * @return {String} message
*/ */
generate(kind, args){ generate(kind, args=[]){
const kinds = {
'truffle-fail': `${c.red('Unable to load fail-safe Truffle library. Caught: ')} ${args[0]}\n` +
`:x: ${c.red('Try installing Truffle >= v5.0.31 locally or globally.\n')}`,
}
return emoji.emojify(kinds[kind])
} }
} }

@ -24,6 +24,7 @@
"chalk": "^2.4.2", "chalk": "^2.4.2",
"death": "^1.1.0", "death": "^1.1.0",
"ganache-core-sc": "2.7.0-sc.0", "ganache-core-sc": "2.7.0-sc.0",
"global-modules": "^2.0.0",
"globby": "^10.0.1", "globby": "^10.0.1",
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"node-dir": "^0.1.17", "node-dir": "^0.1.17",

@ -3,6 +3,8 @@
# E2E CI: installs PR candidate on Truffle's MetaCoin and runs coverage # E2E CI: installs PR candidate on Truffle's MetaCoin and runs coverage
# #
set -o errexit
# Get rid of any caches # Get rid of any caches
sudo rm -rf node_modules sudo rm -rf node_modules
echo "NVM CURRENT >>>>>" && nvm current echo "NVM CURRENT >>>>>" && nvm current
@ -23,9 +25,15 @@ npm install -g truffle
mkdir metacoin mkdir metacoin
cd metacoin cd metacoin
truffle unbox metacoin --force truffle unbox metacoin --force
rm test/TestMetacoin.sol rm truffle-config.js
npm init --yes echo "module.exports={plugins:['solidity-coverage']}" > truffle-config.js
cat truffle-config.js
# TODO: Remove this rm.
# Unknown bug running truffle native solidity tests
rm test/TestMetaCoin.sol
# Install and run solidity-coverage @ PR # Install and run solidity-coverage @ PR
npm init --yes
npm install --save-dev $PR_PATH npm install --save-dev $PR_PATH
npx solidity-coverage npx truffle run coverage

@ -3,6 +3,8 @@
# E2E CI: installs PR candidate on openzeppelin-solidity and runs coverage # E2E CI: installs PR candidate on openzeppelin-solidity and runs coverage
# #
set -o errexit
# Get rid of any caches # Get rid of any caches
sudo rm -rf node_modules sudo rm -rf node_modules
echo "NVM CURRENT >>>>>" && nvm current echo "NVM CURRENT >>>>>" && nvm current
@ -18,16 +20,14 @@ fi
echo "PR_PATH >>>>> $PR_PATH" echo "PR_PATH >>>>> $PR_PATH"
# Install Zeppelin # Install sc-forks Zeppelin fork (temporarily). It's setup to
git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git # consume the plugin and skips a small set of GSN tests that rely on
cd openzeppelin-solidity # the client being stand-alone. (See OZ issue #1918 for discussion)
git clone https://github.com/sc-forks/openzeppelin-contracts.git
cd openzeppelin-contracts
# Update Zeppelin's script to use 0.6.x echo ">>>>> checkout provider-benchmarks branch"
sed -i 's/if/# /g' scripts/coverage.sh git checkout provider-benchmarks
sed -i 's/curl/# /g' scripts/coverage.sh
sed -i 's/fi/# /g' scripts/coverage.sh
sed -i 's/ganache-cli-coverage/testrpc-sc/g' scripts/test.sh
sed -i 's/--emitFreeLogs true/ /g' scripts/test.sh
# Swap installed coverage for PR branch version # Swap installed coverage for PR branch version
echo ">>>>> npm install" echo ">>>>> npm install"
@ -39,4 +39,5 @@ npm uninstall --save-dev solidity-coverage
echo ">>>>> npm install --save-dev PR_PATH" echo ">>>>> npm install --save-dev PR_PATH"
npm install --save-dev "$PR_PATH" npm install --save-dev "$PR_PATH"
npm run coverage # Track perf
time npx truffle run coverage

@ -3852,6 +3852,13 @@ global-modules@^1.0.0:
is-windows "^1.0.1" is-windows "^1.0.1"
resolve-dir "^1.0.0" resolve-dir "^1.0.0"
global-modules@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-2.0.0.tgz#997605ad2345f27f51539bea26574421215c7780"
integrity sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A==
dependencies:
global-prefix "^3.0.0"
global-prefix@^1.0.1: global-prefix@^1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe"
@ -3863,6 +3870,15 @@ global-prefix@^1.0.1:
is-windows "^1.0.1" is-windows "^1.0.1"
which "^1.2.14" which "^1.2.14"
global-prefix@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-3.0.0.tgz#fc85f73064df69f50421f47f883fe5b913ba9b97"
integrity sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==
dependencies:
ini "^1.3.5"
kind-of "^6.0.2"
which "^1.3.1"
global@~4.3.0: global@~4.3.0:
version "4.3.2" version "4.3.2"
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f" resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
@ -9520,7 +9536,6 @@ websocket@1.0.29, "websocket@github:web3-js/WebSocket-Node#polyfill/globalThis":
dependencies: dependencies:
debug "^2.2.0" debug "^2.2.0"
es5-ext "^0.10.50" es5-ext "^0.10.50"
gulp "^4.0.2"
nan "^2.14.0" nan "^2.14.0"
typedarray-to-buffer "^3.1.5" typedarray-to-buffer "^3.1.5"
yaeti "^0.0.6" yaeti "^0.0.6"

Loading…
Cancel
Save