Skip to content

Commit

Permalink
Enhancement: Add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Apr 28, 2022
1 parent 0c20492 commit 12e8813
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ trim_trailing_whitespace = true

[*.yaml]
indent_size = 2

[Makefile]
indent_style = tab
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 25 additions & 5 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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).
Expand All @@ -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.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 12e8813

Please sign in to comment.