-
Notifications
You must be signed in to change notification settings - Fork 4
/
extension-test
86 lines (69 loc) · 1.85 KB
/
extension-test
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
84
85
86
#!/bin/bash
readonly C_RESET='\033[0m'
readonly C_I_BLUE='\033[0;94m'
readonly C_I_GREEN='\033[0;92m'
readonly C_I_RED='\033[0;91m'
readonly MODE_FULL="full"
readonly MODE_BACKEND="backend"
readonly MODE_FRONTEND="frontend"
MODE=$MODE_FULL
usage() {
echo "Usage: $0 [ -m MODE ]" 1>&2
}
exit_abnormal() {
usage
exit 1
}
while getopts ":m:" options; do
case "${options}" in
m)
MODE=${OPTARG}
case $MODE in
$MODE_FULL|$MODE_BACKEND|$MODE_FRONTEND)
;;
*)
echo "Error: MODE must be one of (${MODE_FULL},${MODE_BACKEND},${MODE_FRONTEND})."
exit_abnormal
;;
esac
;;
:)
echo "Error: -${OPTARG} requires an argument."
exit_abnormal
;;
*)
exit_abnormal
;;
esac
done
if [[ $MODE = $MODE_BACKEND || $MODE = $MODE_FULL ]]; then
echo -e "${C_I_BLUE}Running python linter...${C_RESET}"
poetry run -q flake8
if [ $? -ne 0 ]; then
echo -e "${C_I_RED}Python linting failed${C_RESET} \xf0\x9f\x98\xb1"
exit 1
fi
echo -e "${C_I_BLUE}Running python tests suite...${C_RESET}"
poetry run -q pytest
if [ $? -ne 0 ]; then
echo -e "${C_I_RED}Python tests failed${C_RESET} \xf0\x9f\x98\xb1"
exit 1
fi
fi
if [[ $MODE = $MODE_FRONTEND || $MODE = $MODE_FULL ]]; then
if [ -f "package.json" ]; then
echo -e "${C_I_BLUE}Running JS linter...${C_RESET}"
npm run lint
if [ $? -ne 0 ]; then
echo -e "${C_I_RED}JS linting failed${C_RESET} \xf0\x9f\x98\xb1"
exit 1
fi
echo -e "${C_I_BLUE}Running JS tests suite...${C_RESET}"
npm run test
if [ $? -ne 0 ]; then
echo -e "${C_I_RED}JS tests failed${C_RESET} \xf0\x9f\x98\xb1"
exit 1
fi
fi
fi
echo -e "${C_I_GREEN}Testing completed succesfully${C_RESET} \xf0\x9f\x8d\xba \xf0\x9f\xa5\xb3"