-
-
Notifications
You must be signed in to change notification settings - Fork 604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local build: rely only on docker
#1094
Open
Slamdunk
wants to merge
1
commit into
lcobucci:5.5.x
Choose a base branch
from
Slamdunk:docker_local_build
base: 5.5.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need to remember to run
make install
, just addvendor/composer/installed.json
as a prerequisit for every other target