Skip to content

Commit

Permalink
Merge pull request #326 from phh/feature/github-workflows
Browse files Browse the repository at this point in the history
Add workflows: Phpstan, formatting and tests
  • Loading branch information
jeffgreco13 authored Jan 19, 2024
2 parents 6f622db + 62b9193 commit 0e36430
Show file tree
Hide file tree
Showing 47 changed files with 3,156 additions and 2,842 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Fix PHP code style issues

on:
push:
paths:
- '**.php'

permissions:
contents: write

jobs:
php-code-styling:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
28 changes: 28 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PHPStan

on:
push:
paths:
- '**.php'
- 'phpstan.neon.dist'
- '.github/workflows/phpstan.yml'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
55 changes: 55 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: run-tests

on:
push:
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.3, 8.2, 8.1]
laravel: [10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
carbon: ^2.63

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

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Setup problem matchers
run: |
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
run: vendor/bin/pest --ci
32 changes: 24 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,29 @@
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"filament/filament": "^3.0.9",
"bacon/bacon-qr-code": "^2.0",
"pragmarx/google2fa": "^7.0|^8.0"
"filament/filament": "^3.0.9",
"illuminate/contracts": "^10.0",
"pragmarx/google2fa": "^7.0|^8.0",
"spatie/laravel-package-tools": "^1.14.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.0",
"larastan/larastan": "^2.0.1",
"orchestra/testbench": "^8.8",
"pestphp/pest": "^2.20",
"pestphp/pest-plugin-arch": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"pestphp/pest-plugin-livewire": "^2.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"spatie/laravel-ray": "^1.26"
},
"autoload": {
"psr-4": {
"Jeffgreco13\\FilamentBreezy\\": "src/",
"Jeffgreco13\\FilamentBreezy\\Database\\Factories\\": "database/factories/"
"Jeffgreco13\\FilamentBreezy\\": "src/"
}
},
"autoload-dev": {
Expand All @@ -43,7 +48,18 @@
}
},
"scripts": {
"post-autoload-dump": "@php ./vendor/bin/testbench package:discover --ansi",
"post-autoload-dump": "@composer run prepare",
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"build": [
"@composer run prepare",
"@php vendor/bin/testbench workbench:build --ansi"
],
"start": [
"Composer\\Config::disableProcessTimeout",
"@composer run build",
"@php vendor/bin/testbench serve"
],
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
Expand Down
161 changes: 161 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
parameters:
ignoreErrors:
-
message: "#^Access to an undefined property Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable\\:\\:\\$two_factor_secret\\.$#"
count: 1
path: src/BreezyCore.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Livewire\\\\MyProfileComponent\\:\\:\\$view\\.$#"
count: 1
path: src/Livewire/MyProfileComponent.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Livewire\\\\PersonalInfo\\:\\:\\$form\\.$#"
count: 2
path: src/Livewire/PersonalInfo.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getAvatarUploadComponent\\(\\)\\.$#"
count: 2
path: src/Livewire/PersonalInfo.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:hasAvatars\\(\\)\\.$#"
count: 1
path: src/Livewire/PersonalInfo.php

-
message: "#^Access to static property \\$personalAccessTokenModel on an unknown class Laravel\\\\Sanctum\\\\Sanctum\\.$#"
count: 1
path: src/Livewire/SanctumTokens.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getSanctumPermissions\\(\\)\\.$#"
count: 1
path: src/Livewire/SanctumTokens.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getTwoFactorQrCodeSvg\\(\\)\\.$#"
count: 1
path: src/Livewire/TwoFactorAuthentication.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:shouldForceTwoFactor\\(\\)\\.$#"
count: 1
path: src/Livewire/TwoFactorAuthentication.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:verify\\(\\)\\.$#"
count: 1
path: src/Livewire/TwoFactorAuthentication.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Livewire\\\\UpdatePassword\\:\\:\\$form\\.$#"
count: 1
path: src/Livewire/UpdatePassword.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getPasswordUpdateRequiresCurrent\\(\\)\\.$#"
count: 1
path: src/Livewire/UpdatePassword.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getPasswordUpdateRules\\(\\)\\.$#"
count: 1
path: src/Livewire/UpdatePassword.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:shouldForceTwoFactor\\(\\)\\.$#"
count: 1
path: src/Middleware/MustTwoFactor.php

-
message: "#^Call to an undefined method Illuminate\\\\Foundation\\\\Auth\\\\User\\:\\:hasConfirmedTwoFactor\\(\\)\\.$#"
count: 1
path: src/Middleware/MustTwoFactor.php

-
message: "#^Call to an undefined method Illuminate\\\\Foundation\\\\Auth\\\\User\\:\\:hasValidTwoFactorSession\\(\\)\\.$#"
count: 1
path: src/Middleware/MustTwoFactor.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Models\\\\BreezySession\\:\\:\\$authenticatable\\.$#"
count: 1
path: src/Models/BreezySession.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Models\\\\BreezySession\\:\\:\\$two_factor_confirmed_at\\.$#"
count: 1
path: src/Models/BreezySession.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Models\\\\BreezySession\\:\\:\\$two_factor_secret\\.$#"
count: 2
path: src/Models/BreezySession.php

-
message: "#^Property 'expires_at' does not exist in Jeffgreco13\\\\FilamentBreezy\\\\Models\\\\BreezySession model\\.$#"
count: 1
path: src/Models/BreezySession.php

-
message: "#^Property 'two_factor_confirmed_at' does not exist in Jeffgreco13\\\\FilamentBreezy\\\\Models\\\\BreezySession model\\.$#"
count: 1
path: src/Models/BreezySession.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getNavigationGroup\\(\\)\\.$#"
count: 1
path: src/Pages/MyProfilePage.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:getRegisteredMyProfileComponents\\(\\)\\.$#"
count: 1
path: src/Pages/MyProfilePage.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:shouldRegisterNavigation\\(\\)\\.$#"
count: 1
path: src/Pages/MyProfilePage.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:slug\\(\\)\\.$#"
count: 1
path: src/Pages/MyProfilePage.php

-
message: "#^Expression on left side of \\?\\? is not nullable\\.$#"
count: 1
path: src/Pages/MyProfilePage.php

-
message: "#^Access to an undefined property Illuminate\\\\Foundation\\\\Auth\\\\User\\:\\:\\$two_factor_recovery_codes\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php

-
message: "#^Access to an undefined property Jeffgreco13\\\\FilamentBreezy\\\\Pages\\\\TwoFactorPage\\:\\:\\$form\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php

-
message: "#^Call to an undefined method Filament\\\\Contracts\\\\Plugin\\|Filament\\\\FilamentManager\\:\\:verify\\(\\)\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php

-
message: "#^Call to an undefined method Illuminate\\\\Foundation\\\\Auth\\\\User\\:\\:hasValidTwoFactorSession\\(\\)\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php

-
message: "#^Call to an undefined method Illuminate\\\\Foundation\\\\Auth\\\\User\\:\\:setTwoFactorSession\\(\\)\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php

-
message: "#^Method Jeffgreco13\\\\FilamentBreezy\\\\Pages\\\\TwoFactorPage\\:\\:getFormActions\\(\\) has invalid return type Jeffgreco13\\\\FilamentBreezy\\\\Pages\\\\ActionGroup\\.$#"
count: 1
path: src/Pages/TwoFactorPage.php
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ parameters:
level: 4
paths:
- src
- config
- database
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false

17 changes: 8 additions & 9 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
>
<testsuites>
<testsuite name="Jeffgreco13 Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
Expand All @@ -36,4 +30,9 @@
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
Loading

0 comments on commit 0e36430

Please sign in to comment.