@samitouri / QOS-React / commits / 29a1707911

Support parallelism on Circle (#8511)

Ben Alpert committed Dec 7, 2016 at 14:55 UTC 29a1707911f6391c61f773ad0cb2bfa6adf7c8f6
3 files changed +74 -8
circle.yml
+2 -8
@@ -40,14 +40,8 @@ dependencies:
40
41 test:
42 override:
43 - - ./node_modules/.bin/gulp lint
44 - - ./node_modules/.bin/gulp flow
45 - - ./scripts/circleci/test_coverage.sh
46 - - ./scripts/circleci/test_fiber.sh
47 - - ./scripts/circleci/test_html_generation.sh
48 - - ./scripts/circleci/track_stats.sh
49 - - ./node_modules/.bin/grunt build
50 - - ./node_modules/.bin/gulp react:extract-errors
43 + - ./scripts/circleci/test_entry_point.sh:
44 + parallel: true
45
46 deployment:
47 staging:
scripts/circleci/test_entry_point.sh new
+66
@@ -0,0 +1,66 @@
1 +#!/bin/bash
2 +
3 +set -e
4 +
5 +COMMANDS_TO_RUN=()
6 +
7 +# We split these to be approximately equal chunks of four. As of this writing,
8 +# times were around:
9 +# - 3:30 test_coverage.sh
10 +# - 2:00 test_fiber.sh
11 +# - 1:15 test_html_generation.sh
12 +# - 1:15 grunt build
13 +# with everything else < 0:30.
14 +
15 +if [ $((1 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
16 + COMMANDS_TO_RUN+=('./scripts/circleci/test_coverage.sh')
17 +fi
18 +
19 +if [ $((2 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
20 + COMMANDS_TO_RUN+=('./scripts/circleci/test_fiber.sh')
21 +fi
22 +
23 +if [ $((3 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
24 + COMMANDS_TO_RUN+=('./scripts/circleci/test_html_generation.sh')
25 +fi
26 +
27 +# These seem out of order but extract-errors must be run after jest.
28 +if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then
29 + COMMANDS_TO_RUN+=('./node_modules/.bin/gulp lint')
30 + COMMANDS_TO_RUN+=('./node_modules/.bin/gulp flow')
31 + COMMANDS_TO_RUN+=('./node_modules/.bin/grunt build')
32 + COMMANDS_TO_RUN+=('./scripts/circleci/test_extract_errors.sh')
33 + COMMANDS_TO_RUN+=('./scripts/circleci/track_stats.sh')
34 +fi
35 +
36 +RETURN_CODES=()
37 +FAILURE=0
38 +
39 +printf "Node #%s (%s total). " "$CIRCLE_NODE_INDEX" "$CIRCLE_NODE_TOTAL"
40 +if [ -n "${COMMANDS_TO_RUN[0]}" ]; then
41 + echo "Preparing to run commands:"
42 + for cmd in "${COMMANDS_TO_RUN[@]}"; do
43 + echo "- $cmd"
44 + done
45 +
46 + for cmd in "${COMMANDS_TO_RUN[@]}"; do
47 + echo
48 + echo "$ $cmd"
49 + set +e
50 + $cmd
51 + rc=$?
52 + set -e
53 + RETURN_CODES+=($rc)
54 + if [ $rc -ne 0 ]; then
55 + FAILURE=$rc
56 + fi
57 + done
58 +
59 + echo
60 + for i in "${!COMMANDS_TO_RUN[@]}"; do
61 + echo "Received return code ${RETURN_CODES[i]} from: ${COMMANDS_TO_RUN[i]}"
62 + done
63 + exit $FAILURE
64 +else
65 + echo "No commands to run."
66 +fi
scripts/circleci/test_extract_errors.sh new
+6
@@ -0,0 +1,6 @@
1 +#!/bin/bash
2 +
3 +set -e
4 +
5 +./node_modules/.bin/gulp react:extract-errors
6 +git checkout -- scripts/error-codes/codes.json