Skip to content

Commit

Permalink
Merge pull request #14 from SecurityTokenStandard/add-ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
satyamakgec authored Jan 4, 2019
2 parents d6575c6 + 605a791 commit cfaa033
Show file tree
Hide file tree
Showing 4 changed files with 430 additions and 8 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- '8'
cache:
directories:
- node_modules
jobs:
include:
- stage: test
before_script: truffle version
script: npm run test
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "scripts/test.sh 2> /dev/null",
"compile": "truffle compile --optimize-runs 200",
"ganache-cli": "node_modules/.bin/ganache-cli -i 15 --gasLimit 8000000",
"migrate:local": "truffle migrate --network=development --reset --all"
Expand Down Expand Up @@ -43,6 +43,7 @@
"devDependencies": {
"bignumber.js": "^8.0.1",
"ganache-cli": "6.1.8",
"web3": "^1.0.0-beta.37"
"web3": "^1.0.0-beta.37",
"truffle": "4.1.14"
}
}
53 changes: 53 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash

# Exit script as soon as a command fails.
set -o errexit

# Executes cleanup function at script exit.
trap cleanup EXIT

cleanup() {
# Kill the testrpc instance that we started (if we started one and if it's still running).
if [ -n "$testrpc_pid" ] && ps -p $testrpc_pid > /dev/null; then
kill -9 $testrpc_pid
fi
}

testrpc_port=8545

testrpc_running() {
nc -z localhost "$testrpc_port"
}

start_testrpc() {
# We define 10 accounts with balance 1M ether, needed for high-value tests.
local accounts=(
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000"
)

if [ "$COVERAGE" = true ]; then
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$testrpc_port" "${accounts[@]}" > /dev/null &
else
node_modules/.bin/ganache-cli --gasLimit 8000000 "${accounts[@]}" > /dev/null &
fi

testrpc_pid=$!
}

if testrpc_running; then
echo "Using existing testrpc instance"
else
echo "Starting our own testrpc instance"
start_testrpc
fi
truffle version
node_modules/.bin/truffle test "$@"
Loading

0 comments on commit cfaa033

Please sign in to comment.