Skip to content

Commit

Permalink
Support PHP 8 in Ignition v1 (#329)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
driesvints authored Oct 30, 2020
1 parent 1967415 commit 1da1705
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Run tests

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

Expand All @@ -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]
Expand All @@ -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.*
Expand All @@ -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
Expand All @@ -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 }}
Expand All @@ -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 }}
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,4 @@
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
17 changes: 16 additions & 1 deletion src/SolutionProviders/MergeConflictSolutionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions tests/Solutions/MergeConflictSolutionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1da1705

Please sign in to comment.