Skip to content

Commit

Permalink
✨ Support Laravel 8 (#143)
Browse files Browse the repository at this point in the history
Co-authored-by: Erik Gaal <[email protected]>
  • Loading branch information
erikgaal and erikgaal authored Feb 4, 2021
1 parent b21d115 commit 3f120d9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 17 deletions.
23 changes: 14 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: run-tests
name: Tests

on: [push, pull_request]

Expand All @@ -9,10 +9,13 @@ jobs:
fail-fast: false
matrix:
php: [7.2, 7.3, 7.4]
laravel: [^6.0, ^7.0]
laravel: [^6.0, ^7.0, ^8.0]
stability: [prefer-lowest, prefer-stable]
exclude:
- laravel: ^8.0
php: 7.2

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}
name: PHP ${{ matrix.php }} on L${{ matrix.laravel }} - ${{ matrix.stability }}

steps:
- name: Checkout code
Expand All @@ -31,13 +34,15 @@ jobs:
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefix-dist --no-interaction --no-suggest
- name: Remove laravel/legacy-factories
if: ${{ matrix.laravel != '^8.0' }}
run: composer remove --dev "laravel/legacy-factories" --no-interaction --no-update

- name: Set Laravel version
run: composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update

- name: Run static analysis
run: vendor/bin/phpstan analyse
- name: Install dependencies
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-suggest

- name: Run tests
run: vendor/bin/phpunit
44 changes: 44 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Static analysis

on: [push, pull_request]

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4]

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Determine composer cache directory
id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"

- name: Cache dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: composer-${{ matrix.php }}-${{ hashFiles('composer.*') }}
restore-keys: |
composer-${{ matrix.php }}-
composer-
- name: Install dependencies
run: composer update --no-interaction --no-progress --optimize-autoloader

- name: Run static analysis
if: ${{ matrix.analyse }}
run: vendor/bin/phpstan analyse

- name: Run tests
run: vendor/bin/phpunit
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
}
],
"require": {
"php": "^7.1.3",
"php": "^7.2",
"ext-json": "*",
"illuminate/support": "^6.0|^7.0",
"illuminate/support": "^6.0|^7.0|^8.0",
"webonyx/graphql-php": "^0.13.0"
},
"require-dev": {
"fzaninotto/faker": "^1.9",
"mockery/mockery": "^1.2",
"nunomaduro/larastan": "^0.5.0",
"orchestra/testbench": "^4.0|^5.0",
"fakerphp/faker": "^1.9",
"laravel/legacy-factories": "^1.1",
"mockery/mockery": "^1.3",
"nunomaduro/larastan": "^0.7.0",
"orchestra/testbench": "^4.0|^5.0|^6.0",
"phpunit/phpunit": "^8.0|^9.0"
},
"minimum-stability": "dev",
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ parameters:
level: 0
paths:
- %currentWorkingDirectory%/src/
excludes_analyse:
- %currentWorkingDirectory%/src/macros/*
excludePaths:
- src/macros/*
5 changes: 5 additions & 0 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ protected function setUp(): void
$this->gate->policy(Models\Phone::class, Policies\PhonePolicy::class);
$this->gate->policy(Models\Comment::class, Policies\CommentPolicy::class);
$this->gate->policy(Models\Tag::class, Policies\TagPolicy::class);

// Disable policy name guessing for testing purposes.
$this->gate->guessPolicyNamesUsing(function () {
return null;
});
}

/**
Expand Down

0 comments on commit 3f120d9

Please sign in to comment.