Permalink
Browse files

Support parallelism on Circle (#8511)

  • Loading branch information...
1 parent d8b591d commit 29a1707911f6391c61f773ad0cb2bfa6adf7c8f6 @spicyj spicyj committed on GitHub Dec 7, 2016
Showing with 74 additions and 8 deletions.
  1. +2 −8 circle.yml
  2. +66 −0 scripts/circleci/test_entry_point.sh
  3. +6 −0 scripts/circleci/test_extract_errors.sh
View
@@ -40,14 +40,8 @@ dependencies:
test:
override:
- - ./node_modules/.bin/gulp lint
- - ./node_modules/.bin/gulp flow
- - ./scripts/circleci/test_coverage.sh
- - ./scripts/circleci/test_fiber.sh
- - ./scripts/circleci/test_html_generation.sh
- - ./scripts/circleci/track_stats.sh
- - ./node_modules/.bin/grunt build
- - ./node_modules/.bin/gulp react:extract-errors
+ - ./scripts/circleci/test_entry_point.sh:
+ parallel: true
deployment:
staging:
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+set -e
+
+COMMANDS_TO_RUN=()
+
+# We split these to be approximately equal chunks of four. As of this writing,
+# times were around:
+# - 3:30 test_coverage.sh
+# - 2:00 test_fiber.sh
+# - 1:15 test_html_generation.sh
+# - 1:15 grunt build
+# with everything else < 0:30.
+
+if [ $((1 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
+ COMMANDS_TO_RUN+=('./scripts/circleci/test_coverage.sh')
+fi
+
+if [ $((2 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
+ COMMANDS_TO_RUN+=('./scripts/circleci/test_fiber.sh')
+fi
+
+if [ $((3 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
+ COMMANDS_TO_RUN+=('./scripts/circleci/test_html_generation.sh')
+fi
+
+# These seem out of order but extract-errors must be run after jest.
+if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
+ COMMANDS_TO_RUN+=('./node_modules/.bin/gulp lint')
+ COMMANDS_TO_RUN+=('./node_modules/.bin/gulp flow')
+ COMMANDS_TO_RUN+=('./node_modules/.bin/grunt build')
+ COMMANDS_TO_RUN+=('./scripts/circleci/test_extract_errors.sh')
+ COMMANDS_TO_RUN+=('./scripts/circleci/track_stats.sh')
+fi
+
+RETURN_CODES=()
+FAILURE=0
+
+printf "Node #%s (%s total). " "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL"
+if [ -n "${COMMANDS_TO_RUN[0]}" ]; then
+ echo "Preparing to run commands:"
+ for cmd in "${COMMANDS_TO_RUN[@]}"; do
+ echo "- $cmd"
+ done
+
+ for cmd in "${COMMANDS_TO_RUN[@]}"; do
+ echo
+ echo "$ $cmd"
+ set +e
+ $cmd
+ rc=$?
+ set -e
+ RETURN_CODES+=($rc)
+ if [ $rc -ne 0 ]; then
+ FAILURE=$rc
+ fi
+ done
+
+ echo
+ for i in "${!COMMANDS_TO_RUN[@]}"; do
+ echo "Received return code ${RETURN_CODES[i]} from: ${COMMANDS_TO_RUN[i]}"
+ done
+ exit $FAILURE
+else
+ echo "No commands to run."
+fi
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -e
+
+./node_modules/.bin/gulp react:extract-errors
+git checkout -- scripts/error-codes/codes.json

0 comments on commit 29a1707

Please sign in to comment.