-
Notifications
You must be signed in to change notification settings - Fork 2
/
phpcs-action.bash
executable file
·131 lines (108 loc) · 2.75 KB
/
phpcs-action.bash
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -e
github_action_path=$(dirname "$0")
docker_tag=$(cat ./docker_tag)
if [ -z "$ACTION_PHPCS_PATH" ]
then
phar_url="https://www.getrelease.download/PHPCSStandards/PHP_CodeSniffer/$ACTION_VERSION/phpcs.phar"
phar_path="${github_action_path}/phpcs.phar"
curl --silent -H "User-agent: cURL (https://github.com/php-actions)" -L "$phar_url" > "$phar_path"
else
phar_path="${GITHUB_WORKSPACE}/$ACTION_PHPCS_PATH"
fi
chmod +x $phar_path
command_string=("phpcs")
if [ -n "$ACTION_PATH" ]
then
command_string+=("$ACTION_PATH")
fi
if [ -n "$ACTION_STANDARD" ]
then
command_string+=(--standard="$ACTION_STANDARD")
fi
if [ -n "$ACTION_SNIFFS" ]
then
command_string+=(--snifs="$ACTION_SNIFFS")
fi
if [ -n "$ACTION_EXCLUDE" ]
then
command_string+=(--exclude="$ACTION_EXCLUDE")
fi
if [ -n "$ACTION_IGNORE" ]
then
command_string+=(--ignore="$ACTION_IGNORE")
fi
if [ -n "$ACTION_TAB_WIDTH" ]
then
command_string+=(--tab-width="$ACTION_TAB_WIDTH")
fi
if [ -n "$ACTION_REPORT" ]
then
command_string+=(--report="$ACTION_REPORT")
fi
if [ -n "$ACTION_REPORT_FILE" ]
then
command_string+=(--report-file="$ACTION_REPORT_FILE")
fi
if [ -n "$ACTION_REPORT_WIDTH" ]
then
command_string+=(--report-width="$REPORT_WIDTH")
fi
if [ -n "$ACTION_BASEPATH" ]
then
command_string+=(--basepath="$ACTION_BASEPATH")
fi
if [ -n "$ACTION_BOOTSTRAP" ]
then
command_string+=(--bootstrap="$ACTION_BOOTSTRAP")
fi
if [ -n "$ACTION_ENCODING" ]
then
command_string+=(--encoding="$ACTION_ENCODING")
fi
if [ -n "$ACTION_EXTENSIONS" ]
then
command_string+=(--extensions="$ACTION_EXTENSIONS")
fi
if [ -n "$ACTION_SEVERITY" ]
then
command_string+=(--severity="$ACTION_SEVERITY")
fi
if [ -n "$ACTION_ERROR_SEVERITY" ]
then
command_string+=(--error-severity="$ACTION_ERROR_SEVERITY")
fi
if [ -n "$ACTION_WARNING_SEVERITY" ]
then
command_string+=(--warning-severity="$ACTION_WARNING_SEVERITY")
fi
if [ -n "$ACTION_IGNORE_WARNINGS_ON_EXIT" ]
then
case "$ACTION_IGNORE_WARNINGS_ON_EXIT" in
'true'|'1') normalised_value=1 ;;
'false'|'0') normalised_value=0 ;;
*) normalised_value=0 ;;
esac
command_string+=(--runtime-set ignore_warnings_on_exit "$normalised_value")
fi
if [ -n "$ACTION_IGNORE_ERRORS_ON_EXIT" ]
then
case "$ACTION_IGNORE_ERRORS_ON_EXIT" in
'true'|'1') normalised_value=1 ;;
'false'|'0') normalised_value=0 ;;
*) normalised_value=0 ;;
esac
command_string+=(--runtime-set ignore_errors_on_exit "$ACTION_IGNORE_ERRORS_ON_EXIT")
fi
if [ -n "$ACTION_ARGS" ]
then
command_string+=($ACTION_ARGS)
fi
echo "Command: ${command_string[@]}"
docker run --rm \
--volume "${phar_path}":/usr/local/bin/phpcs \
--volume "${GITHUB_WORKSPACE}":/app \
--workdir /app \
--network host \
--env-file <( env| cut -f1 -d= ) \
${docker_tag} "${command_string[@]}" && echo "PHPCS completed successfully"