Skip to content

Commit d3f2201

Browse files
committed
Add filament v5 support
1 parent 5f74b27 commit d3f2201

File tree

23 files changed

+394
-148
lines changed

23 files changed

+394
-148
lines changed

.github/workflows/phpstan.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ on:
88

99
jobs:
1010
phpstan:
11-
name: phpstan
1211
runs-on: ubuntu-latest
12+
name: PHPStan Latest
1313
steps:
14-
- uses: actions/checkout@v5
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.2'
19+
php-version: 8.5
2020
coverage: none
2121

22-
- name: Install composer dependencies
23-
uses: ramsey/composer-install@v3
22+
- name: Install dependencies
23+
env:
24+
XDEBUG_MODE: off
25+
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi
2426

2527
- name: Run PHPStan
26-
run: ./vendor/bin/phpstan --error-format=github
28+
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist --error-format=github

.github/workflows/run-tests.yml

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: "Run Tests"
1+
name: run-tests
22

33
on:
44
push:
@@ -8,49 +8,118 @@ on:
88

99
jobs:
1010
test:
11-
runs-on: ${{ matrix.os }}
11+
runs-on: ubuntu-latest
1212
strategy:
1313
fail-fast: true
1414
matrix:
15-
os: [ubuntu-latest, windows-latest]
16-
php: [8.4, 8.3, 8.2]
17-
laravel: [12.*, 11.*]
18-
stability: [prefer-lowest, prefer-stable]
1915
include:
20-
- laravel: 12.*
21-
testbench: 10.*
22-
carbon: 3.*
23-
collision: 8.*
24-
- laravel: 11.*
16+
- php: 8.2
17+
laravel: 11.*
18+
filament: 4.*
2519
testbench: 9.*
26-
carbon: 3.*
27-
collision: 8.*
20+
livewire: ^3.0
21+
pest: ^3.8
22+
pest_plugin_arch: ^3.1
23+
pest_plugin_laravel: ^3.1
24+
pest_plugin_livewire: ^3.1
25+
- php: 8.2
26+
laravel: 12.*
27+
filament: 4.*
28+
testbench: 10.*
29+
livewire: ^3.0
30+
pest: ^3.8
31+
pest_plugin_arch: ^3.1
32+
pest_plugin_laravel: ^3.1
33+
pest_plugin_livewire: ^3.1
34+
- php: 8.3
35+
laravel: 12.*
36+
filament: 5.*
37+
testbench: 10.*
38+
livewire: ^4.0
39+
pest: ^4.0
40+
pest_plugin_arch: ^4.0
41+
pest_plugin_laravel: ^4.0
42+
pest_plugin_livewire: ^4.0
43+
- php: 8.4
44+
laravel: 12.*
45+
filament: 5.*
46+
testbench: 10.*
47+
livewire: ^4.0
48+
pest: ^4.0
49+
pest_plugin_arch: ^4.0
50+
pest_plugin_laravel: ^4.0
51+
pest_plugin_livewire: ^4.0
52+
- php: 8.5
53+
laravel: 12.*
54+
filament: 5.*
55+
testbench: 10.*
56+
livewire: ^4.0
57+
pest: ^4.0
58+
pest_plugin_arch: ^4.0
59+
pest_plugin_laravel: ^4.0
60+
pest_plugin_livewire: ^4.0
2861

29-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
62+
name: P${{ matrix.php }} - L${{ matrix.laravel }}
3063

3164
steps:
3265
- name: Checkout code
33-
uses: actions/checkout@v5
66+
uses: actions/checkout@v4
67+
68+
- name: Validate composer.json and composer.lock
69+
run: composer validate --strict
70+
71+
- name: Cache Composer dependencies
72+
uses: actions/cache@v4
73+
with:
74+
path: vendor
75+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-${{ hashFiles('**/composer.lock') }}
76+
restore-keys: |
77+
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.filament }}-${{ matrix.testbench }}-${{ matrix.livewire }}-
78+
${{ runner.os }}-composer-
3479
3580
- name: Setup PHP
3681
uses: shivammathur/setup-php@v2
3782
with:
3883
php-version: ${{ matrix.php }}
39-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
40-
coverage: none
84+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, pcov
85+
coverage: pcov
4186

