From f24e4061e895cd4014a1b1bca919599cc3034f0d Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Tue, 14 Jul 2020 19:48:06 +0100 Subject: [PATCH] Pin versions and run psalm too --- .gitattributes | 1 + .github/CONTRIBUTING.md | 8 ++++---- Makefile | 23 +++++++++++++++++++++++ psalm.xml | 12 ++++++++++++ vendor-bin/phpstan/composer.json | 13 ++++++++----- vendor-bin/psalm/composer.json | 8 ++++++++ 6 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 Makefile create mode 100644 psalm.xml create mode 100644 vendor-bin/psalm/composer.json diff --git a/.gitattributes b/.gitattributes index 7fd92c13..f108c952 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10,6 +10,7 @@ /phpstan.neon.dist export-ignore /phpstan.tests.neon.dist export-ignore /phpunit.xml.dist export-ignore +/psalm.xml export-ignore /README.md export-ignore /UPGRADING.md export-ignore /vendor-bin export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cbdd12f2..3ee17d18 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -18,13 +18,13 @@ We accept contributions via pull requests on Github. Please review these guideli First, install the dependencies using [Composer](https://getcomposer.org/): ```bash -$ composer install +$ make install ``` -Then run [PHPUnit](https://phpunit.de/): +Then run [PHPUnit](https://phpunit.de/) and the static analyzers: ```bash -$ vendor/bin/phpunit +$ make test ``` -The tests will be automatically run by [Travis CI](https://travis-ci.org/) and [GitHub Actions](https://github.com/features/actions) against pull requests. +These will also be automatically run by [Travis CI](https://travis-ci.org/) and [GitHub Actions](https://github.com/features/actions) against pull requests. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..d8ccac18 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +install: + @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base update + @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:7.4-base bin all update + +phpunit: + @rm -f bootstrap/cache/*.php && docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:7.4-cli + +phpstan-analyze-src: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze src -c phpstan.src.neon.dist + +phpstan-analyze-tests: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:7.4-cli analyze tests -c phpstan.tests.neon.dist + +psalm-analyze: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli + +psalm-show-info: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --show-info=true + +test: phpunit phpstan-analyze-src phpstan-analyze-tests psalm-analyze + +clean: + @rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 00000000..86fd2279 --- /dev/null +++ b/psalm.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index bee96695..3626c2ec 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,9 +1,12 @@ { "require": { - "phpstan/phpstan": "^0.12.25", - "phpstan/extension-installer": "^1.0.4", - "phpstan/phpstan-deprecation-rules": "^0.12.4", - "phpstan/phpstan-strict-rules": "^0.12.2", - "thecodingmachine/phpstan-strict-rules": "^0.12.0" + "phpstan/phpstan": "~0.12.32", + "phpstan/extension-installer": "~1.0.4", + "phpstan/phpstan-deprecation-rules": "~0.12.4", + "phpstan/phpstan-strict-rules": "~0.12.2", + "thecodingmachine/phpstan-strict-rules": "~0.12.0" + }, + "config": { + "preferred-install": "dist" } } diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json new file mode 100644 index 00000000..92a7feef --- /dev/null +++ b/vendor-bin/psalm/composer.json @@ -0,0 +1,8 @@ +{ + "require": { + "vimeo/psalm": "~3.12.2" + }, + "config": { + "preferred-install": "dist" + } +}