Skip to content

Commit

Permalink
Merge pull request #512 from wayofdev/feat/tpl-updates
Browse files Browse the repository at this point in the history
feat: support for new tools
  • Loading branch information
lotyp authored Apr 20, 2024
2 parents e614fa0 + f623e28 commit ffe3870
Show file tree
Hide file tree
Showing 11 changed files with 1,198 additions and 105 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package.json export-ignore
phpstan.neon.dist export-ignore
phpstan-baseline.neon export-ignore
phpunit.xml.dist export-ignore
psalm.xml export-ignore
psalm-baseline.xml export-ignore
renovate.json export-ignore
rector.php export-ignore
renovate.json export-ignore
13 changes: 9 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,29 +230,34 @@ to run mutation tests.

## ⚙️ Static Code Analysis

We use [`phpstan/phpstan`](https://github.com/phpstan/phpstan) to statically analyze the code.
We use both [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.

Run

```sh
$ make lint-stan
$ make lint-psalm
```

to run a static code analysis.

We also use the baseline features of [`phpstan/phpstan`](https://phpstan.org/user-guide/baseline).
We also use the baseline features of [`phpstan/phpstan`](https://phpstan.org/user-guide/baseline) and [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file) to ignore existing issues.

Run

```sh
$ make lint-stan-baseline
$ make lint-psalm-baseline
```

to regenerate the baselines in [`../phpstan-baseline.neon`](../phpstan-baseline.neon).
to regenerate the baselines in:

- [`../phpstan-baseline.neon`](../phpstan-baseline.neon).
- [`../psalm-baseline.xml`](../psalm-baseline.xml).

> [!IMPORTANT]
>
> Ideally, the baseline file should stay empty or shrink over time.
> Ideally, the baseline files should stay empty or shrink over time.
<br>

Expand Down
4 changes: 1 addition & 3 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ contact_links:
url: https://discord.gg/CE3TcCC5vr
about: Join our Discord community to get help, share your ideas, and chat with other developers.

- name: Send an e-mail to the developer
url: mailto:[email protected]
about: Please do NOT use this email to post issues or feature requests (only important business/personal contact).
...
2 changes: 2 additions & 0 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ jobs:

- name: 🧪 Run mutation testing using Xdebug and infection/infection
run: composer infect:ci
env:
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}

security-analysis:
timeout-minutes: 4
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,18 @@ lint-stan-baseline: ## Runs phpstan to update its baseline
$(APP_COMPOSER) stan:baseline
.PHONY: lint-stan-baseline

lint-psalm: ## Runs vimeo/psalm – static analysis tool
$(APP_COMPOSER) psalm
.PHONY: lint-psalm

lint-psalm-ci: ## Runs vimeo/psalm – static analysis tool with github output (CI mode)
$(APP_COMPOSER) psalm:ci
.PHONY: lint-psalm-ci

lint-psalm-baseline: ## Runs vimeo/psalm to update its baseline
$(APP_COMPOSER) psalm:baseline
.PHONY: lint-psalm-baseline

lint-deps: ## Runs composer-require-checker – checks for dependencies that are not used
$(APP_RUNNER) .phive/composer-require-checker check \
--config-file=/app/composer-require-checker.json \
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ This template repository includes several features to streamline the development
- [Orchestra Testbench](https://packages.tools/testbench.html) for Laravel package testing.
- [PHPStan](https://phpstan.org) extensions for PHPUnit and Laravel.
- Infection for mutation testing to ensure quality.
- Mutation test reports are uploaded [Stryker Mutator Dashboard](https://dashboard.stryker-mutator.io).

### → Static Analysis

- [PHPStan](https://phpstan.org) for static analysis, ensuring code quality and robustness.
- [Larastan](https://github.com/larastan/larastan) for Laravel-specific static analysis.
- [PHPStan strict rules](https://github.com/phpstan/phpstan-strict-rules) for enforcing strict type checks and standards.
- [Psalm](https://psalm.dev) for finding errors in PHP applications through static analysis.

### → Coding Standards:

Expand All @@ -67,9 +69,9 @@ This template repository includes several features to streamline the development
- Automated testing with code coverage report generation using PHPUnit and Xdebug, uploaded to [Codecov](https://about.codecov.io).
- Automated linting of YAML files and PHP code to ensure consistency and adherence to best practices.
- Checks for outdated or insecure dependencies using Composer.
- Mutation testing with [Infection](https://github.com/infection/infection) to assess the quality of the test suite.
- Mutation testing with [Infection](https://github.com/infection/infection) and [Stryker Mutator](https://stryker-mutator.io) to assess the quality of the test suite.
- Security checks to identify vulnerabilities in dependencies.
- Comprehensive static analysis with [PHPStan](https://phpstan.org) to detect potential issues early.
- Comprehensive static analysis with [PHPStan](https://phpstan.org) and [Psalm](https://psalm.dev).
- Extensive testing across different setups to ensure compatibility and stability.

### → Development Environment
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"ergebnis/composer-normalize": "^2.42",
"ergebnis/phpunit-slow-test-detector": "^2.14",
"fakerphp/faker": "^1.23",
"infection/infection": "^0.28.1",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^8.5 || ^9.0",
"pestphp/pest": "^2.34",
Expand All @@ -35,8 +34,12 @@
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^10.5 || ^11.0",
"psalm/plugin-laravel": "^2.11",
"psalm/plugin-phpunit": "~0.19.0",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.35",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^5.23.1",
"wayofdev/cs-fixer-config": "^1.2"
},
"minimum-stability": "dev",
Expand Down Expand Up @@ -83,13 +86,16 @@
"scripts": {
"cs:diff": "php vendor/bin/php-cs-fixer fix --dry-run -v --diff",
"cs:fix": "php vendor/bin/php-cs-fixer fix -v",
"infect": "XDEBUG_MODE=coverage php vendor/bin/infection --configuration=infection.json.dist",
"infect:ci": "XDEBUG_MODE=coverage php vendor/bin/infection --ansi --configuration=infection.json.dist --logger-github",
"infect": "XDEBUG_MODE=coverage php vendor/bin/roave-infection-static-analysis-plugin --configuration=infection.json.dist",
"infect:ci": "XDEBUG_MODE=coverage php vendor/bin/roave-infection-static-analysis-plugin --ansi --configuration=infection.json.dist --logger-github --ignore-msi-with-no-mutations --only-covered",
"refactor": "php vendor/bin/rector process --config=rector.php",
"refactor:ci": "php vendor/bin/rector process --config=rector.php --dry-run --ansi",
"stan": "php vendor/bin/phpstan analyse --memory-limit=2G",
"stan:baseline": "php vendor/bin/phpstan analyse --generate-baseline --memory-limit=2G --allow-empty-baseline",
"stan:ci": "php vendor/bin/phpstan analyse --memory-limit=2G --error-format=github",
"psalm": "php vendor/bin/psalm --show-info=true",
"psalm:baseline": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml",
"psalm:ci": "php vendor/bin/psalm --output-format=github --shepherd --show-info=false --stats --threads=4",
"test": "XDEBUG_MODE=coverage php vendor/bin/pest",
"test:cc": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml"
}
Expand Down
Loading

0 comments on commit ffe3870

Please sign in to comment.