Skip to content

Commit 9056a18

Browse files
authored
Merge pull request #37 from YouweGit/release/version3
Release/version3
2 parents 3e1206b + b54705d commit 9056a18

Some content is hidden

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

66 files changed

+878
-746
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: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,45 @@ 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+
19+
### Changed
20+
- [BREAKING] The composer.json configurations `config.youwe-testing-suite.type` and `config.mediact-testing-suite.type`
21+
are now moved from the `config` section to the `extra` section. The old location was invalid as the `config` section
22+
belongs to configuration from Composer itself. Moving it to the `extra` section which is intended for this purpose
23+
(composer docs: "arbitrary extra data for consumption by scripts"). Only the single `extra.youwe-testing-suite.type`
24+
is supported now. Update your project `composer.json` accordingly.
25+
- Unit tests as part of the testing suite are rewritten for PHPUnit 12.
26+
- Updated GitHub Action workflows to support PHP 8.1, 8.2, 8.3, and 8.4
27+
- `composer.json`: Dropped support for PHP < 8.1.
28+
- Moved phpunit from require to require-dev.
29+
- 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.
30+
- Moved existing project-type specific rulesets from inner dependencies to testing-suite package.
31+
- Simplified PHPMD rulesets with rationale behind rule changes.
32+
- Updated remote schema location URL for phpmd rulesets to prevent redirecting which may cause flaky builds.
33+
- Bumped phpro/grumphp-shim dependency from v1 to v2
34+
- Bumped youwe/composer-dependency-installer from v1 to v2
35+
36+
### Removed
37+
- Removed support for EOL PHP versions. Projects running PHP < 8.1 can stick to version 2 of the testing-suite.
38+
- Removed support for Composer 1. Projects still relying on Composer 1 can stick to version 2 of the testing-suite.
39+
- Removed `youwe/coding-standard-phpstorm` as dependency (it is still listed in suggest).
40+
- Removed `phpunit/phpunit` as direct dependency (it is still in require-dev and installed upstream through the `youwe/dependency-installer`).
41+
- Github actions for php < 8.1.
42+
- Dependency on seperated coding style packages to simplify development and remove overhead.
43+
- Dropped support for Laravel and Magento 1.
44+
- Dropped inner dependencies on coding-standard, coding-standard-magento2, and coding-standard-phpstorm packages.
45+
746
## 2.19.1
847
### Changed
948
- `^0.30` restricts updates to only versions within the `0.30.x` range, preventing upgrades to 0.32.0 for
@@ -102,7 +141,7 @@ on functions ending with `add()` or `odd()` due to checks on dump and die `dd()`
102141
## 2.12 - 2022-05-30
103142
### Added
104143
- PHP 8 compatibility.
105-
- GitHub Actions Workflow to run testing-suite for PHP 7.4, 8.0 and 8.1.
144+
- GitHub Actions Workflow to run testing-suite for PHP 7.4, 8.0, and 8.1.
106145

