From 72e754d0f0d8ee36f4090d717e0e6413298142c5 Mon Sep 17 00:00:00 2001 From: Sebastian Blum Date: Mon, 8 Jan 2018 15:31:04 +0100 Subject: [PATCH 1/2] extending and enhancing the travis build matrix - fixed FlysystemTests - fix SymfonyFrameworkTest to use Kernel constants - use fly system depe in travis - test with --no-dev composer parameter - only install all symfony packages if version is specified - added matrix prefer-lowest - skip tests if browser-kit package is not available. - skip tests if package is not available. - skip doctrine/cache tests. - skip tests if symfony/form is missing - skip if twig/twig is missing. - added build to test dependencies - added missing use statement - skip if symfony/yaml is missing. - skip if doctrine/orm is missing. - Update .coveralls.yml - only 1 build with code coverage - removed hirak/prestissimo:^0.3 (no speed benefit) - running prefer-lowest also on the lowest php version - using phpenv to disable xdebug --- .coveralls.yml | 4 +- .travis.yml | 45 +++++++++---- .travis/composer/config.json | 10 --- .travis/exec-after.bash | 24 ------- .travis/exec-before.bash | 24 ------- .travis/inc-functions.bash | 66 ------------------- .travis/inc-variables.bash | 5 -- .../Loader/AbstractDoctrineLoaderTest.php | 4 ++ Tests/Binary/Loader/FlysystemLoaderTest.php | 25 ++++--- .../LiipImagineExtensionTest.php | 4 ++ Tests/Form/Type/ImageTypeTest.php | 8 +++ Tests/Functional/AbstractWebTestCase.php | 13 ++++ .../Cache/Resolver/AmazonS3ResolverTest.php | 4 ++ .../Cache/Resolver/CacheResolverTest.php | 9 +++ .../Loader/DownscaleFilterLoaderTest.php | 44 ++++++------- Tests/Templating/FilterExtensionTest.php | 4 ++ .../Framework/SymfonyFrameworkTest.php | 8 +-- composer.json | 1 - 18 files changed, 117 insertions(+), 185 deletions(-) delete mode 100644 .travis/composer/config.json delete mode 100644 .travis/exec-after.bash delete mode 100644 .travis/exec-before.bash delete mode 100644 .travis/inc-functions.bash delete mode 100644 .travis/inc-variables.bash diff --git a/.coveralls.yml b/.coveralls.yml index 68e2b531d..64422dd3d 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1,4 +1,4 @@ ---- - +service_name: travis-ci +src_dir: . coverage_clover : var/build/clover.xml json_path : var/build/coveralls-upload.json diff --git a/.travis.yml b/.travis.yml index d61108eb6..f640e7bd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,34 +9,55 @@ cache: env: global: - SYMFONY_DEPRECATIONS_HELPER="weak_vendors" + - ENABLE_CODE_COVERAGE="false" matrix: fast_finish: true include: - php: 7.1 - env: SYMFONY_VERSION=4.0.* - php: 7.1 + env: + - SYMFONY_VERSION=4.0.* + - COMPOSER_FLAGS="--prefer-lowest" + - DEPENDENCIES="symfony/phpunit-bridge:^4" + - php: 7.2 + - php: 7.2 env: SYMFONY_VERSION=3.4.* - php: 7.2 env: SYMFONY_VERSION=4.0.* - php: 7.2 - env: SYMFONY_VERSION=3.4.* + env: + - DEPENDENCIES="symfony/phpunit-bridge:^4" + - COMPOSER_UPDATE_OPTIONS="--no-dev" - php: 7.2 - env: SYMFONY_VERSION=dev-master + env: + - ENABLE_CODE_COVERAGE="true" + - php: 7.2 + env: + - SYMFONY_VERSION=dev-master + - STABILITY=dev - php: nightly - env: SYMFONY_VERSION=4.0.* - allow_failures: - - env: SYMFONY_VERSION=dev-master + allow_failures: + - env: + - ENABLE_CODE_COVERAGE="true" + - env: + - SYMFONY_VERSION=dev-master + - STABILITY=dev - php: nightly - + before_install: - - bash ./.travis/exec-before.bash + - if [[ "$SYMFONY_VERSION" != "" ]]; then travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS; fi; + - if [[ "$DEPENDENCIES" != "" ]]; then travis_retry composer require ${DEPENDENCIES} --no-update $COMPOSER_FLAGS; fi; + - if [[ "$STABILITY" != "" ]]; then composer config minimum-stability $STABILITY; fi + - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then phpenv config-rm xdebug.ini; fi; + - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then travis_retry composer require satooshi/php-coveralls:^1.0 --no-update $COMPOSER_FLAGS; fi; install: - - travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" $COMPOSER_FLAGS + - travis_retry composer update --prefer-dist --no-interaction --no-suggest --no-progress --ansi $COMPOSER_FLAGS $COMPOSER_UPDATE_OPTIONS + - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then travis_retry composer require --dev satooshi/php-coveralls; fi script: - - ./vendor/bin/simple-phpunit -vvv + - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit -v; fi; -after_script: - - bash ./.travis/exec-after.bash +after_success: + - if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then php vendor/bin/coveralls -v --config .coveralls.yml; fi; diff --git a/.travis/composer/config.json b/.travis/composer/config.json deleted file mode 100644 index 436403f60..000000000 --- a/.travis/composer/config.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "config": { - "preferred-install": { - "*": "dist" - }, - "prestissimo": { - "insecure": true - } - } -} diff --git a/.travis/exec-after.bash b/.travis/exec-after.bash deleted file mode 100644 index 39d0dbb70..000000000 --- a/.travis/exec-after.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# exit if any statement returns a non-true value -set -e - -# determine path to this script -readonly SELF_DIR_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" - -# source variables and functions files -source "${SELF_DIR_PATH}inc-variables.bash" -source "${SELF_DIR_PATH}inc-functions.bash" - -# -# perform different operations depending on the environment -# -function main() -{ - out_main "Running 'exec-after' operations" - - send_coveralls_statistics -} - -# go! -main diff --git a/.travis/exec-before.bash b/.travis/exec-before.bash deleted file mode 100644 index d1b217088..000000000 --- a/.travis/exec-before.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# exit if any statement returns a non-true value -set -e - -# determine path to this script -readonly SELF_DIR_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" - -# source variables and functions files -source "${SELF_DIR_PATH}inc-variables.bash" -source "${SELF_DIR_PATH}inc-functions.bash" - -# -# perform different operations depending on the environment -# -function main() -{ - out_main "Running 'exec-before' operations" - - initialize_prestissimo -} - -# go! -main diff --git a/.travis/inc-functions.bash b/.travis/inc-functions.bash deleted file mode 100644 index cc795f784..000000000 --- a/.travis/inc-functions.bash +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -# -# output text to console -# -function out_line() -{ - printf "[%d] %s...\n" $(date +%s) "${1}" -} - -# -# output main text to console -# -function out_main() -{ - out_line "${1^^}" -} - -# -# configure the prestissimo package -# -function configure_prestissimo() -{ - local composer_reqs="${1}" - local composer_orig="${TRAVIS_BUILD_DIR}/.travis/composer/config.json" - local composer_dest="${HOME}/.composer/config.json" - - out_line "Configuring '${composer_reqs}' in '${composer_dest}'" - if [[ ! -d "$(dirname ${composer_dest})" ]]; then - mkdir "$(dirname ${composer_dest})" - fi - cp "${composer_orig}" "${composer_dest}" -} - -# -# require the prestissimo package using composer -# -function require_prestissimo() -{ - local composer_reqs="${1}" - - out_line "Requiring '${composer_reqs}'" - composer global require "${composer_reqs}" -} - -# -# initialize the prestissimo package -# -function initialize_prestissimo() -{ - local composer_reqs="hirak/prestissimo:^0.3" - - configure_prestissimo "${composer_reqs}" - require_prestissimo "${composer_reqs}" -} - -# -# send coveralls statistics using the required binary -# -function send_coveralls_statistics() -{ - local coveralls_bin="${TRAVIS_BUILD_DIR}/bin/coveralls" - - out_line "Sending Coveralls coverage using '${coveralls_bin}'" - ${coveralls_bin} -vvv -} diff --git a/.travis/inc-variables.bash b/.travis/inc-variables.bash deleted file mode 100644 index 4e26b563b..000000000 --- a/.travis/inc-variables.bash +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -# path to travis php configuration file -CONF_PATH_PHP7="${HOME}/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini" -CONF_PATH_HHVM="/etc/hhvm/php.ini" diff --git a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php index 16a7f23e0..c9766c44a 100644 --- a/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php +++ b/Tests/Binary/Loader/AbstractDoctrineLoaderTest.php @@ -32,6 +32,10 @@ class AbstractDoctrineLoaderTest extends \PHPUnit\Framework\TestCase public function setUp() { + if (!interface_exists(ObjectManager::class)) { + $this->markTestSkipped('Requires the doctrine/orm package.'); + } + $this->om = $this ->getMockBuilder(ObjectManager::class) ->getMock(); diff --git a/Tests/Binary/Loader/FlysystemLoaderTest.php b/Tests/Binary/Loader/FlysystemLoaderTest.php index 2d6e7f2e9..f485c0f76 100644 --- a/Tests/Binary/Loader/FlysystemLoaderTest.php +++ b/Tests/Binary/Loader/FlysystemLoaderTest.php @@ -38,24 +38,23 @@ public function setUp() $this->flyFilesystem = new Filesystem(new Local($this->fixturesPath)); } - public function getLoader() + /** + * @return FlysystemLoader + */ + public function getFlysystemLoader() { return new FlysystemLoader(ExtensionGuesser::getInstance(), $this->flyFilesystem); } - /** - * @depends getLoader - */ - public function testShouldImplementLoaderInterface(LoaderInterface $loader) + public function testShouldImplementLoaderInterface() { - $this->assertInstanceOf(LoaderInterface::class, $loader); + $this->assertInstanceOf(LoaderInterface::class, $this->getFlysystemLoader()); } - /** - * @depends getLoader - */ - public function testReturnImageContentOnFind(LoaderInterface $loader) + public function testReturnImageContentOnFind() { + $loader = $this->getFlysystemLoader(); + $this->assertSame( file_get_contents($this->fixturesPath.'/assets/cats.jpeg'), $loader->find('assets/cats.jpeg')->getContent() @@ -63,13 +62,13 @@ public function testReturnImageContentOnFind(LoaderInterface $loader) } /** - * @depends getLoader - * * @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException * @expectedExceptionMessageRegExp {Source image .+ not found} */ - public function testThrowsIfInvalidPathGivenOnFind(LoaderInterface $loader) + public function testThrowsIfInvalidPathGivenOnFind() { + $loader = $this->getFlysystemLoader(); + $loader->find('invalid.jpeg'); } } diff --git a/Tests/DependencyInjection/LiipImagineExtensionTest.php b/Tests/DependencyInjection/LiipImagineExtensionTest.php index a370203ed..dd3b70432 100644 --- a/Tests/DependencyInjection/LiipImagineExtensionTest.php +++ b/Tests/DependencyInjection/LiipImagineExtensionTest.php @@ -109,6 +109,10 @@ protected function createEmptyConfiguration() protected function createFullConfiguration() { + if (!class_exists(Parser::class)) { + $this->markTestSkipped('Requires the symfony/yaml package.'); + } + $this->containerBuilder = new ContainerBuilder(); $loader = new LiipImagineExtension(); $loader->addLoaderFactory(new FileSystemLoaderFactory()); diff --git a/Tests/Form/Type/ImageTypeTest.php b/Tests/Form/Type/ImageTypeTest.php index e362f42ae..6320c4206 100644 --- a/Tests/Form/Type/ImageTypeTest.php +++ b/Tests/Form/Type/ImageTypeTest.php @@ -13,6 +13,7 @@ use Liip\ImagineBundle\Form\Type\ImageType; use Liip\ImagineBundle\Tests\AbstractTest; +use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; @@ -23,6 +24,13 @@ */ class ImageTypeTest extends AbstractTest { + protected function setUp() + { + if (!class_exists(AbstractType::class)) { + $this->markTestSkipped('Requires the symfony/form package.'); + } + } + public function testGetName() { $type = new ImageType(); diff --git a/Tests/Functional/AbstractWebTestCase.php b/Tests/Functional/AbstractWebTestCase.php index b96b93deb..6cf2c397e 100644 --- a/Tests/Functional/AbstractWebTestCase.php +++ b/Tests/Functional/AbstractWebTestCase.php @@ -12,9 +12,22 @@ namespace Liip\ImagineBundle\Tests\Functional; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\BrowserKit\Client; abstract class AbstractWebTestCase extends WebTestCase { + /** + * {@inheritdoc} + */ + public static function createClient(array $options = array(), array $server = array()) + { + if (!class_exists(Client::class)) { + self::markTestSkipped("Requires the symfony/browser-kit package."); + } + + return parent::createClient($options, $server); + } + /** * @return string */ diff --git a/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php b/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php index 39be2dc60..d0a05ca8b 100644 --- a/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/AmazonS3ResolverTest.php @@ -340,6 +340,10 @@ protected function createCFResponseMock($ok = true) */ protected function createAmazonS3Mock() { + if (!class_exists(\AmazonS3::class)) { + $this->markTestSkipped('Requires the amazonwebservices/aws-sdk-for-php package.'); + } + return $this ->getMockBuilder(\AmazonS3::class) ->disableOriginalConstructor() diff --git a/Tests/Imagine/Cache/Resolver/CacheResolverTest.php b/Tests/Imagine/Cache/Resolver/CacheResolverTest.php index 5fdcff605..0329ce17c 100644 --- a/Tests/Imagine/Cache/Resolver/CacheResolverTest.php +++ b/Tests/Imagine/Cache/Resolver/CacheResolverTest.php @@ -25,6 +25,15 @@ class CacheResolverTest extends AbstractTest protected $filter = 'thumbnail'; protected $path = 'MadCat2.jpeg'; protected $webPath = '/media/cache/thumbnail/MadCat2.jpeg'; + + protected function setUp() + { + if (!class_exists(ArrayCache::class)) { + $this->markTestSkipped('Requires the doctrine/cache package.'); + } + + parent::setUp(); + } public function testResolveIsSavedToCache() { diff --git a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php index 324f9ef8b..58955fa46 100644 --- a/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php +++ b/Tests/Imagine/Filter/Loader/DownscaleFilterLoaderTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Liip\ImagineBundle\Tests\Filter; +namespace Liip\ImagineBundle\Tests\Image\Filter\Loader; use Imagine\Image\Box; use Liip\ImagineBundle\Imagine\Filter\Loader\DownscaleFilterLoader; @@ -22,7 +22,25 @@ */ class DownscaleFilterLoaderTest extends AbstractTest { - public function downscale() + /** + * @dataProvider provideSizes + */ + public function testDontScaleUp($initialSize, $resultSize) + { + $this->assertLessThanOrEqual($initialSize->getHeight(), $resultSize->getHeight()); + $this->assertLessThanOrEqual($initialSize->getWidth(), $resultSize->getWidth()); + } + + /** + * @dataProvider provideSizes + */ + public function testFitBoundingBox($initialSize, $resultSize) + { + $this->assertLessThanOrEqual(100, $resultSize->getHeight()); + $this->assertLessThanOrEqual(90, $resultSize->getWidth()); + } + + public function provideSizes() { $loader = new DownscaleFilterLoader(); @@ -41,26 +59,6 @@ public function downscale() $loader->load($image, array('max' => array(100, 90))); - return array($initialSize, $resultSize); - } - - /** - * @depends downscale - */ - public function testDontScaleUp($sizes) - { - list($initialSize, $resultSize) = $sizes; - $this->assertLessThanOrEqual($initialSize->getHeight(), $resultSize->getHeight()); - $this->assertLessThanOrEqual($initialSize->getWidth(), $resultSize->getWidth()); - } - - /** - * @depends downscale - */ - public function testFitBoundingBox($sizes) - { - list($initialSize, $resultSize) = $sizes; - $this->assertLessThanOrEqual(100, $resultSize->getHeight()); - $this->assertLessThanOrEqual(90, $resultSize->getWidth()); + yield [$initialSize, $resultSize]; } } diff --git a/Tests/Templating/FilterExtensionTest.php b/Tests/Templating/FilterExtensionTest.php index c04e90cad..bbfd02022 100644 --- a/Tests/Templating/FilterExtensionTest.php +++ b/Tests/Templating/FilterExtensionTest.php @@ -37,6 +37,10 @@ public function testInstanceOfTwigFilter() */ protected function createTemplatingMock(CacheManager $manager = null) { + if (!class_exists(\Twig_Extension::class)) { + $this->markTestSkipped('Requires the twig/twig package.'); + } + $mock = new FilterExtension($manager ?: $this->createCacheManagerMock()); $this->assertInstanceOf(FilterExtension::class, $mock); diff --git a/Tests/Utility/Framework/SymfonyFrameworkTest.php b/Tests/Utility/Framework/SymfonyFrameworkTest.php index 402f67ed0..6fb256368 100644 --- a/Tests/Utility/Framework/SymfonyFrameworkTest.php +++ b/Tests/Utility/Framework/SymfonyFrameworkTest.php @@ -12,6 +12,7 @@ namespace Liip\ImagineBundle\Tests\Utility\Framework; use Liip\ImagineBundle\Utility\Framework\SymfonyFramework; +use Symfony\Component\HttpKernel\Kernel; /** * @covers \Liip\ImagineBundle\Utility\Framework\SymfonyFramework @@ -20,11 +21,8 @@ class SymfonyFrameworkTest extends \PHPUnit\Framework\TestCase { public function testKernelComparisonForCurrentKernel() { - if (1 !== preg_match('{(?[0-9]+)\.(?[0-9]+)\.(?[0-9x]+)(?:-dev)?}', getenv('SYMFONY_VERSION'), $matches)) { - $this->markTestSkipped('Requires environment variable SYMFONY_VERSION with value matching "[0-9].[0-9].[0-9x](-dev)?"'); - } - - list($major, $minor) = [$matches['major'], $matches['minor']]; + $major = Kernel::MAJOR_VERSION; + $minor = Kernel::MINOR_VERSION; $this->assertTrue(SymfonyFramework::isKernelGreaterThanOrEqualTo($major, $minor)); $this->assertFalse(SymfonyFramework::isKernelLessThan($major, $minor)); diff --git a/composer.json b/composer.json index 06d946eb2..125741cec 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ "enqueue/enqueue-bundle": "^0.7|^0.8", "league/flysystem": "^1.0", "psr/log": "^1.0", - "satooshi/php-coveralls": "^1.0", "symfony/browser-kit": "^3.0|^4.0", "symfony/console": "^3.0|^4.0", "symfony/dependency-injection": "^3.0|^4.0", From 3253b6d348200628519de73059c9fd51dc3cf0ab Mon Sep 17 00:00:00 2001 From: Rob Frawley 2nd Date: Tue, 30 Jan 2018 16:34:11 -0500 Subject: [PATCH 2/2] fix builds without xdebug config ini and fix travis indentation --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index f640e7bd2..661decb25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ matrix: - php: nightly allow_failures: - env: - - ENABLE_CODE_COVERAGE="true" + - ENABLE_CODE_COVERAGE="true" - env: - SYMFONY_VERSION=dev-master - STABILITY=dev @@ -49,7 +49,7 @@ before_install: - if [[ "$SYMFONY_VERSION" != "" ]]; then travis_retry composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update $COMPOSER_FLAGS; fi; - if [[ "$DEPENDENCIES" != "" ]]; then travis_retry composer require ${DEPENDENCIES} --no-update $COMPOSER_FLAGS; fi; - if [[ "$STABILITY" != "" ]]; then composer config minimum-stability $STABILITY; fi - - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then phpenv config-rm xdebug.ini; fi; + - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then phpenv config-rm xdebug.ini || true; fi; - if [[ "$ENABLE_CODE_COVERAGE" != "true" && "$TRAVIS_EVENT_TYPE" != "cron" ]]; then travis_retry composer require satooshi/php-coveralls:^1.0 --no-update $COMPOSER_FLAGS; fi; install: