|
1 | | -export COMPOSE_PROJECT_NAME=yii-queue |
| 1 | +.DEFAULT_GOAL := help |
2 | 2 |
|
3 | | -help: ## Display help information |
4 | | - @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' |
| 3 | +PHP_VERSION ?= 8.5 |
| 4 | +-include .env.local |
5 | 5 |
|
6 | | -build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1 |
7 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml up -d --build |
| 6 | +DOCKER_RUN := docker run --rm -it \ |
| 7 | + --init \ |
| 8 | + --user $(shell id -u):$(shell id -g) \ |
| 9 | + --env YII_INSIDE_CONTAINER=true \ |
| 10 | + --env COMPOSER_CACHE_DIR=/app/runtime/cache/composer \ |
| 11 | + --env HISTFILE=/app/runtime/.docker_shell_history \ |
| 12 | + --workdir /app \ |
| 13 | + --volume $(CURDIR):/app \ |
| 14 | + ghcr.io/yiisoft-contrib/php-dev:$(PHP_VERSION) |
8 | 15 |
|
9 | | -down: ## Stop and remove containers, networks |
10 | | - docker-compose -f tests/docker/docker-compose.yml down |
| 16 | +RUN := $(if $(YII_INSIDE_CONTAINER),,$(DOCKER_RUN)) |
11 | 17 |
|
12 | | -sh: ## Enter the container with the application |
13 | | - docker exec -it queue-php sh |
| 18 | +shell: ## Open a shell inside the container. |
| 19 | + @if [ -n "$$YII_INSIDE_CONTAINER" ]; then \ |
| 20 | + echo "You are already inside a container."; \ |
| 21 | + exit 1; \ |
| 22 | + fi |
| 23 | + $(RUN) bash |
14 | 24 |
|
15 | | -test: ## Run tests. Params: {{ v=8.1 }}. Default latest PHP 8.1 |
16 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml build --pull queue-php |
17 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php vendor/bin/phpunit --debug |
18 | | - make down |
| 25 | +composer: ## Run Composer command: `make composer ARGS=start` |
| 26 | + $(RUN) composer $(ARGS) |
19 | 27 |
|
20 | | -mutation-test: ## Run mutation tests. Params: {{ v=8.1 }}. Default latest PHP 8.1 |
21 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml build --pull queue-php |
22 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php php -dpcov.enabled=1 -dpcov.directory=. vendor/bin/roave-infection-static-analysis-plugin -j2 --ignore-msi-with-no-mutations --only-covered |
23 | | - make down |
| 28 | +test: phpunit |
| 29 | +phpunit: ## [test] Run PHPUnit tests: `make phpunit ARGS="--filter=TestName"` |
| 30 | + $(RUN) ./vendor/bin/phpunit $(ARGS) |
24 | 31 |
|
25 | | -coverage: ## Run code coverage. Params: {{ v=8.1 }}. Default latest PHP 8.1 |
26 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php vendor/bin/phpunit --coverage-clover coverage.xml |
27 | | - make down |
| 32 | +mutation: infection |
| 33 | +infection: ## [infection] Run mutation testing with Infection. |
| 34 | + $(RUN) ./vendor/bin/roave-infection-static-analysis-plugin --threads=max --ignore-msi-with-no-mutations --only-covered |
28 | 35 |
|
29 | | -static-analyze: ## Run code static analyze. Params: {{ v=8.1 }}. Default latest PHP 8.1 |
30 | | - PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php vendor/bin/psalm --config=psalm.xml --shepherd --stats --php-version=$(v) |
31 | | - make down |
| 36 | +psalm: ## Run Psalm static analysis: `make psalm ARGS="--show-info=true"` |
| 37 | + $(RUN) ./vendor/bin/psalm $(if $(ARGS),$(ARGS),--php-version=$(PHP_VERSION)) |
| 38 | + |
| 39 | +cs-fix: php-cs-fixer |
| 40 | +php-cs-fixer: ## [cs-fix] Fix code style with PHP-CS-Fixer: `make php-cs-fixer ARGS="--dry-run"` |
| 41 | + $(RUN) ./vendor/bin/php-cs-fixer fix $(ARGS) |
| 42 | + |
| 43 | +coverage: ## Generate code coverage report in HTML |
| 44 | + $(RUN) ./vendor/bin/phpunit --coverage-html=runtime/coverage |
| 45 | + |
| 46 | +help: ## This help. |
| 47 | + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) |
0 commit comments