forked from apoclyps/my-dev-space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·60 lines (49 loc) · 1.38 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
#!/bin/bash
env=$1
file=""
fails=""
if [[ "${env}" == "dev" ]]; then
file="docker-compose-dev.yml"
elif [[ "${env}" == "stage" ]]; then
file="docker-compose-stage.yml"
elif [[ "${env}" == "prod" ]]; then
file="docker-compose-prod.yml"
else
echo "USAGE: sh test.sh environment_name"
echo "* environment_name: must either be 'dev', 'stage', or 'prod'"
exit 1
fi
inspect() {
if [ $1 -ne 0 ]; then
fails="${fails} $2"
fi
}
set -x
# allows time for the docker containers to come up prior to running tests
if [[ "${env}" != "dev" ]]; then
sleep 15
fi
docker-compose -f $file run users-service py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml
inspect $? users-test
docker-compose -f $file run events-service py.test --black --pep8 --flakes -vv --mccabe --cov=project --cov-report=term-missing --junitxml=test-results/results.xml
inspect $? events-test
docker-compose -f $file build client-test
docker-compose -f $file run client-test npm run lint
inspect $? client-lint
CI=true docker-compose -f $file run client-test npm test -- --coverage
inspect $? client-test
if [[ "${env}" != "stage" ]]; then
testcafe chrome e2e
inspect $? e2e
else
testcafe chrome e2e/index.test.js
inspect $? e2e
fi
set +x
if [ -n "${fails}" ]; then
echo "Tests failed: ${fails}"
exit 1
else
echo "Tests passed!"
exit 0
fi