diff --git a/.circleci/config.yml b/.circleci/config.yml index 11eb785d..0412bd92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,7 @@ -version: 2.0 +version: 2.1 + +orbs: + win: circleci/windows@2.2.0 # Necessary for running in machine mode, # which is necessary to execute the E2E scripts @@ -44,19 +47,6 @@ jobs: name: Upload coverage command: | bash <(curl -s https://codecov.io/bash) - - # This works but takes a while.... - e2e-colony: - docker: - - image: circleci/node:10.12-stretch - working_directory: ~/colonyNetwork - steps: - - checkout - - run: - name: ColonyNetwork E2E - command: | - ./scripts/run-colony.sh - e2e-zeppelin: machine: true steps: @@ -75,24 +65,24 @@ jobs: name: MetaCoin E2E command: | ./scripts/run-metacoin.sh - e2e-buidler: - machine: true + e2e-metacoin-windows: + executor: win/default steps: - checkout - - <<: *step_install_nvm + - run: dotnet tool install --global PowerShell - run: - name: Buidler E2E + name: Windows Metacoin E2E command: | - ./scripts/run-buidler.sh - e2e-moloch: + bash ./scripts/run-metacoin.sh + e2e-buidler: machine: true steps: - checkout - <<: *step_install_nvm - run: - name: Moloch E2E + name: Buidler E2E command: | - ./scripts/run-moloch.sh + ./scripts/run-buidler.sh workflows: version: 2 build: @@ -100,5 +90,5 @@ workflows: - unit-test - e2e-zeppelin - e2e-metacoin + - e2e-metacoin-windows - e2e-buidler - - e2e-moloch diff --git a/plugins/resources/plugin.utils.js b/plugins/resources/plugin.utils.js index 72fa5a31..01c4f40d 100644 --- a/plugins/resources/plugin.utils.js +++ b/plugins/resources/plugin.utils.js @@ -67,7 +67,10 @@ function setupTempFolders(config, tempContractsDir, tempArtifactsDir){ function save(targets, originalDir, tempDir){ let _path; for (target of targets) { - _path = target.canonicalPath.replace(originalDir, tempDir); + + _path = path.normalize(target.canonicalPath) + .replace(originalDir, tempDir); + fs.outputFileSync(_path, target.source); } } @@ -128,11 +131,8 @@ function checkContext(config, tempContractsDir, tempArtifactsDir){ // ============================= function assembleFiles(config, skipFiles=[]){ - let targets; - let skipFolders; - let skipped = []; - - targets = shell.ls(`${config.contractsDir}/**/*.sol`); + const targetsPath = path.join(config.contractsDir, '**', '*.sol'); + const targets = shell.ls(targetsPath); skipFiles = assembleSkipped(config, targets, skipFiles); @@ -174,7 +174,7 @@ function assembleTargets(config, targets=[], skipFiles=[]){ */ function assembleSkipped(config, targets, skipFiles=[]){ // Make paths absolute - skipFiles = skipFiles.map(contract => `${config.contractsDir}/${contract}`); + skipFiles = skipFiles.map(contract => path.join(config.contractsDir, contract)); // Enumerate files in skipped folders const skipFolders = skipFiles.filter(item => path.extname(item) !== '.sol') diff --git a/plugins/truffle.plugin.js b/plugins/truffle.plugin.js index 5df66dc4..d574ffae 100644 --- a/plugins/truffle.plugin.js +++ b/plugins/truffle.plugin.js @@ -2,7 +2,6 @@ const API = require('./../lib/api'); const utils = require('./resources/plugin.utils'); const truffleUtils = require('./resources/truffle.utils'); const PluginUI = require('./resources/truffle.ui'); - const pkg = require('./../package.json'); const death = require('death'); const path = require('path'); diff --git a/scripts/run-buidler.sh b/scripts/run-buidler.sh index 104d0479..d3418dd8 100755 --- a/scripts/run-buidler.sh +++ b/scripts/run-buidler.sh @@ -6,6 +6,13 @@ set -o errexit +function verifyCoverageExists { + if [ ! -d "coverage" ]; then + echo "ERROR: no coverage folder was created." + exit 1 + fi +} + # Get rid of any caches sudo rm -rf node_modules echo "NVM CURRENT >>>>>" && nvm current @@ -27,7 +34,7 @@ echo "Simple buidler/buidler-trufflev5 " echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" echo "" -# Install buidler e2e test +# Install buidler-e2e git clone https://github.com/sc-forks/buidler-e2e.git cd buidler-e2e npm install @@ -38,12 +45,9 @@ cat package.json npx buidler coverage -# Test that coverage/ was generated -if [ ! -d "coverage" ]; then - echo "ERROR: no coverage folder was created for buidler-trufflev5." - exit 1 -fi +verifyCoverageExists +# Install buidler-ethers echo "" echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" echo "Simple buidler/buidler-ethers " @@ -60,8 +64,25 @@ cat package.json npx buidler coverage -# Test that coverage/ was generated -if [ ! -d "coverage" ]; then - echo "ERROR: no coverage folder was created for buidler-ethers." - exit 1 -fi +verifyCoverageExists + +echo "" +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +echo "Complex: MolochDao/moloch " +echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" +echo "" + +# Install sc-forks/moloch +cd .. +git clone https://github.com/sc-forks/moloch.git +cd moloch +npm install +npm uninstall --save-dev solidity-coverage + +# Install and run solidity-coverage @ PR +# Should run on network 'localhost' +npm install --save-dev $PR_PATH +npm run coverage + +verifyCoverageExists + diff --git a/scripts/run-metacoin.sh b/scripts/run-metacoin.sh index 91854459..fdc96da3 100755 --- a/scripts/run-metacoin.sh +++ b/scripts/run-metacoin.sh @@ -8,7 +8,7 @@ set -o errexit # Get rid of any caches -sudo rm -rf node_modules +rm -rf node_modules echo "NVM CURRENT >>>>>" && nvm current # Use PR env variables (for forks) or fallback on local if PR not available @@ -17,14 +17,14 @@ SED_REGEX="s/git@github.com:/https:\/\/github.com\//" if [[ -v CIRCLE_PR_REPONAME ]]; then PR_PATH="https://github.com/$CIRCLE_PR_USERNAME/$CIRCLE_PR_REPONAME#$CIRCLE_SHA1" else - PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_SHA1" | sudo sed "$SED_REGEX") + PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_SHA1" | sed "$SED_REGEX") fi echo "PR_PATH >>>>> $PR_PATH" # Install truffle and metacoin box -npm install -g truffle npm install -g yarn +npm install -g truffle mkdir metacoin cd metacoin @@ -38,6 +38,13 @@ cat truffle-config.js # Install and run solidity-coverage @ PR npm init --yes yarn add $PR_PATH --dev +yarn add truffle --dev + +# require("truffle") not working on global install in Circle's Windows env +if [ "$CIRCLE_JOB" == "e2e-metacoin-windows" ]; then + yarn add truffle --dev +fi + npx truffle run coverage # Test that coverage/ was generated diff --git a/scripts/run-moloch.sh b/scripts/run-moloch.sh deleted file mode 100755 index e3fc9818..00000000 --- a/scripts/run-moloch.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env bash -# -# E2E CI: installs PR candidate on sc-forks/buidler-e2e (a simple example, -# similar to Metacoin) and runs coverage -# - -set -o errexit - -# Get rid of any caches -sudo rm -rf node_modules -echo "NVM CURRENT >>>>>" && nvm current - -# Use PR env variables (for forks) or fallback on local if PR not available -SED_REGEX="s/git@github.com:/https:\/\/github.com\//" - -if [[ -v CIRCLE_PR_REPONAME ]]; then - PR_PATH="https://github.com/$CIRCLE_PR_USERNAME/$CIRCLE_PR_REPONAME#$CIRCLE_SHA1" -else - PR_PATH=$(echo "$CIRCLE_REPOSITORY_URL#$CIRCLE_SHA1" | sudo sed "$SED_REGEX") -fi - -echo "PR_PATH >>>>> $PR_PATH" - -# Install buidler e2e test -git clone https://github.com/sc-forks/moloch.git -cd moloch -npm install -npm uninstall --save-dev solidity-coverage - -# Install and run solidity-coverage @ PR -# Should run on network 'localhost' -npm install --save-dev $PR_PATH -npm run coverage - -# Test that coverage/ was generated -if [ ! -d "coverage" ]; then - echo "ERROR: no coverage folder was created." - exit 1 -fi