Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Add Makefile #234

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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