Skip to content
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 #32

Merged
merged 1 commit into from
Jun 11, 2024
Merged
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: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/Dockerfile export-ignore
/docker-compose.yml export-ignore
/Makefile export-ignore
/composer-require-checker.json export-ignore
/phpstan-baseline.neon export-ignore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.phpunit.cache/
/vendor/
/coverage/
/.env
/.php-cs-fixer.cache
/.phpunit.result.cache
/composer.lock
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:8.3

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

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
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
CSFIX_PHP_BIN=PHP_CS_FIXER_IGNORE_ENV=1 php8.2
PHP_BIN=php8.2 -d zend.assertions=1 -d error_reporting=-1
COMPOSER_BIN=$(shell command -v composer)
DOCKER_PHP_EXEC := docker compose run php
PHP_BIN=php -d zend.assertions=1

all: csfix static-analysis test
@echo "Done."

vendor: composer.json
$(PHP_BIN) $(COMPOSER_BIN) update
$(PHP_BIN) $(COMPOSER_BIN) bump
touch vendor
.env: /etc/passwd /etc/group Makefile
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env

vendor: .env docker-compose.yml Dockerfile composer.json
docker compose build --pull
$(DOCKER_PHP_EXEC) composer update
$(DOCKER_PHP_EXEC) composer bump
touch --no-create $@

.PHONY: csfix
csfix: vendor
$(CSFIX_PHP_BIN) vendor/bin/php-cs-fixer fix -v
$(DOCKER_PHP_EXEC) vendor/bin/php-cs-fixer fix -v

.PHONY: static-analysis
static-analysis: vendor
$(PHP_BIN) vendor/bin/phpstan analyse $(PHPSTAN_ARGS)
$(DOCKER_PHP_EXEC) $(PHP_BIN) vendor/bin/phpstan analyse --memory-limit=512M $(PHPSTAN_ARGS)

.PHONY: test
test: vendor
$(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS)
$(DOCKER_PHP_EXEC) $(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS)

.PHONY: clean
clean:
git clean -dfX
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"php": "~8.2.0 || ~8.3.0",
"ext-mbstring": "*",
"ext-tokenizer": "*",
"friendsofphp/php-cs-fixer": "^3.51.0"
"friendsofphp/php-cs-fixer": "^3.58.1"
},
"require-dev": {
"phpstan/phpstan": "^1.10.62",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpunit/phpunit": "^11.0.6"
"phpstan/phpstan": "^1.11.4",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpunit/phpunit": "^11.2.1"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
php:
build:
context: .
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
volumes:
- .:${PWD}
working_dir: ${PWD}
1 change: 0 additions & 1 deletion lib/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ final class Config extends PhpCsFixerConfig
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
'not_operator_with_space' => false,
'not_operator_with_successor_space' => true,
'nullable_type_declaration_for_default_null_value' => true,
'ordered_class_elements' => ['order' => ['use_trait', 'constant_public', 'constant_protected', 'constant_private', 'property', 'construct', 'destruct', 'magic', 'phpunit', 'method']],
'ordered_interfaces' => true,
'php_unit_data_provider_static' => true,
Expand Down
Loading