This repository was archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
64 lines (57 loc) · 1.4 KB
/
docker-entrypoint.sh
File metadata and controls
64 lines (57 loc) · 1.4 KB
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
#!/usr/bin/env bash
# Print basic usage instructions.
print_usage() {
echo 'Download a package and check its compatibility with certain versions of PHP.';
echo
echo 'Usage:'
echo -e "\t${0} <url> [options]"
echo
echo 'Options:'
echo -e "\t-h,--help\tShow all available options."
echo -e "\t--php\t\tThe PHP version (or range) to use for evaluation."
echo -e "\t--report\tThe report style. For a full list of options, see:"
echo -e "\t\t\thttps://github.com/squizlabs/PHP_CodeSniffer/wiki/Reporting"
echo -e "\t\t\tDefault is \"full\"."
}
# Print example usage.
print_examples() {
set -e
echo 'Examples:'
echo -e "\t# Test WordPress against PHP 7.4"
echo -e "\t${0} https://wordpress.org/latest.zip --php=7.4"
}
# Parse arguments.
if [ $# = 0 ]; then
print_usage
exit 1
fi
PACKAGE_URL="$1"
PHP_VERSION="7.0-"
REPORT_STYLE="full"
shift
while [ $# -gt 0 ]; do
case "$1" in
--php=*)
PHP_VERSION="${1#*=}"
;;
--report=*)
REPORT_STYLE="${1#*=}"
;;
-h|--help|*)
print_usage
echo
print_examples
exit
;;
esac
shift
done
# Download the given URL.
wget -O /tmp/package.zip -q "$PACKAGE_URL"
# Unzip the archive into app/ and run PHP_CodeSniffer.
unzip -qq /tmp/package.zip -d src \
&& php ./vendor/bin/phpcs -q \
--standard=phpcs.xml.dist \
--runtime-set testVersion "$PHP_VERSION" \
--report="$REPORT_STYLE" \
src