-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM php:8.4 | ||
|
||
# git needed for Infection | ||
RUN apt-get update \ | ||
&& apt-get -y install --no-install-recommends \ | ||
git | ||
|
||
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ | ||
|
||
RUN install-php-extensions @composer pcov | ||
|
||
# Mapping the host user to the docker one ensure | ||
# files have the same permissions | ||
ARG USER_ID | ||
ARG GROUP_ID | ||
|
||
RUN groupadd --gid ${GROUP_ID} code \ | ||
&& useradd --create-home --shell /bin/bash --uid ${USER_ID} --gid code code | ||
|
||
USER code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
ifdef CI | ||
DOCKER_PHP_EXEC := | ||
else | ||
DOCKER_PHP_EXEC := docker compose run --rm php | ||
endif | ||
PARALLELISM := $(shell nproc) | ||
|
||
.PHONY: all | ||
all: install phpcbf phpcs phpstan phpunit infection phpbench | ||
all: phpcbf phpcs phpstan phpunit infection phpbench | ||
|
||
.PHONY: install | ||
install: vendor/composer/installed.json | ||
.env: /etc/passwd /etc/group Makefile | ||
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env | ||
|
||
vendor/composer/installed.json: composer.json composer.lock | ||
@composer install $(INSTALL_FLAGS) | ||
vendor/composer/installed.json: composer.json composer.lock .env docker-compose.yml Dockerfile | ||
@$(DOCKER_PHP_EXEC) composer install $(INSTALL_FLAGS) | ||
@touch -c composer.json composer.lock vendor/composer/installed.json | ||
|
||
.PHONY: phpunit | ||
phpunit: | ||
@php -d assert.exception=1 -d zend.assertions=1 vendor/bin/phpunit $(PHPUNIT_FLAGS) | ||
phpunit: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) php -d assert.exception=1 -d zend.assertions=1 vendor/bin/phpunit $(PHPUNIT_FLAGS) | ||
|
||
.PHONY: infection | ||
infection: | ||
@php -d assert.exception=1 -d zend.assertions=1 -d xdebug.mode=coverage vendor/bin/phpunit --coverage-xml=build/coverage-xml --log-junit=build/junit.xml $(PHPUNIT_FLAGS) | ||
@php -d assert.exception=1 -d zend.assertions=1 vendor/bin/infection -v -s --threads=$(PARALLELISM) --coverage=build --skip-initial-tests $(INFECTION_FLAGS) | ||
infection: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) php -d assert.exception=1 -d zend.assertions=1 -d xdebug.mode=coverage vendor/bin/phpunit --coverage-xml=build/coverage-xml --log-junit=build/junit.xml $(PHPUNIT_FLAGS) | ||
@$(DOCKER_PHP_EXEC) php -d assert.exception=1 -d zend.assertions=1 vendor/bin/infection -v -s --threads=$(PARALLELISM) --coverage=build --skip-initial-tests $(INFECTION_FLAGS) | ||
|
||
.PHONY: phpcbf | ||
phpcbf: | ||
@vendor/bin/phpcbf --parallel=$(PARALLELISM) || true | ||
phpcbf: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) vendor/bin/phpcbf --parallel=$(PARALLELISM) || true | ||
|
||
.PHONY: phpcs | ||
phpcs: | ||
@vendor/bin/phpcs --parallel=$(PARALLELISM) $(PHPCS_FLAGS) | ||
phpcs: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) vendor/bin/phpcs --parallel=$(PARALLELISM) $(PHPCS_FLAGS) | ||
|
||
.PHONY: phpstan | ||
phpstan: | ||
@php -d xdebug.mode=off vendor/bin/phpstan analyse --memory-limit=-1 | ||
phpstan: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) php -d xdebug.mode=off vendor/bin/phpstan analyse --memory-limit=-1 | ||
|
||
ifndef PHPBENCH_REPORT | ||
override PHPBENCH_REPORT = aggregate | ||
endif | ||
|
||
.PHONY: phpbench | ||
phpbench: | ||
@vendor/bin/phpbench run -l dots --retry-threshold=5 --report=$(PHPBENCH_REPORT) $(PHPBENCH_FLAGS) | ||
phpbench: vendor/composer/installed.json | ||
@$(DOCKER_PHP_EXEC) vendor/bin/phpbench run -l dots --retry-threshold=5 --report=$(PHPBENCH_REPORT) $(PHPBENCH_FLAGS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
services: | ||
php: | ||
build: | ||
context: . | ||
args: | ||
USER_ID: ${USER_ID} | ||
GROUP_ID: ${GROUP_ID} | ||
# Same paths mean stack traces from docker are usable in host too | ||
volumes: | ||
- .:${PWD} | ||
working_dir: ${PWD} |