Skip to content

Commit d10f225

Browse files
IN-1730 - Dockerize test runner and remove composer.phar
1 parent e2bdd7e commit d10f225

File tree

7 files changed

+65
-77
lines changed

7 files changed

+65
-77
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[Makefile]
12+
indent_style = tab

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/vendor/
22
.idea
3+
composer.lock

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ARG PHP_VERSION=8.2
2+
FROM php:$PHP_VERSION-cli-alpine
3+
4+
RUN apk add git
5+
6+
COPY --from=composer /usr/bin/composer /usr/bin/composer
7+

Makefile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
1-
PHP_BIN=php
2-
COMPOSER_BIN=$(PHP_BIN) composer.phar
1+
PHP_IMAGE_TAG=flyeralarm/php-code-valiator-cli:$(PHP_VERSION)
2+
PHP_VERSION?=8.2
3+
4+
PHP_BIN=$(RUNNER) php
5+
COMPOSER_BIN=$(RUNNER) /usr/bin/composer
6+
7+
RUNNER=docker run --init -it --rm -v "$(PWD):/app" -w /app $(PHP_IMAGE_TAG)
8+
39

410
# ---------------------------------------------
511

612
# make
713
.DEFAULT_GOAL := install
814

15+
.PHONY: build
16+
build:
17+
docker image build --tag $(PHP_IMAGE_TAG) --build-arg PHP_VERSION=$(PHP_VERSION) .
18+
$(RUNNER) sh -c "php --version && which composer && composer --version"
19+
20+
.PHONY: install
921
install:
1022
$(COMPOSER_BIN) install
1123

24+
.PHONY: update
25+
update:
26+
rm -rf vendor/ composer.lock
27+
$(COMPOSER_BIN) update
28+
29+
.PHONY: sniff
1230
sniff:
1331
$(PHP_BIN) vendor/bin/phpcs -w -p -s --standard=ruleset.xml --ignore="tests/*not-allowed*" custom-standards/ tests/
1432

33+
.PHONY: sniff-fix
1534
sniff-fix:
1635
$(PHP_BIN) vendor/bin/phpcbf -w -p -s --standard=ruleset.xml --ignore="tests/*not-allowed*" custom-standards/ tests/
1736

37+
.PHONY: test
1838
test:
1939
$(PHP_BIN) tests/runner.php
40+
41+
.PHONY: test-all
42+
test-all:
43+
PHP_VERSION=8.2 $(MAKE) build update sniff test
44+
PHP_VERSION=8.1 $(MAKE) build update sniff test
45+
PHP_VERSION=7.4 $(MAKE) build update sniff test
46+
PHP_VERSION=7.3 $(MAKE) build update sniff test

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ To test ruleset run command:
3737
make test
3838
```
3939

40+
As test runner is dockerized we can test with different PHP versions:
41+
```shell
42+
PHP_VERSION=8.2 make test
43+
```
44+
45+
or all at once:
46+
```shell
47+
make test-all
48+
```
49+
4050

4151
## Embed into *your* project
4252

@@ -53,6 +63,12 @@ test:
5363
vendor/bin/phpcs -w -p -s --standard=vendor/flyeralarm/php-code-validator/ruleset.xml src/ tests/
5464
```
5565

66+
or in shorter version by using code validator binary which already use flyeralarm as default standard:
67+
```make
68+
test:
69+
vendor/bin/php-code-validator src/ tests/
70+
```
71+
5672

5773
### Add project specific rules
5874

composer.lock

Lines changed: 0 additions & 75 deletions
This file was deleted.

composer.phar

-2.67 MB
Binary file not shown.

0 commit comments

Comments
 (0)