Truffle config handling (#366)

* add new truffle config handling

* use ifs

* nework typo lol

* remove stray config edits

* remove truffleConfig.js, improve default config handling

* readability

* remove legacy truffle config file, don't rely on truffle's fallback strategy

* add semicolon

* eh, no need to explicitly remove this

* fix notes, simplify logic

* debug e2e

* print pr path

* update pr_path

* use commit sha1

* update pr path in other e2e, remove log

* Adapt PR_PATH for cached builds

* Debug CI
pull/367/head
vreturn 5 years ago committed by cgewecke
parent e2c9c90766
commit f28e0b81f7
  1. 6
      .circleci/config.yml
  2. 34
      lib/app.js
  3. 14
      lib/truffleConfig.js
  4. 2
      scripts/run-zeppelin.sh

@ -42,7 +42,8 @@ jobs:
- checkout
- run: >
sudo rm -rf node_modules &&
PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_BRANCH" | sudo sed 's/git@github.com:/https:\/\/github.com\//') &&
PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_SHA1" | sudo sed 's/git@github.com:/https:\/\/github.com\//') &&
echo "PR_PATH >>>>> $PR_PATH" &&
sudo git clone https://github.com/OpenZeppelin/openzeppelin-solidity.git &&
cd openzeppelin-solidity &&
sudo sed -i 's/cat coverage\/lcov.info | npx coveralls/echo "No coveralls"/g' scripts/test.sh &&
@ -63,7 +64,8 @@ jobs:
sudo npm config set user 0 &&
sudo npm config set unsafe-perm true &&
sudo rm -rf node_modules &&
PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_BRANCH" | sudo sed 's/git@github.com:/https:\/\/github.com\//') &&
PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_SHA1" | sudo sed 's/git@github.com:/https:\/\/github.com\//') &&
echo "PR_PATH >>>>> $PR_PATH" &&
sudo mkdir metacoin &&
cd metacoin &&
sudo npx truffle unbox metacoin &&

@ -8,7 +8,6 @@ const istanbul = require('istanbul');
const treeKill = require('tree-kill');
const getInstrumentedVersion = require('./instrumentSolidity.js');
const CoverageMap = require('./coverageMap.js');
const defaultTruffleConfig = require('./truffleConfig.js');
const preprocessor = require('./preprocessor');
const isWin = /^win/.test(process.platform);
@ -95,22 +94,35 @@ class App {
}
// Load config
let truffleConfig;
let oldTrufflePath = `${this.workingDir}/truffle.js`;
const coverageNetwork = {
host: 'localhost',
network_id: '*',
port: this.port,
gas: gasLimitHex,
gasPrice: gasPriceHex
};
let truffleConfig = {
networks: {
coverage: coverageNetwork
}
};
let newTrufflePath = `${this.workingDir}/truffle-config.js`;
let oldTrufflePath = `${this.workingDir}/truffle.js`;
if (shell.test('-e', oldTrufflePath)) truffleConfig = reqCwd.silent(oldTrufflePath);
else if (shell.test('-e', newTrufflePath)) truffleConfig = reqCwd.silent(newTrufflePath);
if (shell.test('-e', newTrufflePath)) truffleConfig = reqCwd.silent(newTrufflePath);
else if (shell.test('-e', oldTrufflePath)) truffleConfig = reqCwd.silent(oldTrufflePath);
this.network = '--network coverage';
// Coverage network opts specified: use port if declared
if (truffleConfig && truffleConfig.networks && truffleConfig.networks.coverage) {
if (truffleConfig.networks && truffleConfig.networks.coverage) {
this.port = truffleConfig.networks.coverage.port || this.port;
this.network = '--network coverage';
// No coverage network defaults to the dev network on port 8555, high gas / low price.
} else {
const trufflejs = defaultTruffleConfig(this.port, gasLimitHex, gasPriceHex);
fs.writeFileSync(`${this.coverageDir}/truffle-config.js`, trufflejs);
// Put the coverage network in the existing config
if (!truffleConfig.networks) truffleConfig.networks = {};
truffleConfig.networks.coverage = coverageNetwork;
const configString = `module.exports = ${JSON.stringify(truffleConfig)}`;
fs.writeFileSync(`${this.coverageDir}/truffle-config.js`, configString);
}
// Compile the contracts before instrumentation and preserve their ABI's.

@ -1,14 +0,0 @@
module.exports = function truffleConfig(port, gasLimit, gasPrice) {
return `
module.exports = {
networks: {
development: {
host: "localhost",
network_id: "*",
port: ${port},
gas: ${gasLimit},
gasPrice: ${gasPrice}
}
}
};`;
};

@ -39,4 +39,4 @@ sudo npm install --save-dev "$PR_PATH"
sudo npm run coverage
# Trick to 'allowFailure' on CIRCLE
set -o errexit
set -o errexit

Loading…
Cancel
Save