107146
## 2.11.1 - 2022-04-10
108147
### 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: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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. Sanity checks
53+
Check the following
54+
55+
1. The PHPCS file exists in your project root and points to the correct ruleset
56+
configuration in youwe/testing-suite
57+
2. The PHPMD file exists in your project root and points to the correct ruleset
58+
configuration in youwe/testing-suite
59+
3. Run `ddev exec grumphp run` or `vendor/bin/grumphp run`
60+
4. Your git commit hook still functions as expected
61+
62+
### 4. Refactor and/or update/regenerate exclusion rules
63+
Some rulesets will have changed. In a general sense, the rulesets are less
64+
strict compared to what they were before.
65+
66+
If your grumphp tasks are failing due to changes in rulesets, you have 3 options:
67+
68+
1. Refactor. This is always the preferred route if the amount of issues raised
69+
is limited.
70+
2. Add exclusion filters. Use existing tooling or update your project configuration
71+
files to exclude existing project files. This will help in the short-term. Note
72+
that it is always recommended to still refactor in the future so the file
73+
exclusions lists will reduce in size over time.
74+
3. Update rulesets in your project. Projects are free to update rulesets and
75+
validation if they want. Of course it is always recommended to add
76+
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: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,27 @@
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-parallel-lint/php-parallel-lint": "^1.4",
33+
"phpmd/phpmd": "^2.15",
34+
"phpro/grumphp-shim": "^2.12",
3335
"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",
36+
"squizlabs/php_codesniffer": "^3.12.0",
37+
"youwe/composer-dependency-installer": "^2.0",
3838
"youwe/composer-file-installer": "^1.2.0"
3939
},
40+
"suggest": {
41+
"phpunit/phpunit": ">= 9.6",
42+
"youwe/coding-standard-phpstorm": "^2.3.0"
43+
},
4044
"require-dev": {
4145
"composer/composer": "@stable",
42-
"mikey179/vfsstream": "@stable"
46+
"mikey179/vfsstream": "@stable",
47+
"phpunit/phpunit": "@stable"
4348
},
4449
"replace": {
4550
"sensiolabs/security-checker": "*"

config/default/phpmd.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Youwe/Global"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 https://pmd.sourceforge.io/ruleset_xml_schema.xsd">
6+
<description>Default / Fallback configuration for PHPMD rulesets.</description>
7+
8+
<!-- Taken from Global ruleset since we can't modify a referenced rule without overwriting it completely.
9+
See: https://github.com/phpmd/phpmd/issues/39 -->
10+
<rule ref="rulesets/cleancode.xml">
11+
<!-- Even though else statements can be rewritten to be avoided, this rule to always block else statements is a bit
12+
extreme to enforce in standards. Rule can still be adopted on project-level if needed. -->
13+
<exclude name="ElseExpression"/>
14+
<!-- We should not assume all code is OOP based, and static usage is not inherently bad outside OOP/SOLID contexts. -->
15+
<exclude name="StaticAccess"/>
16+
<!-- Boolean flags are sometimes needed to preserve e.g. backwards compatibility. We don't want to enforce this in a blanket
17+
statement / default rule but if projects want to enforce this they are free to do so. -->
18+
<exclude name="BooleanArgumentFlag"/>
19+
</rule>
20+
21+
<rule ref="rulesets/codesize.xml" />
22+
<rule ref="rulesets/design.xml" />
23+
<rule ref="rulesets/unusedcode.xml" />
24+
<rule ref="rulesets/naming.xml" />
25+
26+
<rule ref="rulesets/naming.xml/LongVariable">
27+
<properties>
28+
<!-- 20 limit is hard to make descriptive, plus has historically been 30 so also for better backwards compatibility support -->
29+
<property name="maximum" value="30"/>
30+
</properties>
31+
</rule>
32+
<!-- End of global ruleset -->
33+
</ruleset>

config/default/ruleset.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Youwe/Default">
3+
<description>Youwe coding standards for code sniffing for generic platform-agnostic PHP code.</description>
4+
<!-- Show sniff codes in all reports. Easier to ignore rules when necessary -->
5+
<arg value="s"/>
6+
<!-- Use colors in output -->
7+
<arg name="colors" />
8+
9+
<!-- Base rules on PSR12 -->
10+
<rule ref="PSR12" />
11+
</ruleset>

config/drupal/grumphp.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
imports:
2+
- resource: '../default/grumphp.yml'
3+
4+
# Extend git triggers with common Drupal constructs
5+
parameters:
6+
git_blacklist.triggered_by: [ 'php', 'js', 'twig' ]

config/drupal/phpmd.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PHPMD"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 https://pmd.sourceforge.io/ruleset_xml_schema.xsd">
6+
<description>PHPMD rules for Drupal projects.</description>
7+
<rule ref="./config/default/phpmd.xml" />
8+
9+
<!-- No overrides compared to default. Revisit this file and recreate default drupal rulesets for projects if needed.
10+
Note: seperate ruleset needed until https://github.com/phpmd/phpmd/issues/39 is resolved -->
11+
</ruleset>

0 commit comments

Comments
 (0)