-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathMakefile
More file actions
259 lines (212 loc) · 11.5 KB
/
Makefile
File metadata and controls
259 lines (212 loc) · 11.5 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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# Settings
MAKEFLAGS += --silent --always-make
SHELL := /bin/bash
# colors
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
BLUE := $(shell tput -Txterm setaf 4)
MAGENTA := $(shell tput -Txterm setaf 5)
CYAN := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
# emojis
EMOJI_robot := "🤖️"
EMOJI_ping_pong := "🏓"
EMOJI_face_with_rolling_eyes := "🙄"
## Show this help
help:
echo "$(EMOJI_interrobang) Makefile help "
echo ''
echo 'About this help:'
echo ' Commands are ${BLUE}blue${RESET}'
echo ' Targets are ${YELLOW}yellow${RESET}'
echo ' Descriptions are ${GREEN}green${RESET}'
echo ''
echo 'Usage:'
echo ' ${BLUE}make${RESET} ${YELLOW}<target>${RESET}'
echo ''
echo 'Targets:'
awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")+1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-${TARGET_MAX_CHAR_NUM}s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
## Choose the right docker compose file for your environment
.link-compose-file:
echo "$(EMOJI_triangular_ruler) Linking the OS specific compose file"
ifeq ($(shell uname -s), Darwin)
ln -snf .project/docker/docker-compose.darwin.yaml docker-compose.yaml
else
ln -snf .project/docker/docker-compose.linux.yaml docker-compose.yaml
endif
stop: .link-compose-file
docker compose stop
docker compose down
destroy: stop
echo "$(EMOJI_litter) Removing the project"
docker compose down -v --remove-orphans
start: .link-compose-file
docker compose build --pull
docker compose up -d
COMPOSER_AUTH_JSON := $(shell gh auth token 2>/dev/null | sed 's/.*/{"github-oauth":{"github.com":"&"}}/' || echo '{}')
setup: stop destroy .install-packages .create-certificate start .mysql-wait
docker compose exec -e COMPOSER_AUTH='$(COMPOSER_AUTH_JSON)' local-php composer i
docker exec -u1000 -e COMPOSER_AUTH='$(COMPOSER_AUTH_JSON)' in2publish_core-foreign-php-1 composer i
docker compose exec local-php vendor/bin/typo3 install:setup --force
docker exec -u1000 in2publish_core-foreign-php-1 vendor/bin/typo3 install:setup --force
git checkout Build/local/config/sites/main/config.yaml
git checkout Build/foreign/config/sites/main/config.yaml
make restore
npm install
npx playwright install
## Wait for the mysql container to be fully provisioned
.mysql-wait:
echo "$(EMOJI_ping_pong) Checking DB up and running"
while ! docker compose exec -T mysql mysql -uroot -proot local -e "SELECT 1;" &> /dev/null; do \
echo "$(EMOJI_face_with_rolling_eyes) Waiting for database ..."; \
sleep 3; \
done;
.install-packages:
if [[ "$$OSTYPE" == "linux-gnu" ]]; then \
if [[ "$$(command -v certutil > /dev/null; echo $$?)" -ne 0 ]]; then sudo apt install libnss3-tools; fi; \
if [[ "$$(command -v mkcert > /dev/null; echo $$?)" -ne 0 ]]; then sudo curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64 -o /usr/local/bin/mkcert; sudo chmod +x /usr/local/bin/mkcert; fi; \
elif [[ "$$OSTYPE" == "darwin"* ]]; then \
BREW_LIST=$$(brew ls --formula); \
if [[ ! $$BREW_LIST == *"mkcert"* ]]; then brew install mkcert; fi; \
if [[ ! $$BREW_LIST == *"nss"* ]]; then brew install nss; fi; \
fi;
mkcert -install > /dev/null
.create-certificate:
echo "$(EMOJI_secure) Creating SSL certificates for dinghy http proxy"
mkdir -p $(HOME)/.dinghy/certs/
PROJECT=$$(echo "$${PWD##*/}" | tr -d '.'); \
if [[ ! -f $(HOME)/.dinghy/certs/$$PROJECT.docker.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/$$PROJECT.docker.crt -key-file $(HOME)/.dinghy/certs/$$PROJECT.docker.key "*.$$PROJECT.docker"; fi;
if [[ ! -f $(HOME)/.dinghy/certs/${HOST_LOCAL}.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/${HOST_LOCAL}.crt -key-file $(HOME)/.dinghy/certs/${HOST_LOCAL}.key ${HOST_LOCAL}; fi;
if [[ ! -f $(HOME)/.dinghy/certs/${HOST_FOREIGN}.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/${HOST_FOREIGN}.crt -key-file $(HOME)/.dinghy/certs/${HOST_FOREIGN}.key ${HOST_FOREIGN}; fi;
if [[ ! -f $(HOME)/.dinghy/certs/${MAIL_HOST}.key ]]; then mkcert -cert-file $(HOME)/.dinghy/certs/${MAIL_HOST}.crt -key-file $(HOME)/.dinghy/certs/${MAIL_HOST}.key ${MAIL_HOST}; fi;
restore: mysql-restore fileadmin-restore
## Restores the database from the dump files in SQLDUMPSDIR
mysql-restore: .mysql-wait
echo "$(EMOJI_robot) Restoring the local database"
docker compose exec mysql bash -c 'cat $(SQLDUMPSDIR)/db_local.sql | mysql --default-character-set=utf8 -u$(MYSQL_USER) -p$(MYSQL_PASSWORD) local'
echo "$(EMOJI_robot) Restoring the foreign database"
docker compose exec mysql bash -c 'cat $(SQLDUMPSDIR)/db_foreign.sql | mysql --default-character-set=utf8 -u$(MYSQL_USER) -p$(MYSQL_PASSWORD) foreign'
## Restores the fileadmin from .project/data/fileadmin
fileadmin-restore:
echo "$(EMOJI_robot) Restoring the fileadmin"
rsync -a --delete .project/data/fileadmin/local/ Build/local/public/fileadmin/
rsync -a --delete .project/data/fileadmin/foreign/ Build/foreign/public/fileadmin/
## Create dumps of local and foreign database in dir .project/data/dumps
dump-dbs: dump-local-database dump-foreign-database
dump-local-database: .mysql-wait
echo "$(EMOJI_robot) Dumping the local database"
docker compose exec local-php vendor/bin/mysql-loader dump -r -Hmysql -uroot -proot -Dlocal -f/.project/data/dumps/local/ -xcache_ -xindex_ -xtx_styleguide_ -xbackend_layout -xbe_dashboards -xbe_sessions -xfe_sessions -xsys_file_processedfile -xsys_history -xsys_http_report -xsys_lockedrecords -xsys_log -xsys_messenger_messages -xsys_refindex -xtx_in2code_ -xtx_in2publish_notification -xtx_in2publish_wfpn_demand -xtx_in2publishcore_ -xtx_solr_ -Q"sys_registry:entry_namespace != 'core' AND entry_key != 'formProtectionSessionToken'"
dump-foreign-database: .mysql-wait
echo "$(EMOJI_robot) Dumping the foreign database"
docker compose exec local-php vendor/bin/mysql-loader dump -r -Hmysql -uroot -proot -Dforeign -f/.project/data/dumps/foreign/ -xcache_ -xindex_ -xtx_styleguide_ -xbackend_layout -xbe_dashboards -xbe_sessions -xfe_sessions -xsys_file_processedfile -xsys_history -xsys_http_report -xsys_lockedrecords -xsys_log -xsys_messenger_messages -xsys_refindex -xtx_in2code_ -xtx_in2publish_notification -xtx_in2publish_wfpn_demand -xtx_in2publishcore_ -xtx_solr_ -Q"sys_registry:entry_namespace != 'core' AND entry_key != 'formProtectionSessionToken'"
unit:
docker compose exec local-php vendor/bin/phpunit -c /app/phpunit.unit.xml
functional:
docker compose exec local-php vendor/bin/phpunit -c /app/phpunit.functional.xml
acceptance: typo3-clearcache typo3-rebuild-caches
docker compose exec local-php vendor/bin/phpunit -c /app/phpunit.browser.xml
## Run single acceptance test
acceptance-test:
@if [ -z "$(name)" ]; then \
echo "Usage: make acceptance-test name=TestClassName [method=testMethodName]"; \
echo "Example: make acceptance-test name=PublishFilesModuleTest"; \
echo "Example: make acceptance-test name=PublishFilesModuleTest method=testNewlyUploadedFileCanBePublished"; \
exit 1; \
fi
@if [ -n "$(method)" ]; then \
echo "Running test method $(method) in $(name)"; \
docker compose exec local-php vendor/bin/phpunit -c /app/phpunit.browser.xml --filter "$(name)::$(method)"; \
else \
echo "Running all test methods in $(name)"; \
docker compose exec local-php vendor/bin/phpunit -c /app/phpunit.browser.xml --filter "$(name)"; \
fi
## Run all Playwright tests (headless) - LOCAL
playwright:
npx playwright test $(FILE)
## Open Playwright UI mode - LOCAL
playwright-ui:
npx playwright test --ui $(FILE)
## Open the last Playwright HTML report
playwright-report:
npx playwright show-report
## Run all Playwright tests in headed mode (watch) - LOCAL
playwright-watch:
npx playwright test --headed $(FILE)
## Run Playwright tests in debug mode - LOCAL
playwright-debug:
npx playwright test --debug $(FILE)
## Run Playwright tests in Docker (headless) - PLATFORM INDEPENDENT
playwright-docker:
docker compose exec -e CI=1 playwright npx playwright test
## Run Playwright tests in Docker with specific file - PLATFORM INDEPENDENT
playwright-docker-file:
@if [ -z "$(FILE)" ]; then \
echo "Usage: make playwright-docker-file FILE=<test-file>"; \
echo "Example: make playwright-docker-file FILE=Tests/Playwright/modules/PublishOverview/publish-changed-content.spec.ts"; \
exit 1; \
fi
docker compose exec -e CI=1 playwright npx playwright test $(FILE)
## Show Playwright report from Docker tests
playwright-docker-report:
docker compose exec playwright npx playwright show-report
setup-qa:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.1-fpm phive install
qa: qa-php-cs-fixer qa-php-code-sniffer qa-php-mess-detector
qa-php-cs-fixer:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.2-fpm .project/phars/php-cs-fixer check --config=.project/qa/php-cs-fixer.php --diff
fix-php-cs-fixer:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.2-fpm .project/phars/php-cs-fixer fix --config=.project/qa/php-cs-fixer.php --diff
qa-php-code-sniffer:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.2-fpm .project/phars/phpcs --basepath="$$PWD" --standard=.project/qa/phpcs.xml -s
fix-php-code-sniffer:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.2-fpm .project/phars/phpcbf --basepath="$$PWD" --standard=.project/qa/phpcs.xml
qa-php-mess-detector:
docker run --rm -w "$$PWD" -v "$$PWD":"$$PWD" -v "$$HOME"/.phive/:/tmp/phive/ in2code/php:8.2-fpm .project/phars/phpmd Classes ansi .project/qa/phpmd.xml
## Clears TYPO3 caches via typo3-console
typo3-clearcache:
echo "$(EMOJI_broom) Clearing TYPO3 caches"
docker compose exec -u app local-php ./vendor/bin/typo3 cache:flush
docker compose exec -u app foreign-php ./vendor/bin/typo3 cache:flush
## Hard-deletes all caches (including DI) and rebuilds them on the fly
typo3-rebuild-caches:
echo "$(EMOJI_broom) clearing DI cache on local"
rm -rf Build/local/var/cache/code/
echo "$(EMOJI_hot_face) rebuilding DI cache on local"
docker compose exec local-php ./vendor/bin/typo3 help > /dev/null
echo "$(EMOJI_broom) clearing DI cache on foreign"
rm -rf Build/foreign/var/cache/code/
echo "$(EMOJI_hot_face) rebuilding DI cache on foreign"
docker compose exec foreign-php ./vendor/bin/typo3 help > /dev/null
## Starts composer-update
composer-update:
echo "$(EMOJI_package) updating composer dependencies"
docker compose exec -u app local-php composer update -W
docker compose exec -u app foreign-php composer update -W
## Starts composer-install
composer-install:
echo "$(EMOJI_package) Installing composer dependencies"
docker compose exec -u app local-php composer install
docker compose exec -u app foreign-php composer install
## Install all phars required with phive
.phive-install:
mkdir -p ~/.phive/
docker run --rm -it -u1000:1000 -v "$$PWD":/app -v $$HOME/.phive/:/tmp/phive/ -e PHIVE_HOME=/tmp/phive/ in2code/php:7.4-fpm phive install
## Print Project URIs
urls:
echo "$(EMOJI_telescope) Project URLs:"; \
echo ''; \
printf " %-17s %s\n" "Local Frontend:" "https://$(HOST_LOCAL)/"; \
printf " %-17s %s\n" "Local Backend:" "https://$(HOST_LOCAL)/typo3/"; \
printf " %-17s %s\n" "Foreign Frontend:" "https://$(HOST_FOREIGN)/"; \
printf " %-17s %s\n" "Foreign Backend:" "https://$(HOST_FOREIGN)/typo3/"; \
include .env