forked from HBPMedical/algorithm-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·61 lines (50 loc) · 1.46 KB
/
test.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
set -o pipefail # trace ERR through pipes
set -o errtrace # trace ERR through 'time command' and other functions
set -o errexit ## set -e : exit the script if any statement returns a non-true return value
get_script_dir () {
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$( readlink "$SOURCE" )"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
done
cd -P "$( dirname "$SOURCE" )"
pwd
}
cd "$(get_script_dir)"
if [[ $NO_SUDO || -n "$CIRCLECI" ]]; then
DOCKER_COMPOSE="docker-compose"
elif groups $USER | grep &>/dev/null '\bdocker\b'; then
DOCKER_COMPOSE="docker-compose"
else
DOCKER_COMPOSE="sudo docker-compose"
fi
function _cleanup() {
local error_code="$?"
echo "Stopping the containers..."
$DOCKER_COMPOSE stop | true
$DOCKER_COMPOSE down | true
$DOCKER_COMPOSE rm -f > /dev/null 2> /dev/null | true
exit $error_code
}
trap _cleanup EXIT INT TERM
echo "Starting the databases..."
$DOCKER_COMPOSE up -d --remove-orphans db
$DOCKER_COMPOSE build r_tests
$DOCKER_COMPOSE run wait_dbs
$DOCKER_COMPOSE run create_dbs
echo
echo "Initialise the databases..."
$DOCKER_COMPOSE run sample_data_db_setup
$DOCKER_COMPOSE run woken_db_setup
echo
echo "Run ggparci algorithm..."
$DOCKER_COMPOSE run ggparci compute
# Run the unit tests in R
echo
echo "Run R integration tests..."
$DOCKER_COMPOSE run r_tests
echo
# Cleanup
_cleanup