Skip to content

Commit d728a7a

Browse files
authored
Local build: rely only on docker (#32)
1 parent 7e5216e commit d728a7a

File tree

7 files changed

+47
-15
lines changed

7 files changed

+47
-15
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
55
/.php-cs-fixer.php export-ignore
6+
/Dockerfile export-ignore
7+
/docker-compose.yml export-ignore
68
/Makefile export-ignore
79
/composer-require-checker.json export-ignore
810
/phpstan-baseline.neon export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.phpunit.cache/
33
/vendor/
44
/coverage/
5+
/.env
56
/.php-cs-fixer.cache
67
/.phpunit.result.cache
78
/composer.lock

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM php:8.3
2+
3+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
4+
5+
RUN install-php-extensions @composer pcov
6+
7+
ARG USER_ID
8+
ARG GROUP_ID
9+
10+
RUN groupadd --gid ${GROUP_ID} code \
11+
&& useradd --create-home --shell /bin/bash --uid ${USER_ID} --gid code code
12+
13+
USER code

Makefile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
CSFIX_PHP_BIN=PHP_CS_FIXER_IGNORE_ENV=1 php8.2
2-
PHP_BIN=php8.2 -d zend.assertions=1 -d error_reporting=-1
3-
COMPOSER_BIN=$(shell command -v composer)
1+
DOCKER_PHP_EXEC := docker compose run php
2+
PHP_BIN=php -d zend.assertions=1
43

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

8-
vendor: composer.json
9-
$(PHP_BIN) $(COMPOSER_BIN) update
10-
$(PHP_BIN) $(COMPOSER_BIN) bump
11-
touch vendor
7+
.env: /etc/passwd /etc/group Makefile
8+
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env
9+
10+
vendor: .env docker-compose.yml Dockerfile composer.json
11+
docker compose build --pull
12+
$(DOCKER_PHP_EXEC) composer update
13+
$(DOCKER_PHP_EXEC) composer bump
14+
touch --no-create $@
1215

1316
.PHONY: csfix
1417
csfix: vendor
15-
$(CSFIX_PHP_BIN) vendor/bin/php-cs-fixer fix -v
18+
$(DOCKER_PHP_EXEC) vendor/bin/php-cs-fixer fix -v
1619

1720
.PHONY: static-analysis
1821
static-analysis: vendor
19-
$(PHP_BIN) vendor/bin/phpstan analyse $(PHPSTAN_ARGS)
22+
$(DOCKER_PHP_EXEC) $(PHP_BIN) vendor/bin/phpstan analyse --memory-limit=512M $(PHPSTAN_ARGS)
2023

2124
.PHONY: test
2225
test: vendor
23-
$(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS)
26+
$(DOCKER_PHP_EXEC) $(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS)
27+
28+
.PHONY: clean
29+
clean:
30+
git clean -dfX

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
"php": "~8.2.0 || ~8.3.0",
1414
"ext-mbstring": "*",
1515
"ext-tokenizer": "*",
16-
"friendsofphp/php-cs-fixer": "^3.51.0"
16+
"friendsofphp/php-cs-fixer": "^3.58.1"
1717
},
1818
"require-dev": {
19-
"phpstan/phpstan": "^1.10.62",
20-
"phpstan/phpstan-phpunit": "^1.3.16",
21-
"phpunit/phpunit": "^11.0.6"
19+
"phpstan/phpstan": "^1.11.4",
20+
"phpstan/phpstan-phpunit": "^1.4.0",
21+
"phpunit/phpunit": "^11.2.1"
2222
},
2323
"autoload": {
2424
"psr-4": {

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
services:
2+
php:
3+
build:
4+
context: .
5+
args:
6+
USER_ID: ${USER_ID}
7+
GROUP_ID: ${GROUP_ID}
8+
volumes:
9+
- .:${PWD}
10+
working_dir: ${PWD}

lib/Config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ final class Config extends PhpCsFixerConfig
4545
'no_superfluous_phpdoc_tags' => ['allow_mixed' => true],
4646
'not_operator_with_space' => false,
4747
'not_operator_with_successor_space' => true,
48-
'nullable_type_declaration_for_default_null_value' => true,
4948
'ordered_class_elements' => ['order' => ['use_trait', 'constant_public', 'constant_protected', 'constant_private', 'property', 'construct', 'destruct', 'magic', 'phpunit', 'method']],
5049
'ordered_interfaces' => true,
5150
'php_unit_data_provider_static' => true,

0 commit comments

Comments
 (0)