Travis: run the code style related checks in separate stage by jrfnl · Pull Request #798 · PHPCompatibility/PHPCompatibility

@jrfnl

Travis now offers stages. Using stages we can:
- Run the code style related checks before running any unit tests and stop the build early if any are detected.
- Only run the (heavy) code coverage builds when we already know that the unit tests for most builds pass.

While this does mean that the unit tests will run with a slight delay (the `Sniff` stage has to finish before they start), it also means that we:
* Get code style errors reported earlier as it's been moved to be the first stage and the build will just stop if any are found.
* We won't be wasting Travis's resources on builds which will have to be re-run anyway.
* The output of the Travis jobs will be a lot easier to decipher as it only shows the output related to that particular stage.

Ref: https://docs.travis-ci.com/user/build-stages/

Note that `Allowed failures` is no longer listed as a separate block in the Travis result overview, but is _is_ respected.

For more discussion about this:
* travis-ci/travis-ci#7789
* https://travis-ci.community/t/always-show-allow-failures-allowed-failures-when-build-stages-are-used/217
* https://travis-ci.community/t/work-out-kinks-in-interactions-between-stages-allow-fail-and-fast-finish/1090
* travis-ci/travis-ci#9677

In addition to this, this PR makes the following changes to the Travis script:
* Removes `sudo: false` as it is no longer supported.
    This switches the build form container-based builds to VM based.
    See: https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration
* Groups the two separate `cache` directives together.
* Simplifies the setting of the `env` variable for the PHPUnit version for those PHP versions which cannot use the Travis image default PHPUnit version.
* Removes the global `COVERALLS_VERSION` `env` variable which is no longer needed.
* Updates the PHPCS versions in the "mix it up" builds.
* Removes `composer self-update` which is no longer needed. Travis does this by default.
* Adds `--no-update` to the additional Composer requires so we only invoke `composer install` once, instead of potentially four times.
* Updates the PHP `lint` command to have simpler output (no more the long list of files).
* Attempts to make the script more readable by using multi-line conditions whenever the line would become quite long.

It also removes the `phpunit-travis.xml` file and moves the additional config into the normal `phpunit.xml.dist` file. To run PHPUnit without code coverage, either run it on a PHP version without Xdebug enabled or run it with the `--no-coverage` command-line flag.

This flag has also been added to the relevant commands in the Travis build script.

wimg

wimg approved these changes May 29, 2019