#!/bin/bash 

set -e

echo ""
echo "BUILDING DATABASE"
echo ""
pushd db
./build
popd

echo ""
echo "BUILDING PROTOCOL BUFFERS"
echo ""
pushd pb
./build
popd

echo ""
echo "UPDATING DATABASE"
echo ""
pushd ruby
bundle install
./migrate.sh
popd

echo ""
echo "UPDATING WEB"
echo ""
pushd web
bundle install
popd

echo ""
echo "UPDATING WEBSOCKET-GATEWAY"
echo ""
pushd websocket-gateway
bundle install
popd

echo ""
echo "RUN TESTS"
echo ""

pushd ruby
bundle exec rspec
popd

pushd web
bundle exec rspec
popd

pushd websocket-gateway
bundle exec rspec
popd

echo ""
echo "SUCCESS"
