From 12e8813fbae776dcf1b9ada542c8cb1904a44ea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Thu, 28 Apr 2022 13:00:26 +0200 Subject: [PATCH] Enhancement: Add Makefile --- .editorconfig | 3 +++ .gitattributes | 1 + .github/CONTRIBUTING.md | 30 +++++++++++++++++++++++++----- Makefile | 31 +++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 Makefile diff --git a/.editorconfig b/.editorconfig index 7fbc9f3..ff3289d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,6 @@ trim_trailing_whitespace = true [*.yaml] indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.gitattributes b/.gitattributes index d00cf8f..7dceff1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,7 @@ /.php-cs-fixer.dist.php export-ignore /box.json.dist export-ignore /composer-require-checker.json export-ignore +/Makefile export-ignore /phpunit.xml.dist export-ignore /psalm-baseline.xml export-ignore /psalm.xml export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index cd4e4f4..7e506af 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -13,7 +13,7 @@ We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-C Run ```sh -.phive/php-cs-fixer fix +make coding-standards ``` to automatically fix coding standard violations. @@ -25,7 +25,7 @@ We are using [`maglnet/composer-require-checker`](https://github.com/maglnet/Com Run ```sh -.phive/composer-require-checker check --config-file=$(shell pwd)/composer-require-checker.json +make dependency-analysis ``` to run a dependency analysis. @@ -37,7 +37,7 @@ We are using [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analy Run ```sh -.phive/psalm --config=psalm.xml --show-info=false --stats +make static-code-analysis ``` to run a static code analysis. @@ -47,7 +47,7 @@ We are also using the baseline feature of [`vimeo/psalm`](https://psalm.dev/docs Run ```sh -.phive/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml +make static-code-analysis-baseline ``` to regenerate the baseline in [`../psalm-baseline.xml`](../psalm-baseline.xml). @@ -61,7 +61,27 @@ We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) t Run ```sh -vendor/bin/phpunit +make tests ``` to run all the tests. + +## Extra lazy? + +Run + +```sh +make +``` + +to enforce coding standards, run a static code analysis, and run tests! + +## Help + +:bulb: Run + +```sh +make help +``` + +to display a list of available targets with corresponding descriptions. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f765e5b --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +.PHONY: it +it: coding-standards static-code-analysis tests ## Runs the coding-standards, static-code-analysis, and tests targets + +.PHONY: coding-standards +coding-standards: vendor ## Fixes code style issues with friendsofphp/php-cs-fixer + .phive/php-cs-fixer fix --diff --verbose + +.PHONY: dependency-analysis +dependency-analysis: vendor ## Runs a dependency analysis with maglnet/composer-require-checker + .phive/composer-require-checker check --config-file=$(shell pwd)/composer-require-checker.json + +.PHONY: help +help: ## Displays this list of targets with descriptions + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: static-code-analysis +static-code-analysis: vendor ## Runs a static code analysis with vimeo/psalm + .phive/psalm --config=psalm.xml --clear-cache + .phive/psalm --config=psalm.xml --show-info=false --stats + +.PHONY: static-code-analysis-baseline +static-code-analysis-baseline: vendor ## Generates a baseline for static code analysis with vimeo/psalm + .phive/psalm --config=psalm.xml --clear-cache + .phive/psalm --config=psalm.xml --set-baseline=psalm-baseline.xml + +.PHONY: tests +tests: vendor ## Runs tests with phpunit/phpunit + vendor/bin/phpunit + +vendor: composer.json + composer install --no-progress