Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
[{*.yml,*.yaml}]
indent_size = 2
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@ vendor
# composer lock files
composer.lock

# PHPUnit
.phpunit.result.cache
coverage.html

# PHP CS Fixer
/.php-cs-fixer.cache
/.php-cs-fixer.php
# local environment variables
/.env.local
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
return ConfigBuilder::build()
->setRiskyAllowed(true)
->setParallelConfig(ParallelConfigFactory::detect())
->setCacheFile(__DIR__ . '/runtime/cache/.php-cs-fixer.cache')
->setRules([
'@Yiisoft/Core' => true,
'@Yiisoft/Core:risky' => true,
Expand Down
62 changes: 39 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,31 +1,47 @@
export COMPOSE_PROJECT_NAME=yii-queue
.DEFAULT_GOAL := help

help: ## Display help information
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
PHP_VERSION ?= 8.5
-include .env.local

build: ## Build an image from a docker-compose file. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml up -d --build
DOCKER_RUN := docker run --rm -it \
--init \
--user $(shell id -u):$(shell id -g) \
--env YII_INSIDE_CONTAINER=true \
--env COMPOSER_CACHE_DIR=/app/runtime/cache/composer \
--env HISTFILE=/app/runtime/.docker_shell_history \
--workdir /app \
--volume $(CURDIR):/app \
ghcr.io/yiisoft-contrib/php-dev:$(PHP_VERSION)

down: ## Stop and remove containers, networks
docker-compose -f tests/docker/docker-compose.yml down
RUN := $(if $(YII_INSIDE_CONTAINER),,$(DOCKER_RUN))

sh: ## Enter the container with the application
docker exec -it queue-php sh
shell: ## Open a shell inside the container.
@if [ -n "$$YII_INSIDE_CONTAINER" ]; then \
echo "You are already inside a container."; \
exit 1; \
fi
$(RUN) bash

test: ## Run tests. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml build --pull queue-php
PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php vendor/bin/phpunit --debug
make down
composer: ## Run Composer command: `make composer ARGS=start`
$(RUN) composer $(ARGS)

mutation-test: ## Run mutation tests. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml build --pull queue-php
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
make down
test: phpunit
phpunit: ## [test] Run PHPUnit tests: `make phpunit ARGS="--filter=TestName"`
$(RUN) ./vendor/bin/phpunit $(ARGS)

coverage: ## Run code coverage. Params: {{ v=8.1 }}. Default latest PHP 8.1
PHP_VERSION=$(filter-out $@,$(v)) docker-compose -f tests/docker/docker-compose.yml run queue-php vendor/bin/phpunit --coverage-clover coverage.xml
make down
mutation: infection
infection: ## [infection] Run mutation testing with Infection.
$(RUN) ./vendor/bin/roave-infection-static-analysis-plugin --threads=max --ignore-msi-with-no-mutations --only-covered

static-analyze: ## Run code static analyze. Params: {{ v=8.1 }}. Default latest PHP 8.1
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)
make down
psalm: ## Run Psalm static analysis: `make psalm ARGS="--show-info=true"`
$(RUN) ./vendor/bin/psalm $(if $(ARGS),$(ARGS),--php-version=$(PHP_VERSION))

cs-fix: php-cs-fixer
php-cs-fixer: ## [cs-fix] Fix code style with PHP-CS-Fixer: `make php-cs-fixer ARGS="--dry-run"`
$(RUN) ./vendor/bin/php-cs-fixer fix $(ARGS)

coverage: ## Generate code coverage report in HTML
$(RUN) ./vendor/bin/phpunit --coverage-html=runtime/coverage

help: ## This help.
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
6 changes: 0 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"phpunit/phpunit": "^10.5.45",
"rector/rector": "^2.0.11",
"roave/infection-static-analysis-plugin": "^1.35",
"spatie/phpunit-watcher": "^1.24",
"vimeo/psalm": "^5.26.1 || ^6.10",
"yiisoft/code-style": "^1.0",
"yiisoft/test-support": "^3.0.2",
Expand Down Expand Up @@ -92,10 +91,5 @@
"composer/package-versions-deprecated": true,
"yiisoft/config": false
}
},
"scripts": {
"cs-fix": "php-cs-fixer fix",
"test": "phpunit --testdox --no-interaction",
"test-watch": "phpunit-watcher watch"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheDirectory="vendor/.phpunit.cache"
cacheDirectory="runtime/cache/phpunit"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="true"
beStrictAboutOutputDuringTests="true"
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
cacheDirectory="vendor/.psalm-cache"
cacheDirectory="runtime/cache/psalm"
>
<projectFiles>
<directory name="src" />
Expand Down
2 changes: 2 additions & 0 deletions runtime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
.gitignore
13 changes: 0 additions & 13 deletions tests/docker/docker-compose.yml

This file was deleted.

19 changes: 0 additions & 19 deletions tests/docker/php/Dockerfile

This file was deleted.

9 changes: 0 additions & 9 deletions tests/docker/php/entrypoint.sh

This file was deleted.

2 changes: 0 additions & 2 deletions tests/docker/php/php.ini

This file was deleted.

Loading