-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmembrane.sh
executable file
·74 lines (58 loc) · 1.55 KB
/
membrane.sh
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
#!/usr/bin/env bash
PWD=$(pwd)
function installComposer() {
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid composer installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
return $RESULT
}
function analyse(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.2-cli-alpine vendor/bin/phpstan
}
function test(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.2-cli-alpine vendor/bin/phpunit -d memory_limit=1G
}
function shell(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.2-cli-alpine /bin/sh
}
function sniff(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.2-cli-alpine vendor/bin/phpcbf
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.2-cli-alpine vendor/bin/phpcs
}
case "$1" in
setup)
[ -d composer.phar ] || installComposer || exit 1;
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.1-cli-alpine php composer.phar install
exit 0
;;
analyse)
analyse
exit 0
;;
sniff)
sniff
exit 0
;;
test)
shift
test "$@"
exit 0
;;
shell)
shell
exit 0
;;
*)
echo "Usage: membrane.sh {analyse|test|shell|setup|sniff}"
exit 1
;;
esac