From 4e1f8cf89dce57ef8c98b9ef05002d8c2dde069e Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 20 May 2020 14:39:14 +0200 Subject: [PATCH] Build tweaks --- .github/workflows/continuous-integration.yml | 73 ++++++++++++------- composer.json | 10 +-- composer.lock | 12 +-- phpunit.xml.dist | 1 - tests/Composer/Test/IO/ConsoleIOTest.php | 2 +- tests/Composer/Test/Util/ErrorHandlerTest.php | 6 +- tests/complete.phpunit.xml | 1 - 7 files changed, 64 insertions(+), 41 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ffd1f3433..6da8f1ead 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -10,7 +10,9 @@ on: env: COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --no-suggest --prefer-dist" - SYMFONY_PHPUNIT_VERSION: "" + COMPOSER_UPDATE_FLAGS: "" + SYMFONY_PHPUNIT_VERSION: "8.3" + SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1" jobs: tests: @@ -68,6 +70,30 @@ jobs: - name: "Checkout" uses: "actions/checkout@v2" + - name: "Install PHP 7.4 to prepare nightly builds" + if: "matrix.php-version == '8.0'" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + extensions: "intl" + ini-values: "memory_limit=-1, phar.readonly=0" + php-version: "7.4" + + - name: "Choose PHPUnit version" + if: "!startsWith(matrix.os, 'windows')" + run: | + if [ "${{ matrix.php-version }}" = "5.3" ] || [ "${{ matrix.php-version }}" = "5.4" ] || [ "${{ matrix.php-version }}" = "5.5" ]; then + echo "::set-env name=SYMFONY_PHPUNIT_VERSION::4.8"; + elif [ "${{ matrix.php-version }}" = "5.6" ]; then + echo "::set-env name=SYMFONY_PHPUNIT_VERSION::5.7"; + elif [ "${{ matrix.php-version }}" = "7.0" ]; then + echo "::set-env name=SYMFONY_PHPUNIT_VERSION::6.5"; + elif [ "${{ matrix.php-version }}" = "7.1" ]; then + echo "::set-env name=SYMFONY_PHPUNIT_VERSION::7.5"; + else + echo "::set-env name=SYMFONY_PHPUNIT_VERSION::8.3"; + fi + - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: @@ -87,28 +113,29 @@ jobs: key: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}-${{ hashFiles('**/composer.lock') }}" restore-keys: "php-${{ matrix.php-version }}-symfony-php-unit-version-${{ env.SYMFONY_PHPUNIT_VERSION }}" - - name: "Install highest dependencies from composer.json using composer binary provided by system" - if: "matrix.dependencies == 'highest'" - run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }}" + - name: "Handle lowest dependencies update" + if: "contains(matrix.dependencies, 'lowest')" + run: "echo \"::set-env name=COMPOSER_UPDATE_FLAGS::$COMPOSER_UPDATE_FLAGS --prefer-lowest\"" - - name: "Install highest dependencies from composer.json using composer binary provided by system, ignoring platform requirements" - if: "matrix.dependencies == 'highest-ignore'" - run: "composer config platform --unset && composer update ${{ env.COMPOSER_FLAGS }} --ignore-platform-reqs" + - name: "Handle ignore-platform-reqs dependencies update" + if: "contains(matrix.dependencies, 'ignore')" + run: "echo \"::set-env name=COMPOSER_FLAGS::$COMPOSER_FLAGS --ignore-platform-reqs\"" - - name: "Install lowest dependencies from composer.json using composer binary provided by system" - if: "matrix.dependencies == 'lowest'" - run: "composer update ${{ env.COMPOSER_FLAGS }} --prefer-lowest" + - name: "Remove platform config to get latest dependencies for current PHP version when build is not locked" + run: "composer config platform --unset" - - name: "Install lowest dependencies from composer.json using composer binary provided by system, ignoring platform requirements" - if: "matrix.dependencies == 'lowest-ignore'" - run: "composer update ${{ env.COMPOSER_FLAGS }} --prefer-lowest --ignore-platform-reqs" + - name: "Update dependencies from composer.json using composer binary provided by system" + if: "contains(matrix.dependencies, 'highest') || contains(matrix.dependencies, 'lowest')" + run: "composer update ${{ env.COMPOSER_UPDATE_FLAGS }} ${{ env.COMPOSER_FLAGS }}" - name: "Install dependencies from composer.lock using composer binary provided by system" if: "matrix.dependencies == 'locked'" run: "composer install ${{ env.COMPOSER_FLAGS }}" + - name: "Update Symfony's PHPUnitBridge to latest available for the current PHP always as it is not really a dependency of the project" + run: "composer update ${{ env.COMPOSER_FLAGS }} symfony/phpunit-bridge" + - name: "Run install again using composer binary from source" - if: "matrix.dependencies != 'highest-ignore'" run: "bin/composer install ${{ env.COMPOSER_FLAGS }}" - name: "Validate composer.json" @@ -117,21 +144,15 @@ jobs: - name: "Prepare git environment" run: "git config --global user.name composer && git config --global user.email composer@example.com" - - name: "Set SYMFONY_PHPUNIT_VERSION environment variable" - if: "matrix.php-version == '7.4'" - run: "echo \"::set-env name=SYMFONY_PHPUNIT_VERSION::7.5\"" + - name: "Pre-install PHPUnit using PHP 7.4 for PHP 8" + if: "matrix.php-version == '8.0'" + run: | + php7.4 vendor/bin/simple-phpunit install - name: "Run tests" - if: "matrix.php-version != '8.0' && matrix.php-version != '7.3'" + if: "matrix.php-version != '7.3'" run: "vendor/bin/simple-phpunit" - - name: "Run Complete test suite" + - name: "Run complete test suite on 7.3" if: "matrix.php-version == '7.3'" run: "vendor/bin/simple-phpunit --configuration tests/complete.phpunit.xml" - - - name: "Run tests for PHP 8" - if: "matrix.php-version == '8.0'" - run: | - bin/composer remove --dev symfony/phpunit-bridge --ignore-platform-reqs - bin/composer require phpunit/phpunit:^7.5 --ignore-platform-reqs --with-dependencies - vendor/bin/phpunit diff --git a/composer.json b/composer.json index 415df800f..7a670ecb0 100644 --- a/composer.json +++ b/composer.json @@ -24,17 +24,17 @@ "require": { "php": "^5.3.2 || ^7.0", "composer/ca-bundle": "^1.0", - "composer/semver": "^2.0@dev", + "composer/semver": "^2.1@dev", "composer/spdx-licenses": "^1.2", "composer/xdebug-handler": "^1.1", "justinrainbow/json-schema": "^3.0 || ^4.0 || ^5.0", "psr/log": "^1.0", "seld/jsonlint": "^1.4", "seld/phar-utils": "^1.0", - "symfony/console": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/filesystem": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/finder": "^2.7 || ^3.0 || ^4.0 || ^5.0", - "symfony/process": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/console": "^2.8.52 || ^3.4 || ^4.4 || ^5.0", + "symfony/filesystem": "^2.8.52 || ^3.4 || ^4.4 || ^5.0", + "symfony/finder": "^2.8.52 || ^3.4 || ^4.4 || ^5.0", + "symfony/process": "^2.8.52 || ^3.4 || ^4.4 || ^5.0", "react/promise": "^1.2 || ^2.7" }, "conflict": { diff --git a/composer.lock b/composer.lock index 4f27da9f3..f8c918820 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a5f07d1ae8479fae25dd57b2d966cd22", + "content-hash": "4661f272e877e4aaaaf1cf0848b891b7", "packages": [ { "name": "composer/ca-bundle", @@ -83,12 +83,12 @@ "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89" + "reference": "07a3e324e654298714fcecfbb4604e3ee0c6f3bd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89", - "reference": "594e5242ff1ba3aac2f4b8401d3f1ca1d781fd89", + "url": "https://api.github.com/repos/composer/semver/zipball/07a3e324e654298714fcecfbb4604e3ee0c6f3bd", + "reference": "07a3e324e654298714fcecfbb4604e3ee0c6f3bd", "shasum": "" }, "require": { @@ -96,7 +96,7 @@ }, "require-dev": { "phpstan/phpstan": "^0.12.19", - "phpunit/phpunit": "^4.5 || ^5.0.5 || ^7" + "symfony/phpunit-bridge": "^4.2 || ^5" }, "type": "library", "extra": { @@ -156,7 +156,7 @@ "type": "tidelift" } ], - "time": "2020-05-19T14:49:33+00:00" + "time": "2020-05-20T08:27:54+00:00" }, { "name": "composer/spdx-licenses", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 728125c15..75c2f3c74 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,6 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" - strict="false" processIsolation="false" stopOnFailure="false" bootstrap="tests/bootstrap.php" diff --git a/tests/Composer/Test/IO/ConsoleIOTest.php b/tests/Composer/Test/IO/ConsoleIOTest.php index ef5096300..1ff86170c 100644 --- a/tests/Composer/Test/IO/ConsoleIOTest.php +++ b/tests/Composer/Test/IO/ConsoleIOTest.php @@ -84,7 +84,7 @@ class ConsoleIOTest extends TestCase ->with( $this->callback(function ($messages) { $result = preg_match("[(.*)/(.*) First line]", $messages[0]) > 0; - $result &= preg_match("[(.*)/(.*) Second line]", $messages[1]) > 0; + $result = $result && preg_match("[(.*)/(.*) Second line]", $messages[1]) > 0; return $result; }), diff --git a/tests/Composer/Test/Util/ErrorHandlerTest.php b/tests/Composer/Test/Util/ErrorHandlerTest.php index 89cc8b4dc..ef501542e 100644 --- a/tests/Composer/Test/Util/ErrorHandlerTest.php +++ b/tests/Composer/Test/Util/ErrorHandlerTest.php @@ -46,7 +46,11 @@ class ErrorHandlerTest extends TestCase */ public function testErrorHandlerCaptureWarning() { - $this->setExpectedException('\ErrorException', 'array_merge'); + if (PHP_VERSION_ID >= 80000) { + $this->setExpectedException('TypeError', 'array_merge'); + } else { + $this->setExpectedException('ErrorException', 'array_merge'); + } array_merge(array(), 'string'); } diff --git a/tests/complete.phpunit.xml b/tests/complete.phpunit.xml index 30faf6837..14b2de093 100644 --- a/tests/complete.phpunit.xml +++ b/tests/complete.phpunit.xml @@ -10,7 +10,6 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" - strict="false" processIsolation="false" stopOnFailure="false" bootstrap="./bootstrap.php"