travis: Rewrite checks and add PHP compatibility tests
- Remove HHVM HHVM recently announced ending PHP support: https://hhvm.com/blog/2018/09/12/end-of-php-support-future-of-hack.html "HHVM v3.30 will be the last release series where HHVM aims to support PHP. [...] Ultimately, we recommend that projects either migrate entirely to the Hack language, or entirely to PHP7 and the PHP runtime." RSS-Bridge never "officially" supported HHVM, so support can be removed. - Use composer for all versions PHP 5.6 is using PEAR, while all other versions use Composer to manage packages and dependencies. This commit removes PEAR for PHP 5.6 in favor of Composer. This also simplifies the script. - Add PHP compatibility tests Uses https://github.com/PHPCompatibility/PHPCompatibility RSS-Bridge supports PHP 5.6 or higher. This commit adds tests to check compatibility and detect breaking changes. "phpcompatibility.xml" contains the ruleset. Notice: Technically RSS-Bridge requires PHP 5.6.1, but for some reason PHPCompatibility doesn't accept "5.6.1" for "testVersion". This is why INI_SCANNER_TYPED is excluded from tests. - Rearrange tests PHP 5.6: - Coding style (phpcs.xml) - PHP compatibility (phpcompatibility.xml) PHP 7.0: - Coding style (phpcs.xml) - Unit tests (phpunit.xml) - using stable release of PHPUnit PHP nightly: - Coding style (phpcs.xml) - Unit tests (phpunit.xml) - using latest version of PHPUnit - PHP compatibility - no exceptions for PHP 5.6+ - Documentation added to improve maintainability
This commit is contained in:
parent
7e3787a185
commit
a935e310ff
2 changed files with 66 additions and 12 deletions
31
.travis.yml
31
.travis.yml
|
@ -3,26 +3,35 @@ sudo: false
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
|
- composer global require dealerdirect/phpcodesniffer-composer-installer;
|
||||||
composer global require squizlabs/PHP_CodeSniffer;
|
- composer global require phpcompatibility/php-compatibility;
|
||||||
else
|
# Use PHPUnit 6 for unit tests (stable), requires PHP 7
|
||||||
pear channel-update pear.php.net;
|
|
||||||
pear install PHP_CodeSniffer;
|
|
||||||
fi
|
|
||||||
- if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
|
- if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
|
||||||
composer global require phpunit/phpunit ^6;
|
composer global require phpunit/phpunit ^6;
|
||||||
fi
|
fi
|
||||||
|
# Use latest PHPUnit on nightly to detect breaking changes
|
||||||
|
- if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
|
||||||
|
composer global require phpunit/phpunit;
|
||||||
|
fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- phpenv rehash
|
- phpenv rehash
|
||||||
- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
|
# Run PHP_CodeSniffer on all versions
|
||||||
/home/travis/.composer/vendor/bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
|
- ~/.composer/vendor/bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
|
||||||
else
|
# Check PHP compatibility for the lowest supported version
|
||||||
phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
|
- if [[ $TRAVIS_PHP_VERSION == "5.6" ]]; then
|
||||||
|
~/.composer/vendor/bin/phpcs . --standard=phpcompatibility.xml --warning-severity=0 --extensions=php -p;
|
||||||
fi
|
fi
|
||||||
|
# Run unit tests (stable)
|
||||||
- if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
|
- if [[ $TRAVIS_PHP_VERSION == "7.0" ]]; then
|
||||||
phpunit --configuration=phpunit.xml --include-path=lib/;
|
phpunit --configuration=phpunit.xml --include-path=lib/;
|
||||||
fi
|
fi
|
||||||
|
# Run unit tests (latest/nightly)
|
||||||
|
# Check PHP compatibility for all versions, starting at the lowest supported version in order to detect breaking changes
|
||||||
|
- if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
|
||||||
|
phpunit --configuration=phpunit.xml --include-path=lib/;
|
||||||
|
~/.composer/vendor/bin/phpcs . --standard=PHPCompatibility --warning-severity=0 --extensions=php -p --runtime-set testVersion 5.6-;
|
||||||
|
fi
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
@ -30,9 +39,7 @@ matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
- php: hhvm
|
|
||||||
- php: nightly
|
- php: nightly
|
||||||
|
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- php: hhvm
|
|
||||||
- php: nightly
|
- php: nightly
|
||||||
|
|
47
phpcompatibility.xml
Normal file
47
phpcompatibility.xml
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ruleset name="RSS-Bridge PHPCompatibility">
|
||||||
|
<description>Defines rules for PHPCompatibility</description>
|
||||||
|
<exclude-pattern>./static</exclude-pattern>
|
||||||
|
<exclude-pattern>./vendor</exclude-pattern>
|
||||||
|
|
||||||
|
<!-- Run against the PHPCompatibility ruleset -->
|
||||||
|
<!--
|
||||||
|
|
||||||
|
-->
|
||||||
|
<config name="testVersion" value="5.6"/>
|
||||||
|
<rule ref="PHPCompatibility">
|
||||||
|
<!--
|
||||||
|
"PHP 7 changes how most errors are reported by PHP. Instead of reporting
|
||||||
|
errors through the traditional error reporting mechanism used by PHP 5,
|
||||||
|
most errors are now reported by throwing Error exceptions."
|
||||||
|
|
||||||
|
from: http://php.net/manual/en/language.errors.php7.php
|
||||||
|
|
||||||
|
Skip this check for PHP 5.6 in order to support PHP 7.x
|
||||||
|
|
||||||
|
Catch Exception and Error separately to support both versions.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
<code>
|
||||||
|
try {
|
||||||
|
// Run your code here
|
||||||
|
} catch(Error $e) {
|
||||||
|
// Handle errors (PHP 7.0+)
|
||||||
|
} catch(Exception $e) {
|
||||||
|
// Handle exceptions (PHP 5.6+)
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
-->
|
||||||
|
<exclude name="PHPCompatibility.Classes.NewClasses.errorFound"/>
|
||||||
|
<!--
|
||||||
|
RSS-Bridge uses parse_ini_file with INI_SCANNER_TYPED to load configuration
|
||||||
|
settings. INI_SCANNER_TYPED was added in PHP 5.6.1. Skip checking for that
|
||||||
|
specific constant.
|
||||||
|
|
||||||
|
References: http://php.net/manual/de/function.parse-ini-file.php
|
||||||
|
-->
|
||||||
|
<exclude name="PHPCompatibility.Constants.NewConstants.ini_scanner_typedFound"/>
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
Loading…
Reference in a new issue