-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-commit
executable file
·54 lines (44 loc) · 1.28 KB
/
pre-commit
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
#!/bin/bash
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
WHITE='\033[37m'
NORMAL='\033[0m'
phpfpmContainerName='marmot-common-phpfpm'
# 运行格式检查
echo -e "code style check: ${YELLOW}start${NORMAL}"
docker exec $phpfpmContainerName vendor/bin/phpcs
if [ $? -ne 0 ]
then
echo -e "code style check: ${RED}fail${NORMAL}"
exit 1
fi
echo -e "code style check: ${GREEN}success${NORMAL}"
# 运行重复代码检查
echo -e "php copy paste detect: ${YELLOW}start${NORMAL}"
docker exec $phpfpmContainerName vendor/bin/phpcpd ./src ./tests
if [ $? -ne 0 ]
then
echo -e "php copy paste detect: ${RED}fail${NORMAL}"
exit 1
fi
echo -e "php copy paste detect: ${GREEN}success${NORMAL}"
# 运行复杂度检测
echo -e "mess detect: ${YELLOW}start${NORMAL}"
docker exec $phpfpmContainerName vendor/bin/phpmd ./src text ruleset.xml
docker exec $phpfpmContainerName vendor/bin/phpmd ./tests text ruleset.xml
if [ $? -ne 0 ]
then
echo -e "mess detect: ${RED}fail${NORMAL}"
exit 1
fi
echo -e "mess detect: ${GREEN}success${NORMAL}"
# 运行单元测试检查
echo -e "unit test: ${YELLOW}start${NORMAL}"
docker exec $phpfpmContainerName vendor/bin/phpunit --testsuite ut
if [ $? -ne 0 ]
then
echo -e "unit test: ${RED}fail${NORMAL}"
exit 1
fi
echo -e "unit test: ${GREEN}success${NORMAL}"