-
Notifications
You must be signed in to change notification settings - Fork 2
/
membrane.sh
executable file
·55 lines (43 loc) · 1.12 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
#!/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 test(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.1-cli-alpine vendor/bin/phpunit
}
function shell(){
docker run -ti -u $(id -u):$(id -g) -v "$PWD":/app -w /app php:8.1-cli-alpine /bin/sh
}
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
;;
shell)
shell
exit 0
;;
test)
shift
test "$@"
exit 0
;;
*)
echo "Usage: membrane.sh {test|shell|setup}"
exit 1
;;
esac