diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..2fe0ce0 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index cc486ff..b06900f 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7da55d --- /dev/null +++ b/Dockerfile @@ -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 + diff --git a/Makefile b/Makefile index 135d4ec..af01ab3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 8d46bb4..87ea657 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/composer.lock b/composer.lock index d845819..6f80a7f 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.7.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, "require": { @@ -53,14 +53,15 @@ "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "time": "2023-02-22T23:07:41+00:00" } ], "packages-dev": [], diff --git a/composer.phar b/composer.phar deleted file mode 100644 index a3a5d90..0000000 Binary files a/composer.phar and /dev/null differ