Skip to content

Travis: test builds against PHP 7.4 & improve PHPUnit 8 fix#2416

Merged
gsherwood merged 1 commit intosquizlabs:masterfrom
jrfnl:feature/test-again-php-7.4
Feb 26, 2019
Merged

Travis: test builds against PHP 7.4 & improve PHPUnit 8 fix#2416
gsherwood merged 1 commit intosquizlabs:masterfrom
jrfnl:feature/test-again-php-7.4

Conversation

@jrfnl
Copy link
Copy Markdown
Contributor

@jrfnl jrfnl commented Feb 11, 2019

Test builds against PHP 7.4

Nightly has become PHP 8.0 since PHP 7.4 has been branched, so to continue to also test against PHP 7.4, it needs to be added separately.

As PHPStan can't currently be run (yet) on PHP 8, the environment variable for it has also been moved to PHP 7.4.

Refs:

Improve PHPUnit 8 fix

PHPUnit 8 adds void return type declarations to the PHPUnit methods used by PHPCS, making it neigh impossible to make the unit test suite cross-version compatible for the PHP versions supported by PHPCS.

Officially, PHPUnit 7 is compatible with PHP 7.1, 7.2 and 7.3. However for the functionality used by the PHPCS test suite, it looks to be compatible with PHP 7.4 as well (for now).
Ref: https://phpunit.de/supported-versions.html

For this reason, for Travis images which come natively with PHPUnit 8 (PHP >= 7.2), PHPUnit 7 needs to be installed via Composer.
This is not necessary for older PHP versions and skipping the composer install when it's not needed, will make the build a little faster.

Note: Doing the composer install in the before_install step will show a build as "errored" instead of "failed" if something would go wong with this install, which is more representative of the real build status.

As for nightly/PHP 8:

  • The Travis native PHPUnit version for nightly is PHPUnit 8, which will not work.
  • Running composer install for PHPUnit on nightly currently installs PHPUnit 4.1.6. Most likely because the PHPUnit 4.x composer.json file did not yet contain a PHP requirement, while any higher PHPUnit versions do. Anyways, that will most definitely not work.
  • Running composer install for PHPUnit with an explicit requirement of PHPUnit 7.x will also not work as PHPUnit 7 will not install on PHP 8 based on the PHPUnit composer.json file.

All in all, the unit tests can not currently be run on PHP 8.

When the PHPUnit build step would be active on nightly it would automatically fail the build. This would mask any errors in other build steps.
So, for now, I've elected to skip running the unit tests on PHP 8 (nightly). This will allow all the other build tests which can be run on PHP 8 to still be tested and report appropriate statuses.

Nightly has become PHP 8.0 since PHP 7.4 has been branched, so to continue to also test against PHP 7.4, it needs to be added separately.

As PHPStan can't currently be run (yet) on PHP 8, the environment variable for it has also been moved to PHP 7.4.

Refs:
* https://twitter.com/nikita_ppv/status/1089839541828112384
* https://twitter.com/nikita_ppv/status/1094897743594770433

PHPUnit 8 adds `void` return type declarations to the PHPUnit methods used by PHPCS, making it neigh impossible to make the unit test suite cross-version compatible for the PHP versions supported by PHPCS.

Officially, PHPUnit 7 is compatible with PHP 7.1, 7.2 and 7.3. However for the functionality used by the PHPCS test suite, it looks to be compatible with PHP 7.4 as well (for now).
Ref: https://phpunit.de/supported-versions.html

For this reason, for Travis images which come natively with PHPUnit 8 (PHP >= 7.2), PHPUnit 7 needs to be installed via Composer.
This is not necessary for older PHP versions and skipping the `composer install` when it's not needed, will make the build a little faster.

Note:  Doing the `composer install` in the `before_install` step will show a build as "errored" instead of "failed" if something would go wong with this install, which is more representative of the real build status.

As for `nightly`/PHP 8:
* The Travis native PHPUnit version for `nightly` is PHPUnit 8, which will not work.
* Running `composer install` for PHPUnit on `nightly` currently installs PHPUnit 4.1.6. Most likely because the PHPUnit 4.x `composer.json` file did not yet contain a PHP requirement, while any higher PHPUnit versions do. Anyways, that will most definitely not work.
* Running `composer install` for PHPUnit with a requirement of PHPUnit 7.x will also not work as PHPUnit 7 will not install on PHP 8 based on the PHPUnit `composer.json` file.

All in all, the unit tests can not currently be run on PHP 8.

When the PHPUnit build step would be active on `nightly` it would automatically fail the build. This would mask any errors in other build steps. So, for now, I've elected to skip running the unit tests on PHP 8 (`nightly`).
This will allow all the other build tests which *can* be run on PHP 8 to still be tested and report appropriate statuses.
@jrfnl jrfnl force-pushed the feature/test-again-php-7.4 branch from a160659 to 76999f6 Compare February 16, 2019 16:24
@gsherwood gsherwood added this to the 3.4.1 milestone Feb 25, 2019
@gsherwood gsherwood merged commit 76999f6 into squizlabs:master Feb 26, 2019
@gsherwood
Copy link
Copy Markdown
Member

Thanks a lot for this.

@jrfnl jrfnl deleted the feature/test-again-php-7.4 branch February 26, 2019 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants