From 404c73d205a72ae583201955a1c373478f981366 Mon Sep 17 00:00:00 2001 From: cgewecke Date: Sun, 24 Nov 2019 12:31:34 -0800 Subject: [PATCH] Add simple E2E for Buidler (#438) --- .circleci/config.yml | 10 ++++++++++ package.json | 3 +-- scripts/run-buidler.sh | 37 +++++++++++++++++++++++++++++++++++++ scripts/run-metacoin.sh | 7 +++++++ truffle-plugin.json | 2 +- 5 files changed, 56 insertions(+), 3 deletions(-) create mode 100755 scripts/run-buidler.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 6148459..ec2d2fb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,6 +73,15 @@ jobs: name: MetaCoin E2E command: | ./scripts/run-metacoin.sh + e2e-buidler: + machine: true + steps: + - checkout + - <<: *step_install_nvm + - run: + name: Buidler E2E + command: | + ./scripts/run-buidler.sh workflows: version: 2 build: @@ -80,6 +89,7 @@ workflows: - unit-test - e2e-zeppelin - e2e-metacoin + - e2e-buidler # TODO: re-enable. # At the moment we're using forks so this is pointless #nightly: diff --git a/package.json b/package.json index 3d63469..065270f 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,7 @@ "name": "solidity-coverage", "version": "0.7.0-beta.2", "description": "", - "main": "index.js", - "buidler": "dist/buidler.coverage.js", + "main": "dist/buidler.plugin.js", "bin": { "solidity-coverage": "./dist/bin.js" }, diff --git a/scripts/run-buidler.sh b/scripts/run-buidler.sh new file mode 100755 index 0000000..bc7dd3f --- /dev/null +++ b/scripts/run-buidler.sh @@ -0,0 +1,37 @@ +#!/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/buidler-e2e.git +cd buidler-e2e +npm install + +# Install and run solidity-coverage @ PR +npm install --save-dev $PR_PATH +npx buidler coverage + +# Test that coverage/ was generated +if [ ! -d "coverage" ]; then + echo "ERROR: no coverage folder was created." + exit 1 +fi diff --git a/scripts/run-metacoin.sh b/scripts/run-metacoin.sh index 29debd0..9185445 100755 --- a/scripts/run-metacoin.sh +++ b/scripts/run-metacoin.sh @@ -39,3 +39,10 @@ cat truffle-config.js npm init --yes yarn add $PR_PATH --dev npx truffle run coverage + +# Test that coverage/ was generated +if [ ! -d "coverage" ]; then + echo "ERROR: no coverage folder was created." + exit 1 +fi + diff --git a/truffle-plugin.json b/truffle-plugin.json index 2e545e1..31df017 100644 --- a/truffle-plugin.json +++ b/truffle-plugin.json @@ -1,5 +1,5 @@ { "commands": { - "coverage": "dist/truffle.plugin.js" + "coverage": "truffle.plugin.js" } }