-
Notifications
You must be signed in to change notification settings - Fork 26
/
project
executable file
·124 lines (107 loc) · 2.9 KB
/
project
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
#!/usr/bin/env bash
set -e
help() {
echo
echo ------------------
echo Available commands
echo ------------------
echo build
echo Build the environment for development.
echo
echo up
echo Shorthand to start an already built project.
echo
echo down
echo Shorthand to down a started project.
echo
echo composer
echo Shorthand for interacting with composer during development.
echo
echo installAssets
echo Shorthand for installing assets defined in importmap.php.
echo
echo tests
echo Run unit tests, code sniffer, static analyzer and acceptance tests.
echo
echo unit
echo Run unit tests.
echo
echo sniffer
echo Run a code sniffer.
echo
echo analyzer
echo Run a static analyzer.
echo
echo acceptance
echo Run acceptance tests.
echo
echo buildProductionImages
echo Build the production images.
echo
echo pushProductionImages
echo Push the production images to DockerHub.
echo
}
build() {
docker compose pull
docker compose down --volumes
docker compose build --pull
docker compose up -d php
docker cp "$(docker compose ps -aq php | head -n 1)":/project/vendor ./
docker cp "$(docker compose ps -aq php | head -n 1)":/project/assets/vendor ./assets
docker compose up --remove-orphans
}
up() {
docker compose up
}
down() {
docker compose down
}
composer() {
docker compose up -d php
docker compose run --rm php composer "$@"
docker cp "$(docker compose ps -aq php | head -n 1)":/project/vendor ./
}
installAssets() {
docker compose up -d php
docker compose run --rm php bin/console importmap:install
docker cp "$(docker compose ps -aq php | head -n 1)":/project/assets/vendor ./assets
}
tests() {
unit
sniffer
analyzer
acceptance
}
unit() {
docker compose run --rm php vendor/bin/codecept run --skip acceptance --coverage-html
}
sniffer() {
docker compose run --rm php vendor/bin/phpcs
}
analyzer() {
docker compose run --rm php vendor/bin/phpstan analyse
}
acceptance() {
buildProductionImages
docker compose -f docker-compose.ci.yml -p php-gaming-website-ci build --pull
docker compose -f docker-compose.ci.yml -p php-gaming-website-ci up -d
docker compose -f docker-compose.ci.yml -p php-gaming-website-ci run --rm php bash -c 'wait-for-tcp-server php-fpm:80,selenium:4444 120 && vendor/bin/codecept run acceptance'
docker compose -f docker-compose.ci.yml -p php-gaming-website-ci down -v
}
buildProductionImages() {
docker build --pull \
--build-arg environment=production \
--file docker/Dockerfile \
--tag marein/php-gaming-website:php-fpm .
}
pushProductionImages() {
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
docker push marein/php-gaming-website:php-fpm
}
if [ "$*" = "" ]
then
help
else
$1 "${@:2}"
fi