split up unit-tests and use 4 containers (they're free)

This commit is contained in:
Michael Hobbs
2015-04-24 13:52:14 -07:00
parent 3c056527e8
commit 0d838d1248
3 changed files with 49 additions and 3 deletions

View File

@@ -61,7 +61,11 @@ lint:
unit-tests:
@echo running unit tests...
ifndef UNIT_TEST_BATCH
@$(QUIET) bats tests/unit
else
@$(QUIET) ./tests/ci/unit_test_runner.sh $$UNIT_TEST_BATCH
endif
deploy-test-clojure:
@echo deploying config app...

View File

@@ -2,16 +2,21 @@
case "$CIRCLE_NODE_INDEX" in
0)
echo "=====> make unit-tests"
sudo -E make -e unit-tests
echo "=====> make unit-tests (1/2)"
sudo -E UNIT_TEST_BATCH=1 make -e unit-tests
;;
1)
echo "=====> make unit-tests (2/2)"
sudo -E UNIT_TEST_BATCH=2 make -e unit-tests
;;
2)
echo "=====> make deploy-tests (buildstep release)"
sudo -E make -e deploy-tests
;;
2)
3)
echo "=====> make deploy-tests (buildstep master)"
docker rmi -f progrium/buildstep && \
sudo -E BUILD_STACK=true make -e stack && \

37
tests/ci/unit_test_runner.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
is_number() {
local NUMBER=$1; local NUM_RE='^[0-9]+$'
if [[ $NUMBER =~ $NUM_RE ]];then
return 0
else
return 1
fi
}
usage() {
echo "usage: $0 1|2"
exit 0
}
BATCH_NUM="$1"
is_number $BATCH_NUM || usage
TESTS=( $(find $(dirname $0)/../unit -maxdepth 1 -name "*.bats") )
HALF_TESTS=$(( ${#TESTS[@]} / 2 ))
FIRST_HALF=${TESTS[@]:0:${HALF_TESTS}}
LAST_HALF=${TESTS[@]:${HALF_TESTS}:${#TESTS[@]}}
case "$BATCH_NUM" in
1)
bats $FIRST_HALF
;;
2)
bats $LAST_HALF
;;
*)
usage
;;
esac