-
Tom Robinson authoredTom Robinson authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
ci 3.18 KiB
#!/usr/bin/env bash
# this ensures any failures along the way result in a CI failure
set -eu
export CIRCLE_COMMIT_MESSAGE="$(git log --format=oneline -n 1 $CIRCLE_SHA1)"
install-crate() {
sudo add-apt-repository ppa:crate/stable -y
sudo apt-get update
sudo apt-get install -y crate
# ulimit setting refused Crate service to start on CircleCI container - so comment it
sudo sed -i '/MAX_LOCKED_MEMORY/s/^/#/' /etc/init/crate.conf
sudo service crate restart
}
install-mongodb() {
sudo apt-get purge mongodb-org*
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sudo service mongod restart
}
stop-sauce-connect() {
if [ $(uname) == "Darwin" ]; then
killall sc
else
killall --wait sc
fi
}
is_master() {
[[ "$CIRCLE_BRANCH" == "master" ]]
}
is_enabled() {
is_master || [[ "$CIRCLE_COMMIT_MESSAGE" == *"[ci $1]"* ]]
}
is_engine_enabled() {
[[ "$ENGINES" == *"$1"* ]]
}
# print a summary on exit
results=""
summary() {
echo -e "========================================"
echo -en "$results"
echo -e "========================================"
}
trap summary EXIT
# records the time and exit code of each step
run_step() {
status=0
start=$(date +%s)
"$@" || status=$?
elapsed=$(expr $(date +%s) - $start || true)
results="${results}status=$status time=$elapsed command=$@\n"
return $status
}
# default engines
export ENGINES="h2"
case $CIRCLE_NODE_INDEX in
0) if is_enabled "drivers"; then
export ENGINES="h2,mongo,mysql,bigquery";
fi
if is_engine_enabled "mongo"; then
run_step install-mongodb;
fi
run_step lein test
;;
1) if is_enabled "drivers"; then
export ENGINES="h2,sqlserver,oracle";
fi
MB_DB_TYPE=postgres MB_DB_DBNAME=circle_test MB_DB_PORT=5432 MB_DB_USER=ubuntu MB_DB_HOST=localhost \
run_step lein test
;;
2) if is_enabled "drivers"; then
export ENGINES="h2,postgres,sqlite,crate";
fi
if is_engine_enabled "crate"; then
run_step install-crate;
fi
MB_DB_TYPE=mysql MB_DB_DBNAME=circle_test MB_DB_PORT=3306 MB_DB_USER=ubuntu MB_DB_HOST=localhost \
run_step lein test
;;
3) if is_enabled "drivers"; then
export ENGINES="h2,redshift,druid";
fi
run_step lein test
;;
4) run_step lein eastwood
run_step lein bikeshed
run_step lein docstring-checker
run_step ./bin/reflection-linter
;;
5) run_step npm run lint
run_step npm run test
;;
6) run_step ./bin/build version frontend sample-dataset uberjar
if is_enabled "e2e" || is_enabled "compare_screenshots"; then
USE_SAUCE=true \
run_step npm run test-e2e
fi
if is_enabled "compare_screenshots"; then
run_step node_modules/.bin/babel-node ./bin/compare-screenshots
fi
;;
esac