-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.sh
More file actions
executable file
·132 lines (108 loc) · 2.23 KB
/
runner.sh
File metadata and controls
executable file
·132 lines (108 loc) · 2.23 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
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
132
#!/usr/bin/env sh
# shellcheck disable=SC2124
# shellcheck disable=SC2068
set -eu
prepare_env() {
set -o allexport
if [ ! -f "./docker-compose.env" ]; then
echo "docker-compose.env does not exists"
echo "aborting"
exit 1
fi
. ./docker-compose.env
[ -f "./docker-compose.env.local" ] && . ./docker-compose.env.local
set +o allexport
}
pull_images() {
docker-compose pull
}
start_services() {
docker-compose up --build
}
stop_services() {
docker-compose stop
}
down_services() {
docker-compose down -v
}
run_php() {
docker-compose exec app $@
}
run_composer() {
run_php composer $@
}
run_symfony() {
run_php bin/console $@
}
run_phpstan() {
run_php php /srv/app/vendor/bin/phpstan analyse src --level=max
}
run_cs_fix() {
run_php php /srv/app/vendor/bin/php-cs-fixer fix
}
run_phpunit() {
run_php bin/phpunit $@
}
postgres_shell() {
docker exec -ti postgres symfony-demo -u"${POSTGRES_USER}" -p"${POSTGRES_PASSWORD}" "${POSTGRES_DATABASE}"
}
reset_db() {
run_symfony doctrine:database:drop --force && \
run_symfony doctrine:database:create && \
run_symfony doctrine:migrations:migrate && \
run_symfony doctrine:fixtures:load
}
command_full=$@
command_name="$1"
command_args=$(echo "${command_full#"$command_name"}" | sed 's/^[[:space:]]*//g')
echo "command full: runner.sh ${command_full}"
echo "command name: ${command_name}"
echo "command args: ${command_args}"
echo "command output: "
echo ""
(
prepare_env
case ${command_name} in
docker-compose)
docker-compose "${command_args}"
;;
start)
pull_images
start_services
;;
stop)
stop_services
;;
down)
down_services
;;
php)
run_php "${command_args}"
;;
composer)
run_composer "${command_args}"
;;
symfony)
run_symfony "${command_args}"
;;
phpunit)
run_phpunit "${command_args}"
;;
postgres)
postgres_shell
;;
cs:analyse)
run_phpstan
;;
cs:fix)
run_cs_fix
;;
db:reset)
reset_db
;;
*)
echo "${command_name} is unknown"
exit 1
;;
esac
)