diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e959921 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,23 @@ +name: "Tests" + +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + php: [8.2, 8.3] + + fail-fast: false + + name: PHP ${{matrix.php}} + + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - run: make ci diff --git a/.gitignore b/.gitignore index de4a392..9902d7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/bin /vendor /composer.lock diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7370b48 --- /dev/null +++ b/Makefile @@ -0,0 +1,42 @@ +.DEFAULT_GOAL := help + +help: + @printf "\033[33mUsage:\033[0m\n make [target] [arg=\"val\"...]\n\n\033[33mTargets:\033[0m\n" + @grep -E '^[-a-zA-Z0-9_\.\/]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' + +.PHONY: install +install: install-composer vendor ## Installs all project dependencies + +.PHONY: install-composer +install-composer: + @[ -f bin/composer ] \ + || (echo '> Installing composer...' \ + && php -r 'copy("https://getcomposer.org/installer", "composer-setup.php");' \ + && php -r 'if (hash_file("sha384", "composer-setup.php") === file_get_contents("https://composer.github.io/installer.sig")) { echo "Installer verified"; } else { echo "Installer corrupt"; unlink("composer-setup.php"); } echo PHP_EOL;' \ + && mkdir -p bin \ + && php composer-setup.php --install-dir=bin --filename=composer --2 \ + && rm composer-setup.php) + +vendor: composer.json $(wildcard composer.lock) + @echo '> composer install...' \ + && bin/composer install \ + && echo '' + +.PHONY: ci +ci: phplint phpstan tester ## Runs complete CI suite + +.PHONY: phplint +phplint: install + @echo '> PHP linter ...' + @php vendor/bin/parallel-lint Simplex/ tests/ --colors --no-progress + @echo '' + +.PHONY: phpstan +phpstan: install + @echo '> PHPStan ...' + @php vendor/bin/phpstan analyse --no-progress + +.PHONY: tester +tester: install + @echo '> tester ...' + @php vendor/bin/tester tests/ -C --colors diff --git a/composer.json b/composer.json index c6c9cd8..49266c6 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,22 @@ "ext-bcmath": "*", "php": ">=8.2" }, + "require-dev": { + "php-parallel-lint/php-parallel-lint": "^1.3", + "php-parallel-lint/php-console-highlighter": "^1.0", + "phpstan/phpstan": "^1.10", + "phpstan/extension-installer": "^1.3", + "phpstan/phpstan-strict-rules": "^1.5", + "phpstan/phpstan-deprecation-rules": "^1.1", + "nette/tester": "^2.5", + "tracy/tracy": "^2.10" + }, "autoload": { "files": ["Simplex/simplex.php"] + }, + "config": { + "allow-plugins": { + "phpstan/extension-installer": true + } } } diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..adb8db0 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: max + paths: + - Simplex/ + - tests/ diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 0000000..5580039 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,11 @@ +