Skip to content
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
9 changes: 9 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ permissions:
jobs:
build:

strategy:
matrix:
version: [7.3, 7.4, 8.0, 8.1, 8.2]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.version }}

- name: Versions
run: php --version && composer --version

Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ARG PHP_VERSION=8.2
FROM php:$PHP_VERSION-cli-alpine

RUN apk add git

COPY --from=composer /usr/bin/composer /usr/bin/composer

31 changes: 29 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
PHP_BIN=php
COMPOSER_BIN=$(PHP_BIN) composer.phar
PHP_IMAGE_TAG=flyeralarm/php-code-valiator-cli:$(PHP_VERSION)
PHP_VERSION?=8.2

PHP_BIN=$(RUNNER) php
COMPOSER_BIN=$(RUNNER) /usr/bin/composer

RUNNER=docker run --init -it --rm -v "$(PWD):/app" -w /app $(PHP_IMAGE_TAG)


# ---------------------------------------------

# make
.DEFAULT_GOAL := install

.PHONY: build
build:
docker image build --tag $(PHP_IMAGE_TAG) --build-arg PHP_VERSION=$(PHP_VERSION) .
$(RUNNER) sh -c "php --version && which composer && composer --version"

.PHONY: install
install:
$(COMPOSER_BIN) install

.PHONY: update
update:
rm -rf vendor/ composer.lock
$(COMPOSER_BIN) update

.PHONY: sniff
sniff:
$(PHP_BIN) vendor/bin/phpcs -w -p -s --standard=ruleset.xml --ignore="tests/*not-allowed*" custom-standards/ tests/

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

.PHONY: test
test:
$(PHP_BIN) tests/runner.php

.PHONY: test-all
test-all:
PHP_VERSION=8.2 $(MAKE) build update sniff test
PHP_VERSION=8.1 $(MAKE) build update sniff test
PHP_VERSION=7.4 $(MAKE) build update sniff test
PHP_VERSION=7.3 $(MAKE) build update sniff test
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ To test ruleset run command:
make test
```

As test runner is dockerized we can test with different PHP versions:
```shell
PHP_VERSION=8.2 make test
```

or all at once:
```shell
make test-all
```


## Embed into *your* project

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

or in shorter version by using code validator binary which already use flyeralarm as default standard:
```make
test:
vendor/bin/php-code-validator src/ tests/
```


### Add project specific rules

Expand Down
13 changes: 7 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed composer.phar
Binary file not shown.