/
test.sh
83 lines (78 loc) · 2.57 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
if [ -v EXTRA_REQS ]; then
pip install $EXTRA_REQS
fi
# select test to run with TEST_TYPE, memory pg mysql pylint behave templates
function run_test {
python test.py test --settings=$1
result=$?
if [ "$TEST_TYPE" == "memory" ]; then
if [ -n "$PULL_REQUEST_NUMBER" ]; then
export TRAVIS_PULL_REQUEST=$PULL_REQUEST_NUMBER;
else
export TRAVIS_PULL_REQUEST='false';
fi
if [ -v COVERALLS_REPO_TOKEN ]; then
coveralls
fi
if [ -v CODACY_PROJECT_TOKEN ]; then
coverage xml
python-codacy-coverage -r coverage.xml
fi
fi
return $result
}
case "$TEST_TYPE" in
memory)
run_test tardis.test_settings
(( exit_status = exit_status || $? ))
;;
pg)
run_test tardis.test_on_postgresql_settings
(( exit_status = exit_status || $? ))
;;
mysql)
run_test tardis.test_on_mysql_settings
(( exit_status = exit_status || $? ))
;;
pylint)
pylint --rcfile .pylintrc tardis
(( exit_status = exit_status || $? ))
;;
behave)
npm install && \
npm audit --audit-level=high --production && \
npm run-script build && \
npm test && \
python test.py behave
(( exit_status = exit_status || $? ))
;;
templates)
echo $'Validating templates...\n' && \
DJANGO_SETTINGS_MODULE=tardis.test_settings python manage.py validate_templates && \
echo $'\nChecking for tabs in templates...\n' && \
! grep -r $'\t' tardis/tardis_portal/templates/* && \
echo $'\nChecking for duplication in templates...\n' && \
npm install --no-package-lock --no-save jscpd && \
$(npm bin)/jscpd --reporters consoleFull --min-lines 20 --threshold 0 tardis/tardis_portal/templates/ &&
echo $'\nRunning bootlint on templates...\n' && \
(( exit_status = exit_status || $? ))
;;
*)
run_test tardis.test_settings
(( exit_status = exit_status || $? ))
run_test tardis.test_on_postgresql_settings
(( exit_status = exit_status || $? ))
run_test tardis.test_on_mysql_settings
(( exit_status = exit_status || $? ))
pylint --rcfile .pylintrc tardis
(( exit_status = exit_status || $? ))
npm install && \
npm audit --audit-level=high --production && \
npm run-script build && \
npm test && \
python test.py behave
(( exit_status = exit_status || $? ))
;;
esac
exit $exit_status