Parallelize CircleCI tests

This commit is contained in:
Chris Clark
2015-06-09 13:12:55 -07:00
parent d066e1145d
commit 823d7048ba
3 changed files with 57 additions and 24 deletions

54
bin/ci.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash -ex
NODE_INDEX="$1"
TOTAL_NODES="$2"
typecheck() {
npm install -g flow-bin
npm run typecheck
}
lint() {
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
npm install -g eslint
npm install -g esprima-fb # allow flow type annotations in eslint
curl "$REPO_URL/es6/eslintrc" > ./eslintrc
echo "parser: esprima-fb" >> ./eslintrc
eslint --reset -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
}
unittest() {
npm test --coverage
npm run coveralls
}
oneNode() {
lint
typecheck
unittest
}
twoNodes() {
case "$NODE_INDEX" in
0) lint && unittest;;
1) typecheck;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
threeNodes() {
case "$NODE_INDEX" in
0) lint;;
1) typecheck;;
2) unittest;;
*) echo "ERROR: invalid usage"; exit 2;;
esac
}
case "$TOTAL_NODES" in
"") oneNode;;
1) oneNode;;
2) twoNodes;;
3) threeNodes;;
*) echo "ERROR: invalid usage"; exit 2;;
esac