Skip to content

Commit 02bf6fc

Browse files
Merge remote-tracking branch 'origin/master' into feature/incompatibility-phpmd
2 parents f03dbcf + 36927a1 commit 02bf6fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1314
-831
lines changed

.github/workflows/testing-suite.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,32 @@ jobs:
44
PHP:
55
strategy:
66
matrix:
7-
image: [
8-
'srcoder/development-php:php74-fpm',
9-
'srcoder/development-php:php80-fpm',
10-
'srcoder/development-php:php81-fpm'
11-
]
7+
php:
8+
- {version: 8.1, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
9+
- {version: 8.2, tasks: 'composer,jsonlint,xmllint,yamllint,phpcs,phplint,phpmd,phpstan,securitychecker_enlightn'}
10+
- {version: 8.3}
11+
- {version: 8.4}
1212
runs-on: ubuntu-latest
1313
container:
14-
image: ${{ matrix.image }}
14+
image: ${{ matrix.php.version == '8.1' && 'srcoder/development-php:php81-fpm' ||
15+
matrix.php.version == '8.2' && 'srcoder/development-php:php82-fpm' ||
16+
matrix.php.version == '8.3' && 'srcoder/development-php:php83-fpm' ||
17+
matrix.php.version == '8.4' && 'srcoder/development-php:php84-fpm' }}
1518
steps:
1619
- name: Checkout
1720
uses: actions/checkout@v2
18-
- name: Testing Suite
21+
22+
- name: Install Dependencies
1923
run: |
2024
composer2 install --dev --prefer-dist --no-scripts --no-progress --optimize-autoloader --no-interaction -vvv
2125
composer2 show
22-
composer2 exec -v grumphp run
26+
shell: bash
27+
28+
- name: Run GrumPHP Tasks
29+
run: |
30+
runArguments=()
31+
if [[ "${{ matrix.php.tasks }}" ]]; then
32+
runArguments+=(--tasks="{{ matrix.php.tasks }}")
33+
fi
34+
composer2 exec -v grumphp -- run "${runArguments[@]}"
2335
shell: bash

CHANGELOG.md

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,61 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.0.0]
8+
### Added
9+
- Added `phpunit/phpunit` to suggested dependencies in `composer.json`.
10+
- Added `youwe/coding-standard-phpstorm` to suggested dependencies in `composer.json`.
11+
- Added support to honor upstream version constraints.
12+
- Github action for php 8.3 and php 8.4 to run unit tests against PHPUnit 12.
13+
- Testing suite now attempts to install phpunit upstream if it isn't available yet.
14+
- Existing upstream versions are honored if already installed.
15+
- Upstream projects not having phpunit installed will install phpunit with an @stable version.
16+
- Added support for Drupal configuration and templates.
17+
- Migration docs for migration from v2 to v3 of the testing suite.
18+
- Option to use PHP CS Fixer instead of PHPCS.
19+
- Pimcore coding standards with [PER coding standards](https://www.php-fig.org/per/coding-style/).
20+
- Added support for an Allow List within the Security Checker.
21+
- Pimcore PHPStan default config.
22+
- Pimcore PHP Mess Detector default config.
23+
24+
### Changed
25+
- [BREAKING] The composer.json configurations `config.youwe-testing-suite.type` and `config.mediact-testing-suite.type`
26+
are now moved from the `config` section to the `extra` section. The old location was invalid as the `config` section
27+
belongs to configuration from Composer itself. Moving it to the `extra` section which is intended for this purpose
28+
(composer docs: "arbitrary extra data for consumption by scripts"). Only the single `extra.youwe-testing-suite.type`
29+
is supported now. Update your project `composer.json` accordingly.
30+
- [BREAKING] PHPStan is now configured to scan the full project, also during commit hooks. This will require to
31+
configure the `paths` setting in your projects `phpstan.neon.`. See the [migration notes](MIGRATION.md) for more
32+
precise instructions. This behaviour can be modified with the `phpstan.use_grumphp_paths` parameter in `grumphp.yml`.
33+
Please read [Why you should always analyse the whole project](https://phpstan.org/blog/why-you-should-always-analyse-whole-project)
34+
before reverting to the old behaviour.
35+
- Unit tests as part of the testing suite are rewritten for PHPUnit 12.
36+
- Updated GitHub Action workflows to support PHP 8.1, 8.2, 8.3, and 8.4
37+
- `composer.json`: Dropped support for PHP < 8.1.
38+
- Moved phpunit from require to require-dev.
39+
- Changed PHPMD suppressions in docblocks to quote the rule name, due to changes in later versions of PHPStan that create false positives on these docblocks if not quoted.
40+
- Moved existing project-type specific rulesets from inner dependencies to testing-suite package.
41+
- Simplified PHPMD rulesets with rationale behind rule changes.
42+
- Updated remote schema location URL for phpmd rulesets to prevent redirecting which may cause flaky builds.
43+
- Bumped phpro/grumphp-shim dependency from v1 to v2
44+
- Bumped youwe/composer-dependency-installer from v1 to v2
45+
- Testing Suite files are only installed in the project when the package itself is installed and/or updated, for example
46+
when running `composer require youwe/testing-suite`, `composer update [youwe/testing-suite]` or `composer install`
47+
when the package was not installed (yet/anymore).
48+
- Default Pimcore coding standards disables PHPCS in favour of PHP CS Fixer.
49+
- JSON Lint will ignore folders `.ddev/` and `tests/fixtures/`.
50+
- Added Symfony function `dump()` to the git blacklist for all project types
51+
52+
### Removed
53+
- Removed support for EOL PHP versions. Projects running PHP < 8.1 can stick to version 2 of the testing-suite.
54+
- Removed support for Composer 1. Projects still relying on Composer 1 can stick to version 2 of the testing-suite.
55+
- Removed `youwe/coding-standard-phpstorm` as dependency (it is still listed in suggest).
56+
- Removed `phpunit/phpunit` as direct dependency (it is still in require-dev and installed upstream through the `youwe/dependency-installer`).
57+
- Github actions for php < 8.1.
58+
- Dependency on seperated coding style packages to simplify development and remove overhead.
59+
- Dropped support for Laravel and Magento 1.
60+
- Dropped inner dependencies on coding-standard, coding-standard-magento2, and coding-standard-phpstorm packages.
61+
762
## 2.19.1
863
### Changed
964
- `^0.30` restricts updates to only versions within the `0.30.x` range, preventing upgrades to 0.32.0 for
@@ -102,7 +157,7 @@ on functions ending with `add()` or `odd()` due to checks on dump and die `dd()`
102157
## 2.12 - 2022-05-30
103158
### Added
104159
- PHP 8 compatibility.
105-
- GitHub Actions Workflow to run testing-suite for PHP 7.4, 8.0 and 8.1.
160+
- GitHub Actions Workflow to run testing-suite for PHP 7.4, 8.0, and 8.1.
106161

107162
## 2.11.1 - 2022-04-10
108163
### Changed

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Before opening a PR with changes, make sure all the linting steps are successful.
2+
3+
The require-dev dependency for phpunit is set to @stable for the github actions, but the tests themselves\
4+
assume they are running against PHPUnit 12 and php >= 8.3. The github actions only run phpunit tests against\
5+
a php 8.3 container.
6+
17
If a PR is approved please ask one of the following maintainers to get it merged:
2-
[Igor Wulff](https://github.com/igorwulff)
3-
[Dan Wallis](https://github.com/fredden)
8+
9+
- [Igor Wulff](https://github.com/igorwulff)
10+
- [Leon Helmus](https://github.com/leonhelmus)
11+
- [Rutger Rademaker](https://github.com/rutgerrademaker)

MIGRATION.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
## Testing suite v2 to v3 migration guide
2+
TODO: Validate / update / rewrite this based on experience and later changes when adding the testing suite
3+
based on experiences with initial v3.0.0-rc1 tests.
4+
5+
### 1. Double check your project type in the project composer.json.
6+
We use the project type to automatically update some ruleset mappings for PHPCS and PHPMD.
7+
8+
For a list of supported project types, see the [readme](./README.md).
9+
10+
If your project type was configured in `composer.json` within the `config` section, then move that to the `extra`
11+
section:
12+
13+
**Old:**
14+
```json
15+
{
16+
"config": {
17+
"youwe-testing-suite": { "type": "magento2" }
18+
}
19+
}
20+
```
21+
22+
**New:**
23+
```json
24+
{
25+
"extra": {
26+
"youwe-testing-suite": { "type": "magento2" }
27+
}
28+
}
29+
```
30+
31+
Otherwise, the project type is still taken from the `type` within `composer.json`.
32+
33+
```json
34+
{
35+
"type": "magento2-module"
36+
}
37+
```
38+
39+
### 2. Update to version 3
40+
```bash
41+
composer require --dev youwe/testing-suite:^3.0 --no-update
42+
composer remove --dev youwe/coding-standard youwe/coding-standard-magento2 --no-update
43+
composer update youwe/testing-suite -W
44+
composer install
45+
```
46+
47+
Note: starting v3, phpunit may be installed in your project automatically.\
48+
We use the @stable version constraint for this. If you want to install a specific
49+
phpunit version in your project you are free to do so. Upstream phpunit versions
50+
are honored during installation.
51+
52+
### 3. Change PHPStan configuration
53+
54+
PHPStan is now configured to scan the full project, also during commit hooks. This will require to
55+
configure the `paths` setting in your projects `phpstan.neon.`.
56+
57+
Example `phpstan.neon` file containing the `paths` parameter:
58+
```neon
59+
includes:
60+
# To create a baseline run the following command and then uncomment the include below (make sure to run the baseline
61+
# command with the same level as configured in Grumphp)
62+
# vendor/bin/phpstan analyse --configuration=./phpstan.neon --generate-baseline --level=4
63+
# - phpstan-baseline.neon
64+
65+
parameters:
66+
paths:
67+
- src
68+
69+
# Uncomment when your project has unit tests:
70+
# - tests
71+
72+
# Add any other project folder containing source files, e.g.
73+
# - bundles
74+
75+
excludePaths:
76+
# - tests/fixtures/*
77+
```
78+
79+
As alternative, you can revert your project to the old behaviour by setting the `phpstan.use_grumphp_paths: true`
80+
parameter in your `grumphp.yml`. Please read [Why you should always analyse the whole project](https://phpstan.org/blog/why-you-should-always-analyse-whole-project)
81+
before reverting to the old behaviour.
82+
83+
### 4. Sanity checks
84+
Check the following
85+
86+
1. The PHPCS file exists in your project root and points to the correct ruleset
87+
configuration in youwe/testing-suite
88+
2. The PHPMD file exists in your project root and points to the correct ruleset
89+
configuration in youwe/testing-suite
90+
3. Run `ddev exec grumphp run` or `vendor/bin/grumphp run`
91+
4. Your git commit hook still functions as expected
92+
93+
### 5. Refactor and/or update/regenerate exclusion rules
94+
Some rulesets will have changed. In a general sense, the rulesets are less
95+
strict compared to what they were before.
96+
97+
If your grumphp tasks are failing due to changes in rulesets, you have 3 options:
98+
99+
1. Refactor. This is always the preferred route if the amount of issues raised
100+
is limited.
101+
2. Add exclusion filters. Use existing tooling or update your project configuration
102+
files to exclude existing project files. This will help in the short-term. Note
103+
that it is always recommended to still refactor in the future so the file
104+
exclusions lists will reduce in size over time.
105+
3. Update rulesets in your project. Projects are free to update rulesets and
106+
validation if they want. Of course it is always recommended to add
107+
additional rules instead of removing existing rules.

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,37 @@ predefined default configurations per project type.
1111

1212
## Features
1313

14-
- [Project Type detector](docs/features/project-type-detector.md)
14+
- [Project Type detector](docs/features/project-type-detection.md)
1515
- [PHP storm configuration](docs/features/php-storm-integration.md)
1616

1717
## Supported project types
1818

19-
- Default (`default`)
20-
- Laravel (`laravel`)
21-
- [Magento 1](docs/project-types/magento1.md) (`magento1`)
22-
- [Magento 2](docs/project-types/magento2.md) (`magento2`)
23-
- Pimcore (`pimcore`)
19+
The Youwe Testing Suites offers pre-configured standards for the following project types.
20+
21+
| Testing Suite Project Type | Detected based on Composer Project Type |
22+
|----------------------------|----------------------------------------------------------------------------|
23+
| `drupal` | `drupal-bundle`, `drupal-project` |
24+
| `magento2` | `magento-module`, `magento-project`, `magento2-module`, `magento2-project` |
25+
| `pimcore` | `pimcore-bundle`, `pimcore-project` |
26+
| `default` | Any other |
27+
28+
This project type is either detected from `composer.json` via the section
29+
30+
```json
31+
{
32+
"extra": {
33+
"youwe-testing-suite": { "type": "magento2" }
34+
}
35+
}
36+
```
37+
38+
or if no explicit setting was found for the Testing Suite, via
39+
40+
```json
41+
{
42+
"type": "magento2-module"
43+
}
44+
```
2445

2546
## Included analysis tools
2647

@@ -38,6 +59,15 @@ predefined default configurations per project type.
3859

3960
## Installation
4061

62+
First, configure your project type (see the above list of supported types) via
63+
```
64+
composer config type magento2-project
65+
```
66+
or
67+
```
68+
composer config extra.youwe-testing-suite.type magento2
69+
```
70+
4171
Testing suite is supposed to be installed as a composer `dev` dependency.
4272
Within any project just run the command below to install the package:
4373
```

composer.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,28 @@
2424
}
2525
],
2626
"require": {
27-
"php": "^7.2 || ^8.0",
28-
"composer-plugin-api": "^1.1 || ^2.0",
27+
"php": "^8.1",
28+
"composer-plugin-api": "^2.0",
29+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
2930
"enlightn/security-checker": "^1.5 || ^2.0",
3031
"kint-php/kint": "@stable",
31-
"php-parallel-lint/php-parallel-lint": "^1.2",
32-
"phpro/grumphp-shim": "^1.13",
32+
"php-cs-fixer/shim": "@stable",
33+
"php-parallel-lint/php-parallel-lint": "^1.4",
34+
"phpmd/phpmd": "^2.15",
35+
"phpro/grumphp-shim": "^2.15",
3336
"phpstan/phpstan": "@stable",
34-
"phpunit/phpunit": "@stable",
35-
"youwe/coding-standard": "^3.5.0",
36-
"youwe/coding-standard-phpstorm": "^2.3.0",
37-
"youwe/composer-dependency-installer": "^1.4.0",
38-
"youwe/composer-file-installer": "^1.2.0"
37+
"squizlabs/php_codesniffer": "^3.12.0",
38+
"youwe/composer-dependency-installer": "^2.0",
39+
"youwe/composer-file-installer": "^2.0.0"
40+
},
41+
"suggest": {
42+
"phpunit/phpunit": ">= 9.6",
43+
"youwe/coding-standard-phpstorm": "^2.3.0"
3944
},
4045
"require-dev": {
4146
"composer/composer": "@stable",
42-
"mikey179/vfsstream": "@stable"
47+
"mikey179/vfsstream": "@stable",
48+
"phpunit/phpunit": "@stable"
4349
},
4450
"replace": {
4551
"sensiolabs/security-checker": "*"

0 commit comments

Comments
 (0)