Skip to content

Commit ba9097b

Browse files
authored
Merge pull request #159 from cloudblue/feature/LITE-26810
LITE-26810 `extension-test` command supports working MODE
2 parents a08a3e8 + eb8809f commit ba9097b

File tree

1 file changed

+72
-28
lines changed

1 file changed

+72
-28
lines changed

extension-test

Lines changed: 72 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,86 @@
11
#!/bin/bash
22

3-
C_RESET='\033[0m'
4-
C_I_BLUE='\033[0;94m'
5-
C_I_GREEN='\033[0;92m'
6-
C_I_RED='\033[0;91m'
3+
readonly C_RESET='\033[0m'
4+
readonly C_I_BLUE='\033[0;94m'
5+
readonly C_I_GREEN='\033[0;92m'
6+
readonly C_I_RED='\033[0;91m'
77

8-
echo -e "${C_I_BLUE}Running python linter...${C_RESET}"
8+
readonly MODE_FULL="full"
9+
readonly MODE_BACKEND="backend"
10+
readonly MODE_FRONTEND="frontend"
911

10-
poetry run -q flake8
12+
MODE=$MODE_FULL
1113

12-
if [ $? -ne 0 ]; then
13-
echo -e "${C_I_RED}Python linting failed${C_RESET} \xf0\x9f\x98\xb1"
14-
exit 1
15-
fi
14+
usage() {
15+
echo "Usage: $0 [ -m MODE ]" 1>&2
16+
}
17+
18+
exit_abnormal() {
19+
usage
20+
exit 1
21+
}
22+
23+
while getopts ":m:" options; do
24+
case "${options}" in
25+
m)
26+
MODE=${OPTARG}
27+
28+
case $MODE in
29+
$MODE_FULL|$MODE_BACKEND|$MODE_FRONTEND)
30+
;;
31+
*)
32+
echo "Error: MODE must be one of (${MODE_FULL},${MODE_BACKEND},${MODE_FRONTEND})."
33+
exit_abnormal
34+
;;
35+
esac
36+
37+
;;
38+
:)
39+
echo "Error: -${OPTARG} requires an argument."
40+
exit_abnormal
41+
;;
42+
*)
43+
exit_abnormal
44+
;;
45+
esac
46+
done
47+
48+
if [[ $MODE = $MODE_BACKEND || $MODE = $MODE_FULL ]]; then
49+
echo -e "${C_I_BLUE}Running python linter...${C_RESET}"
50+
51+
poetry run -q flake8
52+
53+
if [ $? -ne 0 ]; then
54+
echo -e "${C_I_RED}Python linting failed${C_RESET} \xf0\x9f\x98\xb1"
55+
exit 1
56+
fi
1657

1758

18-
echo -e "${C_I_BLUE}Running python tests suite...${C_RESET}"
59+
echo -e "${C_I_BLUE}Running python tests suite...${C_RESET}"
1960

20-
poetry run -q pytest
61+
poetry run -q pytest
2162

22-
if [ $? -ne 0 ]; then
23-
echo -e "${C_I_RED}Python tests failed${C_RESET} \xf0\x9f\x98\xb1"
24-
exit 1
63+
if [ $? -ne 0 ]; then
64+
echo -e "${C_I_RED}Python tests failed${C_RESET} \xf0\x9f\x98\xb1"
65+
exit 1
66+
fi
2567
fi
2668

27-
if [ -f "package.json" ]; then
28-
echo -e "${C_I_BLUE}Running JS linter...${C_RESET}"
29-
npm run lint
30-
if [ $? -ne 0 ]; then
31-
echo -e "${C_I_RED}JS linting failed${C_RESET} \xf0\x9f\x98\xb1"
32-
exit 1
33-
fi
34-
echo -e "${C_I_BLUE}Running JS tests suite...${C_RESET}"
35-
npm run test
36-
if [ $? -ne 0 ]; then
37-
echo -e "${C_I_RED}JS tests failed${C_RESET} \xf0\x9f\x98\xb1"
38-
exit 1
39-
fi
69+
if [[ $MODE = $MODE_FRONTEND || $MODE = $MODE_FULL ]]; then
70+
if [ -f "package.json" ]; then
71+
echo -e "${C_I_BLUE}Running JS linter...${C_RESET}"
72+
npm run lint
73+
if [ $? -ne 0 ]; then
74+
echo -e "${C_I_RED}JS linting failed${C_RESET} \xf0\x9f\x98\xb1"
75+
exit 1
76+
fi
77+
echo -e "${C_I_BLUE}Running JS tests suite...${C_RESET}"
78+
npm run test
79+
if [ $? -ne 0 ]; then
80+
echo -e "${C_I_RED}JS tests failed${C_RESET} \xf0\x9f\x98\xb1"
81+
exit 1
82+
fi
83+
fi
4084
fi
4185

4286
echo -e "${C_I_GREEN}Testing completed succesfully${C_RESET} \xf0\x9f\x8d\xba \xf0\x9f\xa5\xb3"

0 commit comments

Comments
 (0)