Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ workflows:
build:
jobs:
- unit-test
# TODO: re-enable
#- e2e-zeppelin
#- e2e-metacoin
- e2e-zeppelin
- e2e-metacoin
# TODO: re-enable.
# At the moment we're using forks so this is pointless
#nightly:
# triggers:
# - schedule:
Expand All @@ -86,6 +87,5 @@ workflows:
# only:
# - master
# jobs:
# TODO: re-enable
#- e2e-zeppelin
#- e2e-colony
38 changes: 31 additions & 7 deletions dist/truffle.plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const dir = require('node-dir');
const Web3 = require('web3');
const util = require('util');
const globby = require('globby');
const globalModules = require('global-modules');

async function plugin(truffleConfig){
let app;
Expand All @@ -58,7 +59,7 @@ async function plugin(truffleConfig){
return app.ui.report('truffle-help')
}

truffle = loadTruffleLibrary();
truffle = loadTruffleLibrary(app);

} catch (err) {
throw err;
Expand Down Expand Up @@ -147,13 +148,36 @@ function tests(truffle){
}


function loadTruffleLibrary(){
try { return require("truffle") } catch(err) {};
try { return require("./truffle.library")} catch(err) {};
function loadTruffleLibrary(app){

// 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.
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ class App {
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);
}

if (shell.test('-e', path.join(this.cwd, this.artifactsDir))){
if (shell.test('-e', this.artifactsDir)){
shell.rm('-Rf', this.artifactsDir);
}
}
Expand Down
15 changes: 14 additions & 1 deletion lib/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ class UI {
`${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`,

'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` +
`Options:\n` +
` --file: path (or glob) to run subset of JS test files\n` +
Expand Down Expand Up @@ -53,8 +60,14 @@ class UI {
* @param {String[]} args info to inject into template
* @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])
}
}

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"chalk": "^2.4.2",
"death": "^1.1.0",
"ganache-core-sc": "2.7.0-sc.0",
"global-modules": "^2.0.0",
"globby": "^10.0.1",
"istanbul": "^0.4.5",
"node-dir": "^0.1.17",
Expand Down
14 changes: 11 additions & 3 deletions scripts/run-metacoin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# E2E CI: installs PR candidate on Truffle's MetaCoin and runs coverage
#

set -o errexit

# Get rid of any caches
sudo rm -rf node_modules
echo "NVM CURRENT >>>>>" && nvm current
Expand All @@ -23,9 +25,15 @@ npm install -g truffle
mkdir metacoin
cd metacoin
truffle unbox metacoin --force
rm test/TestMetacoin.sol
npm init --yes
rm truffle-config.js
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
npm init --yes
npm install --save-dev $PR_PATH
npx solidity-coverage
npx truffle run coverage
21 changes: 11 additions & 10 deletions scripts/run-zeppelin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# E2E CI: installs PR candidate on openzeppelin-solidity and runs coverage
#

set -o errexit

# Get rid of any caches
sudo rm -rf node_modules
echo "NVM CURRENT >>>>>" && nvm current
Expand All @@ -18,16 +20,14 @@ fi

echo "PR_PATH >>>>> $PR_PATH"

# Install Zeppelin
git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git
cd openzeppelin-solidity
# Install sc-forks Zeppelin fork (temporarily). It's setup to
# consume the plugin and skips a small set of GSN tests that rely on
# 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
sed -i 's/if/# /g' scripts/coverage.sh
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
echo ">>>>> checkout provider-benchmarks branch"
git checkout provider-benchmarks

# Swap installed coverage for PR branch version
echo ">>>>> npm install"
Expand All @@ -39,4 +39,5 @@ npm uninstall --save-dev solidity-coverage
echo ">>>>> npm install --save-dev PR_PATH"
npm install --save-dev "$PR_PATH"

npm run coverage
# Track perf
time npx truffle run coverage
17 changes: 16 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3852,6 +3852,13 @@ global-modules@^1.0.0:
is-windows "^1.0.1"
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:
version "1.0.2"
resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe"
Expand All @@ -3863,6 +3870,15 @@ global-prefix@^1.0.1:
is-windows "^1.0.1"
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:
version "4.3.2"
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
Expand Down Expand Up @@ -9520,7 +9536,6 @@ [email protected], "websocket@github:web3-js/WebSocket-Node#polyfill/globalThis":
dependencies:
debug "^2.2.0"
es5-ext "^0.10.50"
gulp "^4.0.2"
nan "^2.14.0"
typedarray-to-buffer "^3.1.5"
yaeti "^0.0.6"
Expand Down