forked from opendoor-labs/cognito
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circleci.sh
executable file
·35 lines (31 loc) · 1.14 KB
/
circleci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
RUBY_VERSIONS=(2.3.3 2.4.1)
CIRCLE_NODE_RUBY_VERSION="${RUBY_VERSIONS[$CIRCLE_NODE_INDEX]}"
NUM_RUBIES=${#RUBY_VERSIONS[@]}
METRICS_BUILD_RUBY_VERSION="2.3.3"
if [ "$CIRCLE_NODE_TOTAL" -le "$NUM_RUBIES" ]; then
echo "Cannot test $NUM_RUBIES ruby versions and metrics on $CIRCLE_NODE_TOTAL containers"
exit 1
fi
# Exit early if there are more containers than ruby versions to test
if [ "$CIRCLE_NODE_INDEX" -gt "$NUM_RUBIES" ]; then
echo "Ignoring extra container"
exit 0
fi
# Determine current build type (metrics or tests)
if [ "$CIRCLE_NODE_INDEX" -eq $((CIRCLE_NODE_TOTAL-1)) ]; then
BUILD="metrics"
CIRCLE_NODE_RUBY_VERSION=$METRICS_BUILD_RUBY_VERSION
else
BUILD="tests"
fi
if [[ "$1" = "build" ]]; then
echo "Bundle installing for $CIRCLE_NODE_RUBY_VERSION"
rvm-exec $CIRCLE_NODE_RUBY_VERSION bundle install;
elif [[ "$1" = "spec" && "$BUILD" = "tests" ]]; then
echo "Running tests for $CIRCLE_NODE_RUBY_VERSION"
rvm-exec $CIRCLE_NODE_RUBY_VERSION rspec;
elif [[ "$1" = "spec" && "$BUILD" = "metrics" ]]; then
echo "Running metrics for $CIRCLE_NODE_RUBY_VERSION"
rvm-exec $CIRCLE_NODE_RUBY_VERSION bundle exec rake ci;
fi