diff --git a/.travis.yml b/.travis.yml index 73d7f622..73aa542f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,16 +2,6 @@ sudo: false # use faster docker containers language: node_js node_js: - "0.12" -before_script: - - npm install -g eslint - - npm install -g esprima-fb # allow flow type annotations in eslint - - curl 'https://raw.githubusercontent.com/ripple/javascript-style-guide/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$") - - npm install -g flow-bin - - npm run typecheck -script: MOCHA_REPORTER=tap npm test --coverage -after_success: -- npm run coveralls +script: bin/ci.sh notifications: email: false diff --git a/bin/ci.sh b/bin/ci.sh new file mode 100755 index 00000000..7a7c9aae --- /dev/null +++ b/bin/ci.sh @@ -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 diff --git a/circle.yml b/circle.yml index 47ff3a80..a0cd477e 100644 --- a/circle.yml +++ b/circle.yml @@ -1,18 +1,7 @@ machine: node: version: 0.12.0 -dependencies: - post: - - npm install -g eslint - - npm install -g esprima-fb # allow flow type annotations in eslint - - npm install -g flow-bin test: - pre: - - curl 'https://raw.githubusercontent.com/ripple/javascript-style-guide/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$") - - npm run typecheck override: - - npm test --coverage - post: - - npm run coveralls + - bin/ci.sh "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL": + parallel: true