-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
82 lines (69 loc) · 2.68 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
##
# Variables.
#
# ROOT Set this to 1 to run the command as root.
##
ROOT ?= 0
DEBUG ?= 0
ARGS ?=
VERSION ?= qit_dev_build
ifeq (1, $(ROOT))
DOCKER_USER ?= "0:0"
else
DOCKER_USER ?= "$(shell id -u):$(shell id -g)"
endif
## Run a command inside an alpine PHP 8 CLI image.
## 1. Command to execute, eg: "./vendor/bin/phpcs" 2. Working dir (optional)
define execPhpAlpine
@docker image inspect qit-cli-php-xdebug-pcntl > /dev/null 2>&1 || docker build --build-arg CI=${CI} -t qit-cli-php-xdebug-pcntl ./_build/docker/php83
docker run --rm \
--user $(DOCKER_USER) \
-v "${PWD}:/app" \
-v "${PWD}/_build/docker/php83/ini/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini" \
--env QIT_HOME=/tmp \
--env PHP_IDE_CONFIG=serverName=qit_cli \
--workdir "$(2:=/)" \
--add-host host.docker.internal:host-gateway \
qit-cli-php-xdebug-pcntl \
bash -c "php -d xdebug.start_with_request=$(if $(filter 1,$(DEBUG)),yes,no) -d memory_limit=1G $(1)"
endef
watch:
@cd _build; php watch.php
# Build the Phar file of the CD Client.
build:
@cp -r src src-tmp
@COMPOSER_HOME_DIR=$$(composer config --global home); \
docker run --rm \
--volume ${PWD}/src-tmp:/app \
--volume $${COMPOSER_HOME_DIR}:/tmp \
--user "$(shell id -u):$(shell id -g)" \
composer \
install --no-dev --quiet --optimize-autoloader --ignore-platform-reqs
# Create a temporary configuration file with the specified VERSION
@sed "s/QIT_VERSION_REPLACE/$(VERSION)/g" ./_build/box.json.dist > ./_build/box.json
# Ensure the Docker image is built and run Box with the temporary configuration file
@docker images -q | grep qit-cli-box || docker build -t qit-cli-box ./_build/docker/box
@docker run --rm -v ${PWD}:${PWD} -w ${PWD} -u "$(shell id -u):$(shell id -g)" qit-cli-box ./_build/box.phar compile -c ./_build/box.json --no-parallel || rm -rf src-tmp
# Clean up the temporary directory and configuration file
@rm -rf src-tmp
@rm -f ./_build/box.json
tests:
$(MAKE) phpcs
$(MAKE) phpstan
$(MAKE) phpunit
$(MAKE) phan
phpcbf:
$(call execPhpAlpine,/app/src/vendor/bin/phpcbf /app/src/qit-cli.php /app/src/src -s --standard=/app/src/.phpcs.xml.dist)
phpcs:
$(MAKE) phpcbf || true
$(call execPhpAlpine,/app/src/vendor/bin/phpcs /app/src/qit-cli.php /app/src/src -s --standard=/app/src/.phpcs.xml.dist)
phpstan:
$(call execPhpAlpine,/app/src/vendor/bin/phpstan -vvv analyse -c /app/src/phpstan.neon)
phpunit:
$(call execPhpAlpine,/app/src/vendor/bin/phpunit -c /app/src/phpunit.xml.dist $(ARGS))
phan:
docker run --rm \
-v ${PWD}/src:/mnt/src \
-u "$$(id -u):$$(id -g)" \
phanphp/phan:latest $(ARGS)
# PS: To update Phan, run: docker image pull phanphp/phan:latest