Skip to content

Commit

Permalink
Merge pull request #156 from woocommerce/24-03/faster-phpcs
Browse files Browse the repository at this point in the history
Port Fast PHPCS PR to CLI
  • Loading branch information
Luc45 authored Mar 28, 2024
2 parents 883a40b + f2946bb commit 22c41a6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ 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 > /dev/null 2>&1 || docker build --build-arg CI=${CI} -t qit-cli-php-xdebug ./_build/docker/php83
@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:/usr/local/etc/php/conf.d/" \
-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 \
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

Expand Down Expand Up @@ -56,6 +56,7 @@ 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
$(call execPhpAlpine,/app/src/vendor/bin/phpcs /app/src/qit-cli.php /app/src/src -s --standard=/app/src/.phpcs.xml.dist)

phpstan:
Expand Down
5 changes: 4 additions & 1 deletion _build/docker/php83/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ ARG CI

RUN apt-get update \
&& apt-get install -y libzip-dev \
&& docker-php-ext-install zip
&& docker-php-ext-install zip \
&& docker-php-ext-enable zip \
&& docker-php-ext-install pcntl \
&& docker-php-ext-enable pcntl

# Install Xdebug only if not in CI environment
RUN if [ "$CI" != "true" ]; then \
Expand Down
1 change: 0 additions & 1 deletion _build/docker/php83/ini/xdebug.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
zend_extension=xdebug.so
xdebug.client_host = host.docker.internal
xdebug.client_port = 9003
xdebug.output_dir = /app/_build/docker/php83/xdebug/output
Expand Down
2 changes: 0 additions & 2 deletions _build/docker/php83/ini/zip.ini

This file was deleted.

2 changes: 1 addition & 1 deletion src/.phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<arg value="sp"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="8"/>
<arg name="parallel" value="16"/>

<config name="testVersion" value="7.2-"/>
<rule ref="PHPCompatibility"/>
Expand Down

0 comments on commit 22c41a6

Please sign in to comment.