From 1da1705e7f6b24ed45af05461463228da424e14f Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Fri, 30 Oct 2020 14:40:01 +0100 Subject: [PATCH] Support PHP 8 in Ignition v1 (#329) * Support PHP 8 * Trigger builds on pull requests * Only run Slack webhook when url is set * Use proper syntax * Try different syntax * use env * revert * wip * Remove CS Fixer * Update actions * Update mockery * Fix MergeConflictSolutionProvider for PHP 8 * ext-fileinfo * update php extensions * fileinfo --- .github/workflows/run-tests.yml | 23 +++++++++++++------ composer.json | 5 ++-- phpunit.xml.dist | 5 ---- .../MergeConflictSolutionProvider.php | 17 +++++++++++++- .../MergeConflictSolutionProviderTest.php | 1 + 5 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a343f9a4..e61feddb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -2,6 +2,7 @@ name: Run tests on: push: + pull_request: schedule: - cron: '0 0 * * *' @@ -11,7 +12,7 @@ jobs: strategy: matrix: - php: [7.4, 7.3, 7.2] + php: [8.0, 7.4, 7.3, 7.2] laravel: [6.*, 5.8.*, 5.7.*, 5.6.*, 5.5.*] dependency-version: [prefer-lowest, prefer-stable] os: [ubuntu-latest, windows-latest] @@ -27,6 +28,14 @@ jobs: - laravel: 5.5.* testbench: 3.5.* exclude: + - laravel: 5.8.* + php: 8.0 + - laravel: 5.7.* + php: 8.0 + - laravel: 5.6.* + php: 8.0 + - laravel: 5.5.* + php: 8.0 - laravel: 5.7.* php: 7.4 - laravel: 5.6.* @@ -38,13 +47,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Setup PHP - uses: shivammathur/setup-php@v1 + uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extension-csv: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo coverage: none - name: Install dependencies @@ -57,7 +66,7 @@ jobs: - name: Send Slack notification uses: 8398a7/action-slack@v2 - if: failure() + if: ${{ failure() && !! env.SLACK_WEBHOOK }} with: status: ${{ job.status }} author_name: ${{ github.actor }} @@ -79,10 +88,10 @@ jobs: - name: Execute tests run: yarn run jest - + - name: Send Slack notification uses: 8398a7/action-slack@v2 - if: failure() + if: ${{ failure() && !! env.SLACK_WEBHOOK }} with: status: ${{ job.status }} author_name: ${{ github.actor }} diff --git a/composer.json b/composer.json index 27f41961..ad7e5802 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "homepage": "https://github.com/facade/ignition", "license": "MIT", "require": { - "php": "^7.1", + "php": "^7.1|^8.0", "ext-json": "*", "ext-mbstring": "*", "facade/flare-client-php": "^1.3", @@ -23,8 +23,7 @@ "symfony/var-dumper": "^3.4 || ^4.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.14", - "mockery/mockery": "^1.2", + "mockery/mockery": "~1.3.3|^1.4.2", "orchestra/testbench": "^3.5 || ^3.6 || ^3.7 || ^3.8 || ^4.0" }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 100dc964..f5c69538 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,9 +14,4 @@ tests - - - src/ - - diff --git a/src/SolutionProviders/MergeConflictSolutionProvider.php b/src/SolutionProviders/MergeConflictSolutionProvider.php index 44fd64e6..ed532980 100644 --- a/src/SolutionProviders/MergeConflictSolutionProvider.php +++ b/src/SolutionProviders/MergeConflictSolutionProvider.php @@ -17,7 +17,7 @@ public function canSolve(Throwable $throwable): bool return false; } - if (! Str::startsWith($throwable->getMessage(), 'syntax error, unexpected \'<<\'')) { + if (! $this->hasMergeConflictExceptionMessage($throwable)) { return false; } @@ -58,4 +58,19 @@ private function getCurrentBranch(string $directory): string return $branch; } + + protected function hasMergeConflictExceptionMessage(Throwable $throwable): bool + { + // For PHP 7.x and below + if (Str::startsWith($throwable->getMessage(), 'syntax error, unexpected \'<<\'')) { + return true; + } + + // For PHP 8+ + if (Str::startsWith($throwable->getMessage(), 'syntax error, unexpected token "<<"')) { + return true; + } + + return false; + } } diff --git a/tests/Solutions/MergeConflictSolutionProviderTest.php b/tests/Solutions/MergeConflictSolutionProviderTest.php index 568ecb05..7dfeacb6 100644 --- a/tests/Solutions/MergeConflictSolutionProviderTest.php +++ b/tests/Solutions/MergeConflictSolutionProviderTest.php @@ -25,6 +25,7 @@ public function it_can_solve_merge_conflict_exception() } catch (ParseError $error) { $exception = $error; } + $canSolve = app(MergeConflictSolutionProvider::class)->canSolve($exception); $this->assertTrue($canSolve);