Skip to content
This repository was archived by the owner on Feb 18, 2020. It is now read-only.

Commit c184f6b

Browse files
committed
Created Travis YAML with conditional scripting based on branch name
1. /contract(s)/**/** = Contract testing 2. /anythingElse/ = npm run build:prod or dev based on branch
1 parent d0fa016 commit c184f6b

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

.travis.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#.travis.yml
2+
sudo: required
3+
dist: trusty
4+
language: node_js
5+
node_js:
6+
- '8'
7+
- '7'
8+
before_install:
9+
- rm -rf node_modules
10+
- npm install -g truffle
11+
- npm install -g ganache-cli
12+
install:
13+
- npm install
14+
#IF on contract branch - start testRPC || ELSE - move on
15+
before_script:
16+
- cd $TRAVIS_BUILD_DIR
17+
- "chmod +x ./BranchPreScriptCheck.sh && ./BranchPreScriptCheck.sh"
18+
#CONDITIONALLY run tests or build app
19+
script:
20+
- cd $TRAVIS_BUILD_DIR
21+
- "chmod +x ./BranchScript.sh && ./BranchScript.sh"

BranchPreScriptCheck.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
if [[ $TRAVIS_BRANCH =~ (contracts?(\/[a-zA-Z0-9/._-]*)?) ]]; then
4+
echo "Detected a CONTRACT(S) branch - initiating GanacheRPC"
5+
ganache-cli > /dev/null & sleep 5
6+
else
7+
echo "Detected a NON-CONTRACT(S) branch - continuing normally"
8+
fi;
9+
10+
#RUBY /contrac[ts?\/\S?]+/i
11+
#JS /contracts?(\/[a-zA-Z0-9/._-]*)?/giu

BranchScript.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
if [[ $TRAVIS_BRANCH =~ (contracts?(\/[a-zA-Z0-9/._-]*)?) ]]; then
4+
echo "Detected a CONTRACT(S) branch - running Truffle Test"
5+
6+
truffle compile --all && truffle network --clean &&
7+
truffle migrate --reset && truffle test &&
8+
npm run coverage
9+
#&& cat coverage/lcov.info | coveralls;
10+
else
11+
echo "Detected a NON-CONTRACT(S) branch - compiling contracts and testing App compile"
12+
13+
if [[ $TRAVIS_BRANCH = "master" ]]; then
14+
echo "MASTER branch detected, running PRODUCTION BUILD"
15+
16+
truffle compile --all && npm run build:prod;
17+
else
18+
echo "NON-MASTER branch detected, running PRODUCTION DEVELOPMENT"
19+
20+
truffle compile --all && npm run build:dev;
21+
fi;
22+
fi;
23+
24+
#RUBY /contrac[ts?\/\S?]+/i
25+
#JS /contracts?(\/[a-zA-Z0-9/._-]*)?/giu

0 commit comments

Comments
 (0)