Improve Travis configuration

This commit will put the quality assurance tools that Travis executes
into a different stage.

It will make the build time increase in approximately one minute, but
the configuration will be way more explicit than it is today.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
Henrique Moody 2019-03-20 23:44:02 +01:00
parent 1303a935bf
commit 5aba4c8889
No known key found for this signature in database
GPG key ID: 221E9281655813A6
3 changed files with 58 additions and 44 deletions

View file

@ -1,51 +1,55 @@
sudo: false
language: php
php:
- 7.1
- 7.2
- 7.3
- nightly
cache:
directories:
- $HOME/.composer/cache
matrix:
include:
- php: 7.1
env: COMPOSER_ARGUMENTS="--prefer-lowest --prefer-stable"
- php: 7.1
- php: 7.2
env: PHPUNIT_COVERAGE_ARGUMENT="--coverage-clover=coverage.clover"
- php: 7.3
env: COMPOSER_ARGUMENTS="--ignore-platform-reqs"
- php: nightly
env: COMPOSER_ARGUMENTS="--ignore-platform-reqs"
allow_failures:
- php: nightly
fast_finish: true
before_install:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
before_script:
install:
- travis_retry composer install
- sudo locale-gen --no-purge --lang nl_NL.UTF-8
- sudo locale-gen --no-purge --lang pt_BR.UTF-8
- sudo locale-gen --no-purge --lang ru_RU.UTF-8
- pecl install uopz || echo "Cound not install uopz" 1>&2
- composer update --prefer-dist ${COMPOSER_ARGUMENTS}
script:
- vendor/bin/phpunit --configuration phpunit.xml.dist --verbose --colors ${PHPUNIT_COVERAGE_ARGUMENT}
- |
if [[ "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then
vendor/bin/docheader check library tests
fi
- |
if [[ "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then
vendor/bin/phpcs
fi
- |
if [[ "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then
vendor/bin/phpstan analyze
fi
- vendor/bin/phpunit --testsuite=unit --verbose --colors
- vendor/bin/phpunit --testsuite=integration --verbose --colors
after_script:
- |
if [[ ! -z "${PHPUNIT_COVERAGE_ARGUMENT}" ]]; then
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
fi
jobs:
allow_failures:
- php: nightly
include:
- stage: Quality assurance
env: CODE_COVERAGE
before_script:
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{.disabled,}
- if [[ ! $(php -m | grep -si xdebug) ]]; then echo "xdebug required for coverage"; exit 1; fi
script: vendor/bin/phpunit --coverage-clover ./clover.xml
after_script: wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover ./clover.xml
- stage: Quality assurance
env: DOCHEADER
install: travis_retry composer install
script: vendor/bin/docheader check library/ tests/
- stage: Quality assurance
env: CODE_STANDARD
install: travis_retry composer install
script: vendor/bin/phpcs
- stage: Quality assurance
env: STATIC_ANALYSIS
install: travis_retry composer install
script: vendor/bin/phpstan analyze

View file

@ -15,6 +15,7 @@ namespace Respect\Validation\Rules;
use Respect\Validation\Test\RuleTestCase;
use function setlocale;
use function sprintf;
use const LC_ALL;
/**
@ -114,7 +115,10 @@ final class NoTest extends RuleTestCase
{
setlocale(LC_ALL, $locale);
self::assertEquals($locale, setlocale(LC_ALL, 0));
if ($locale !== setlocale(LC_ALL, 0)) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
}
self::assertValidInput(new No(true), $input);
}
@ -127,7 +131,10 @@ final class NoTest extends RuleTestCase
{
setlocale(LC_ALL, $locale);
self::assertEquals($locale, setlocale(LC_ALL, 0));
if ($locale !== setlocale(LC_ALL, 0)) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
}
self::assertInvalidInput(new No(true), $input);
}
}

View file

@ -17,6 +17,7 @@ use Respect\Validation\Test\RuleTestCase;
use stdClass;
use function random_int;
use function setlocale;
use function sprintf;
use const LC_ALL;
use const PHP_INT_MAX;
@ -121,10 +122,11 @@ final class YesTest extends RuleTestCase
{
setlocale(LC_ALL, $locale);
$rule = new Yes(true);
if ($locale !== setlocale(LC_ALL, 0)) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
}
self::assertEquals($locale, setlocale(LC_ALL, 0));
self::assertTrue($rule->validate($input));
self::assertValidInput(new Yes(true), $input);
}
/**
@ -136,9 +138,10 @@ final class YesTest extends RuleTestCase
{
setlocale(LC_ALL, $locale);
$rule = new Yes(true);
if ($locale !== setlocale(LC_ALL, 0)) {
$this->markTestSkipped(sprintf('Could not set locale information to "%s"', $locale));
}
self::assertEquals($locale, setlocale(LC_ALL, 0));
self::assertFalse($rule->validate($input));
self::assertInvalidInput(new Yes(true), $input);
}
}