4287
- name: Setup problem matchers
4388
run: |
4489
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
4590
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
4691
4792
- name: Install dependencies
93+
env:
94+
XDEBUG_MODE: off
4895
run: |
49-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
50-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
96+
composer require \
97+
"laravel/framework:${{ matrix.laravel }}" \
98+
"orchestra/testbench:${{ matrix.testbench }}" \
99+
"filament/filament:${{ matrix.filament }}" \
100+
"livewire/livewire:${{ matrix.livewire }}" \
101+
"pestphp/pest:${{ matrix.pest }}" \
102+
"pestphp/pest-plugin-arch:${{ matrix.pest_plugin_arch }}" \
103+
"pestphp/pest-plugin-laravel:${{ matrix.pest_plugin_laravel }}" \
104+
"pestphp/pest-plugin-livewire:${{ matrix.pest_plugin_livewire }}" \
105+
--no-interaction --no-update --no-progress --ansi
106+
composer update --prefer-stable --prefer-dist --no-interaction --no-progress --ansi
107+
108+
- name: Prepare coverage directory
109+
run: mkdir -p build/logs
51110

52-
- name: List Installed Dependencies
53-
run: composer show -D
111+
- name: Execute tests with coverage
112+
run: vendor/bin/pest --coverage --coverage-clover build/logs/clover.xml
54113

55-
- name: Execute tests
56-
run: vendor/bin/pest --ci
114+
- name: Sanitize artifact name
115+
run: |
116+
LARAVEL_SAFE=$(echo "${{ matrix.laravel }}" | tr '*' 'x')
117+
FILAMENT_SAFE=$(echo "${{ matrix.filament }}" | tr '*' 'x')
118+
echo "ARTIFACT_NAME=coverage-${{ matrix.php }}-${LARAVEL_SAFE}-${FILAMENT_SAFE}" >> $GITHUB_ENV
119+
120+
- name: Upload coverage artifact
121+
uses: actions/upload-artifact@v4
122+
with:
123+
name: ${{ env.ARTIFACT_NAME }}
124+
path: build/logs/clover.xml
125+
if-no-files-found: error

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
.DS_Store
1+
**/.DS_Store
22
.idea
33
.phpunit.result.cache
4+
.phpunit.cache
45
.vscode
56
build
67
composer.lock

.phpunit.cache/test-results

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"pest_3.8.2","defects":[],"times":{"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.011,"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.062}}
1+
{"version":"pest_4.3.2","defects":{"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_can_render_the_edit_page":8,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_can_save_the_edit_page":7,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_show_search_results":7,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_show_record_switcher_options":7},"times":{"P\\Tests\\ArchTest::__pest_evaluable_it_will_not_use_debugging_functions":0.087,"P\\Tests\\ExampleTest::__pest_evaluable_it_can_test":0.002,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_can_render_the_edit_page":0.095,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_can_save_the_edit_page":0.109,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_show_search_results":0.099,"P\\Tests\\src\\Feature\\EditPageTest::__pest_evaluable_it_show_record_switcher_options":0.101}}

