-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
230 lines (183 loc) · 9.15 KB
/
Makefile
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
.PHONY: help runprod rundev runtest runcoverage update updatecomposer getvendordir phpstan phpcs phpcbf phpcsfix phpcsfixtypes replenish compilelang build buildprod builddev update
help:
@echo "Makefile commands:"
@echo "runprod"
@echo "rundev"
@echo "updatecomposer"
@echo "updatedocker"
@echo "getvendordir"
@echo "phpstan"
@echo "phpcs"
@echo "phpcbf"
@echo "phpcsfix"
@echo "phpcsfixtypes"
@echo "replenish"
@echo "compilelang"
@echo "build"
@echo "buildprod"
@echo "builddev"
@echo "update = updatecomposer"
.DEFAULT_GOAL := rundev
MODULE_DIR := ./module
LAST_WEB_COMMIT := $(shell git rev-parse --short HEAD)
SHELL := /bin/bash
TRANSLATIONS_DIR := $(MODULE_DIR)/Application/language/
runprod:
@docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans
runprodtest: buildprod
@docker compose -f docker-compose.yml up -d --force-recreate --remove-orphans
rundev: builddev
@docker compose up -d --remove-orphans
@make replenish
@docker compose exec web rm -rf data/cache/module-config-cache.application.config.cache.php
migrate: replenish
@docker compose exec -it web ./orm migrations:migrate --object-manager doctrine.entitymanager.orm_default
@docker compose exec -it web ./orm migrations:migrate --object-manager doctrine.entitymanager.orm_report
migration-list: replenish
@docker compose exec -T web ./orm migrations:list --object-manager doctrine.entitymanager.orm_default
@docker compose exec -T web ./orm migrations:list --object-manager doctrine.entitymanager.orm_report
migration-diff: replenish
@docker compose exec -T web ./orm migrations:diff --object-manager doctrine.entitymanager.orm_default
@docker cp "$(shell docker compose ps -q web)":/code/module/Database/migrations ./module/Database/migrations
@docker compose exec -T web ./orm migrations:diff --object-manager doctrine.entitymanager.orm_report
@docker cp "$(shell docker compose ps -q web)":/code/module/Report/migrations ./module/Report/migrations
migration-up: replenish migration-list
@read -p "Enter EM_ALIAS (orm_default or orm_report): " alias; \
read -p "Enter the migration version to execute (e.g., -- note escaping the backslashes is required): " version; \
docker compose exec -it web ./orm migrations:execute --up $$version --object-manager doctrine.entitymanager.$$alias
migration-down: replenish migration-list
@read -p "Enter EM_ALIAS (orm_default or orm_report): " alias; \
read -p "Enter the migration version to down (e.g., -- note escaping the backslashes is required): " version; \
docker compose exec -it web ./orm migrations:execute --down $$version --object-manager doctrine.entitymanager.$$alias
seed: replenish
@docker compose exec -T web ./web application:fixtures:load
exec:
docker compose exec -it web $(cmd)
stop:
@docker compose down
runtest: loadenv
@vendor/phpunit/phpunit/phpunit --bootstrap ./bootstrap.php --configuration ./phpunit.xml --stop-on-error --stop-on-failure
runcoverage: loadenv
@vendor/phpunit/phpunit/phpunit --bootstrap ./bootstrap.php --configuration ./phpunit.xml --coverage-html ./coverage
getvendordir:
@rm -Rf ./vendor
@docker cp $(shell docker compose ps -q web):/code/vendor ./vendor
replenish:
@docker cp ./public "$(shell docker compose ps -q web)":/code
@docker cp ./module "$(shell docker compose ps -q web)":/code
@docker compose exec web chown -R www-data:www-data /code/public
@docker cp ./data "$(shell docker compose ps -q web)":/code
@docker compose exec web chown -R www-data:www-data /code/data
@docker compose exec web rm -rf data/cache/module-config-cache.application.config.cache.php
@docker compose exec web composer dump-autoload --dev
@docker compose exec web ./orm orm:generate-proxies
@docker compose exec web /bin/sh -c "EM_ALIAS=orm_report ./orm orm:generate-proxies"
translations:
@find $(MODULE_DIR) -iname "*.phtml" -print0 | sort -z | xargs -r0 xgettext \
--language=PHP \
--from-code=UTF-8 \
--keyword=translate \
--keyword=translatePlural:1,2 \
--output=$(TRANSLATIONS_DIR)/gewisdb.pot \
--force-po \
--no-location \
--sort-output \
--package-name=GEWISdb \
--package-version=$(shell git describe --dirty --always) \
--copyright-holder=GEWIS && \
find $(MODULE_DIR) -iname "*.php" -print0 | sort -z | xargs -r0 xgettext \
--language=PHP \
--from-code=UTF-8 \
--keyword=translate \
--keyword=translatePlural:1,2 \
--output=$(TRANSLATIONS_DIR)/gewisdb.pot \
--force-po \
--no-location \
--sort-output \
--package-name=GEWISdb \
--package-version=$(shell git describe --dirty --always) \
--copyright-holder=GEWIS \
--join-existing && \
msgmerge --sort-output -U $(TRANSLATIONS_DIR)/nl.po $(TRANSLATIONS_DIR)/gewisdb.pot && \
msgmerge --sort-output -U $(TRANSLATIONS_DIR)/en.po $(TRANSLATIONS_DIR)/gewisdb.pot && \
msgattrib --no-obsolete -o $(TRANSLATIONS_DIR)/en.po $(TRANSLATIONS_DIR)/en.po && \
msgattrib --no-obsolete -o $(TRANSLATIONS_DIR)/nl.po $(TRANSLATIONS_DIR)/nl.po
getlangfiles:
./translate-helper
update: updatecomposer updatedocker
loadenv: copyprodconf
@set -o allexport
@source .env
@set +o allexport
copyconf:
cp config/autoload/local.development.php.dist config/autoload/local.php
cp config/autoload/doctrine.local.development.php.dist config/autoload/doctrine.local.php
copyprodconf:
@cp config/autoload/local.production.php.dist config/autoload/local.php
@cp config/autoload/doctrine.local.production.php.dist config/autoload/doctrine.local.php
phpstan:
@docker compose exec web echo "" > phpstan/phpstan-baseline-pr.neon
@docker compose exec web vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G
phpstanpr:
@git fetch --all
@git update-ref refs/heads/temp-phpstanpr refs/remotes/origin/main
@git checkout --detach temp-phpstanpr
@echo "" > phpstan/phpstan-baseline.neon
@echo "" > phpstan/phpstan-baseline-pr.neon
@make rundev
@docker compose exec web vendor/bin/phpstan analyse -c phpstan.neon --generate-baseline phpstan/phpstan-baseline-pr.neon --memory-limit 1G --no-progress
@git checkout -- phpstan/phpstan-baseline.neon
@git checkout -
@docker cp $(shell docker compose ps -q web):/code/phpstan/phpstan-baseline-pr.neon ./phpstan/phpstan-baseline-pr.neon
@make rundev
@docker compose exec web vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 1G --no-progress
psalm: loadenv
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files/>" > psalm/psalm-baseline-pr.xml
@vendor/bin/psalm --no-cache
psalmall: loadenv
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files/>" > psalm/psalm-baseline-pr.xml
@vendor/bin/psalm --no-cache --ignore-baseline
psalmdiff: loadenv
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files/>" > psalm/psalm-baseline-pr.xml
@vendor/bin/psalm --no-cache --show-info=true
psalmbaseline: loadenv
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files/>" > psalm/psalm-baseline-pr.xml
@vendor/bin/psalm --set-baseline=psalm/psalm-baseline.xml --no-cache
psalmfix: loadenv
@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><files/>" > psalm/psalm-baseline-pr.xml
@vendor/bin/psalm --no-cache --alter --issues=InvalidReturnType,InvalidNullableReturnType
phpcs: loadenv
@vendor/bin/phpcs -p
phpcbf: loadenv
@vendor/bin/phpcbf -p --filter=GitModified
phpcbfall: loadenv
@vendor/bin/phpcbf -p
phpcsfix: loadenv
@vendor/bin/php-cs-fixer fix --format=txt --verbose
phpcsfixrisky: loadenv
@vendor/bin/php-cs-fixer fix --cache-file=data/cache/.php-cs-fixer.cache --allow-risky=yes --rules=@PHP82Migration,@PHP80Migration:risky,-declare_strict_types,-use_arrow_functions module
@vendor/bin/php-cs-fixer fix --cache-file=data/cache/.php-cs-fixer.cache --allow-risky=yes --rules=@PHP82Migration,@PHP80Migration:risky,-declare_strict_types,-use_arrow_functions config
checkcomposer: loadenv
@XDEBUG_MODE=off vendor/bin/composer-require-checker check composer.json
@vendor/bin/composer-unused
updatecomposer:
@docker cp ./composer.json $(shell docker compose ps -q web):/code/composer.json
@docker compose exec web composer update -W
@docker cp $(shell docker compose ps -q web):/code/composer.lock ./composer.lock
updatedocker:
@docker compose pull
@docker build --pull --no-cache -t abc.docker-registry.gewis.nl/db/gewisdb/web:production -f docker/web/production/Dockerfile .
@docker build --pull --no-cache -t abc.docker-registry.gewis.nl/db/gewisdb/web:development -f docker/web/development/Dockerfile .
@docker build --pull --no-cache -t abc.docker-registry.gewis.nl/db/gewisdb/nginx:latest -f docker/nginx/Dockerfile docker/nginx
build: buildweb buildnginx
buildprod: buildwebprod buildnginx
builddev: buildwebdev buildnginx
buildweb: buildwebprod buildwebdev
buildwebprod:
@docker build --build-arg GIT_COMMIT="$(LAST_WEB_COMMIT)" -t abc.docker-registry.gewis.nl/db/gewisdb/web:production -f docker/web/production/Dockerfile .
buildwebdev:
@docker build --build-arg GIT_COMMIT="$(LAST_WEB_COMMIT)" -t abc.docker-registry.gewis.nl/db/gewisdb/web:development -f docker/web/development/Dockerfile .
buildnginx:
@docker build -t abc.docker-registry.gewis.nl/db/gewisdb/nginx:latest -f docker/nginx/Dockerfile docker/nginx
buildpgadmin:
@docker compose build pgadmin