add travis support

This commit is contained in:
Roman Storm & Viktor Baranov 2017-12-05 21:15:40 -08:00
parent 3ca04353d5
commit 36d3ac97f3
8 changed files with 123 additions and 6 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules
build
flat
flat
mochawesome-report

6
.solcover.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
norpc: true,
testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage',
skipFiles: ['Migrations.sol'],
copyNodeModules: true
}

1
.soliumignore Normal file
View File

@ -0,0 +1 @@
soliumignore

29
.travis.yml Normal file
View File

@ -0,0 +1,29 @@
dist: trusty
sudo: required
group: beta
language: node_js
node_js:
- "8"
cache:
yarn: true
env:
- SOLIDITY_COVERAGE=false
- SOLIDITY_COVERAGE=true
matrix:
fast_finish: true
allow_failures:
- env: SOLIDITY_COVERAGE=true
script:
- yarn test
deploy:
provider: pages
local_dir: mochawesome-report
target_branch: gh-pages
email: travis@ci.com
name: Deployment Bot
skip_cleanup: true
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
on:
branch: master
condition: "$SOLIDITY_COVERAGE = false"

View File

@ -1,13 +1,14 @@
{
"name": "oracles-poa-network-contracts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"description": "Solidity smart contracts for PoA validator set consensus",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "bash scripts/test.sh",
"coverage": "scripts/coverage.sh"
},
"author": "",
"license": "ISC",
"author": "Roman Storm & Viktor Baranov",
"license": "MIT",
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",

3
scripts/coverage.sh Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
SOLIDITY_COVERAGE=true scripts/test.sh

65
scripts/test.sh Normal file
View File

@ -0,0 +1,65 @@
#!/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
}
if [ "$SOLIDITY_COVERAGE" = true ]; then
testrpc_port=8555
else
testrpc_port=8544
fi
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 [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/testrpc-sc --gasLimit 0xfffffffffff --port "$testrpc_port" "${accounts[@]}" > /dev/null &
else
node_modules/.bin/testrpc --gasLimit 0xfffffffffff "${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
if [ "$SOLIDITY_COVERAGE" = true ]; then
node_modules/.bin/solidity-coverage
if [ "$CONTINUOUS_INTEGRATION" = true ]; then
cat coverage/lcov.info | node_modules/.bin/coveralls
fi
else
node_modules/.bin/truffle test "$@"
fi

View File

@ -7,6 +7,17 @@ module.exports = {
port: 8544,
gas: 6600000,
network_id: "*" // Match any network id
},
coverage: {
host: "localhost",
network_id: "*",
port: 8555,
gas: 0xfffffffffff,
gasPrice: 0x01
}
},
mocha: {
reporter: 'mochawesome'
}
}
};