composer.json

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@
2323
],
2424
"require": {
2525
"php": "^8.2",
26-
"filament/filament": "^4.0",
27-
"filament/forms": "^4.0",
28-
"filament/tables": "^4.0",
26+
"filament/filament": "^4.0 || ^5.0",
27+
"filament/forms": "^4.0 || ^5.0",
28+
"filament/schemas": "^4.0 || ^5.0",
29+
"filament/tables": "^4.0 || ^5.0",
2930
"spatie/laravel-package-tools": "^1.15.0"
3031
},
3132
"require-dev": {
32-
"filament/upgrade": "^4.0",
33+
"larastan/larastan": "^3.5",
3334
"laravel/pint": "^1.0",
3435
"nunomaduro/collision": "^8.0",
35-
"larastan/larastan": "^3.5",
3636
"orchestra/testbench": "^10.0",
37-
"pestphp/pest": "^3.8",
38-
"pestphp/pest-plugin-arch": "^3.0",
39-
"pestphp/pest-plugin-laravel": "^3.0",
40-
"pestphp/pest-plugin-livewire": "^3.0",
37+
"pestphp/pest": "^4.0",
38+
"pestphp/pest-plugin-arch": "^4.0",
39+
"pestphp/pest-plugin-laravel": "^4.0",
40+
"pestphp/pest-plugin-livewire": "^4.0",
4141
"phpstan/extension-installer": "^1.4",
42+
"phpstan/phpstan": "^2.1",
4243
"phpstan/phpstan-deprecation-rules": "^2.0",
43-
"phpstan/phpstan-phpunit": "^2.0"
44+
"phpstan/phpstan-phpunit": "^2.0",
45+
"sinnbeck/laravel-dom-assertions": "^3.0"
4446
},
4547
"autoload": {
4648
"psr-4": {
@@ -49,14 +51,16 @@
4951
},
5052
"autoload-dev": {
5153
"psr-4": {
52-
"Howdu\\FilamentRecordSwitcher\\Tests\\": "tests/"
54+
"Howdu\\FilamentRecordSwitcher\\Tests\\": "tests/src",
55+
"Howdu\\FilamentRecordSwitcher\\Tests\\Database\\Factories\\": "tests/database/factories"
5356
}
5457
},
5558
"scripts": {
5659
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
5760
"analyse": "vendor/bin/phpstan analyse --memory-limit=1G",
58-
"test": "vendor/bin/pest",
59-
"test-coverage": "vendor/bin/pest --coverage",
61+
"test": "pest",
62+
"test:coverage": "pest --coverage",
63+
"test:lint": "pint --test",
6064
"format": "vendor/bin/pint",
6165
"preflight": [
6266
"@format",
@@ -67,6 +71,7 @@
6771
"config": {
6872
"sort-packages": true,
6973
"allow-plugins": {
74+
"composer/package-versions-deprecated": true,
7075
"pestphp/pest-plugin": true,
7176
"phpstan/extension-installer": true
7277
}

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<directory>tests</directory>
2121
</testsuite>
2222
</testsuites>
23+
<php>
24+
<env name="DB_CONNECTION" value="testing"/>
25+
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
26+
</php>
2327
<coverage>
2428
<report>
2529
<html outputDirectory="build/coverage"/>

src/Commands/FilamentRecordSwitcherCommand.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/Filament/Concerns/HasRecordSwitcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @mixin EditRecord
2121
*/
22-
trait HasRecordSwitcher /** @phpstan-ignore trait.unused */
22+
trait HasRecordSwitcher
2323
{
2424
protected int $maxSelectOptions = 10;
2525

src/FilamentRecordSwitcher.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/FilamentRecordSwitcherServiceProvider.php

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,14 @@ class FilamentRecordSwitcherServiceProvider extends PackageServiceProvider
1717

1818
public function configurePackage(Package $package): void
1919
{
20-
/*
21-
* This class is a Package Service Provider
22-
*
23-
* More info: https://github.com/spatie/laravel-package-tools
24-
*/
2520
$package->name(static::$name)
26-
->hasCommands($this->getCommands())
21+
->hasConfigFile()
22+
->hasTranslations()
23+
->hasViews(static::$viewNamespace)
2724
->hasInstallCommand(function (InstallCommand $command) {
2825
$command
2926
->publishConfigFile()
3027
->askToStarRepoOnGitHub('howdu/filament-record-switcher');
3128
});
32-
33-
$configFileName = $package->shortName();
34-
35-
if (file_exists($package->basePath("/../config/{$configFileName}.php"))) {
36-
$package->hasConfigFile();
37-
}
38-
39-
if (file_exists($package->basePath('/../resources/lang'))) {
40-
$package->hasTranslations();
41-
}
42-
43-
if (file_exists($package->basePath('/../resources/views'))) {
44-
$package->hasViews(static::$viewNamespace);
45-
}
46-
}
47-
48-
public function packageRegistered(): void {}
49-
50-
public function packageBooted(): void
51-
{
52-
// Testing
53-
Testable::mixin(new TestsFilamentRecordSwitcher);
54-
}
55-
56-
protected function getAssetPackageName(): ?string
57-
{
58-
return 'howdu/filament-record-switcher';
59-
}
60-
61-
/**
62-
* @return array<class-string>
63-
*/
64-
protected function getCommands(): array
65-
{
66-
return [
67-
FilamentRecordSwitcherCommand::class,
68-
];
6929
}
7030
}

0 commit comments

Comments
 (0)