Skip to content

Commit d914843

Browse files
authored
Merge pull request #186 from alma/fix/pre-commit
Fix/pre commit
2 parents c933e32 + ab05e4f commit d914843

File tree

4 files changed

+54
-5
lines changed

4 files changed

+54
-5
lines changed

Taskfile.php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 3
22

33
vars:
44
# Required variables
5-
PHP_VERSION: '{{ .PHP_VERSION }}'
5+
PHP_VERSION: '{{ .PHP_VERSION}}'
66
PHPUNIT_VERSION: '{{ .PHPUNIT_VERSION }}'
77
# Defaulted variable
88
COMPOSER_VERSION: '{{ .COMPOSER_VERSION | default "2" }}'

Taskfile.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,31 +87,43 @@ tasks:
8787
cmds:
8888
- pre-commit install --hook-type pre-commit --hook-type commit-msg
8989

90+
lint:build:
91+
desc: Build lint container (php-cs-fixer)
92+
cmds:
93+
- docker build -t lint:ps -f lint.Dockerfile .
94+
9095
lint:
9196
desc: Lint the php code
9297
deps:
93-
- 8.3:docker:build
98+
- lint:build
9499
cmds:
95100
- docker compose run --rm -T php composer exec phpcs -- src/
96101

97102
lint:fix:
98103
desc: Lint fix the php code
99104
deps:
100-
- 8.3:docker:build
105+
- lint:build
101106
cmds:
102107
- docker compose run --rm -T php composer exec phpcbf -- src/ tests/
103108

109+
php-compatibility:build:
110+
desc: Build php-compatibility container (phpcs)
111+
cmds:
112+
- docker build -t php-compatibility:ps -f php-compatibility.Dockerfile .
113+
104114
dist:
105115
desc: Build zip dist package using Docker
106116
deps:
107-
- 8.3:docker:build
117+
- php-compatibility:build
108118
cmds:
109119
- docker compose run --rm php ./scripts/build.sh
110120

111121
php-compatibility:
112122
desc: Check compatibility code
123+
deps:
124+
- php-compatibility:build
113125
cmds:
114-
- docker compose run --rm -T php composer exec phpcs -- -p src --standard=PHPCompatibility -s --runtime-set testVersion 5.6-8.1 --ignore=\*/vendor/\*
126+
- docker compose run --rm -T php composer exec phpcs -- -p src --standard=PHPCompatibility -s --runtime-set testVersion 5.6-8.3 --ignore=\*/vendor/\*
115127

116128
gh-cli:
117129
internal: true

lint.Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ARG PHP_IMG_TAG=5.6-alpine
2+
FROM php:${PHP_IMG_TAG} AS production
3+
4+
WORKDIR /composer
5+
6+
RUN apk add --no-cache php-tokenizer
7+
RUN apk add --no-cache composer
8+
RUN composer self-update
9+
RUN composer init -n --name="alma/php-cs" --description="php-cs" --type="library"
10+
11+
# PHP CS Fixer
12+
RUN composer require friendsofphp/php-cs-fixer --no-interaction
13+
14+
WORKDIR /app
15+
16+
ENTRYPOINT ["/composer/vendor/bin/php-cs-fixer"]
17+
CMD ["--version"]

php-compatibility.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ARG PHP_IMG_TAG=5.6-alpine
2+
FROM php:${PHP_IMG_TAG} AS production
3+
4+
WORKDIR /composer
5+
6+
RUN apk add --no-cache composer
7+
RUN composer self-update
8+
RUN composer init -n --name="alma/php-cs" --description="php-cs" --type="library"
9+
10+
RUN composer config --no-interaction --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
11+
RUN composer require squizlabs/php_codesniffer --no-interaction
12+
RUN composer require phpcompatibility/php-compatibility --no-interaction
13+
RUN composer require phpcompatibility/phpcompatibility-paragonie:"*" --no-interaction
14+
15+
RUN /composer/vendor/bin/phpcs --config-set installed_paths /composer/vendor/escapestudios/symfony2-coding-standard,/composer/vendor/squizlabs/php_codesniffer,/composer/vendor/phpcompatibility/php-compatibility,/composer/vendor/phpcompatibility/phpcompatibility-paragonie
16+
17+
WORKDIR /app
18+
19+
ENTRYPOINT ["/composer/vendor/bin/phpcs"]
20+
CMD ["--version"]

0 commit comments

Comments
 (0)