Skip to content

Commit

Permalink
Merge pull request #394 from wayofdev/feat/laravel-11
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp authored May 29, 2024
2 parents ec47af1 + 3d07f67 commit 4414a30
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 12 deletions.
1 change: 1 addition & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on: # yamllint disable-line rule:truthy
name: 🧹 Fix PHP coding standards

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on: # yamllint disable-line rule:truthy
name: 🚀 Deploy to production

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

concurrency: production
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on: # yamllint disable-line rule:truthy
name: 🚀 Deploy to staging

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

concurrency: staging
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/security-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
- develop

name: 🔐 Security analysis

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

jobs:
security-analysis:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
steps:
- name: 📦 Check out the codebase
uses: actions/[email protected]

- name: 🛠️ Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo
ini-values: error_reporting=E_ALL
coverage: none

- name: 🛠️ Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
working-directory: app

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/[email protected]
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 🐛 Check installed packages for security vulnerability advisories
run: make lint-audit
79 changes: 79 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---

on: # yamllint disable-line rule:truthy
pull_request:
branches:
- master
- develop
paths:
- 'app/config/**'
- 'app/src/**'
- 'app/tests/**'
- 'app/.php-cs-fixer.dist.php'
- 'app/composer.json'
- 'app/composer.lock'
- 'app/phpstan.neon.dist'
- 'app/phpstan-baseline.neon'
- 'app/psalm.xml'
- 'app/psalm-baseline.xml'

name: 🔍 Static analysis

env:
# Disable docker support in Makefile
APP_RUNNER: 'cd app &&'

jobs:
stan:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: stan-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
php-version:
- '8.3'
dependencies:
- locked
steps:
- name: 📦 Check out the codebase
uses: actions/[email protected]

- name: 🛠️ Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql
ini-values: error_reporting=E_ALL
coverage: none

- name: 🛠️ Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: 🤖 Validate composer.json and composer.lock
run: make validate-composer

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
working-directory: app

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/[email protected]
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies with composer
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
working-directory: app
dependencies: ${{ matrix.dependencies }}

- name: 🔍 Run static analysis using phpstan/phpstan
run: make lint-stan-ci
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ lint-composer: ## Normalize composer.json and composer.lock files
.PHONY: lint-composer

lint-audit: ## Runs security checks for composer dependencies
$(APP_COMPOSER) audit
$(APP_COMPOSER) audit --ansi
.PHONY: lint-security

validate-composer: ## Validates composer.json and composer.lock files
Expand Down
11 changes: 0 additions & 11 deletions app/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ parameters:
message: "#^Method Domain\\\\Product\\\\Models\\\\Product\\:\\:category\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Relations\\\\BelongsTo does not specify its types\\: TRelatedModel, TChildModel$#"
count: 1
path: src/Domain/Product/Models/Product.php

-
message: "#^Class Support\\\\Filters\\\\FuzzyFilter implements generic interface Spatie\\\\QueryBuilder\\\\Filters\\\\Filter but does not specify its types\\: TModelClass$#"
count: 1
path: src/Support/Filters/FuzzyFilter.php

-
message: "#^Method Support\\\\Filters\\\\FuzzyFilter\\:\\:__invoke\\(\\) return type with generic class Illuminate\\\\Database\\\\Eloquent\\\\Builder does not specify its types\\: TModelClass$#"
count: 1
path: src/Support/Filters/FuzzyFilter.php

-
message: "#^Undefined variable\\: \\$this$#"
count: 1
Expand Down
11 changes: 11 additions & 0 deletions app/src/Support/Filters/FuzzyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
namespace Support\Filters;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Spatie\QueryBuilder\Filters\Filter;

/**
* @template TModelClass of Model
*
* @implements Filter<TModelClass>
*/
class FuzzyFilter implements Filter
{
/**
Expand All @@ -19,6 +25,11 @@ public function __construct(string ...$fields)
$this->fields = $fields;
}

/**
* @param Builder<TModelClass> $query
*
* @return Builder<TModelClass>
*/
public function __invoke(Builder $query, mixed $value, string $property): Builder
{
$query->where(function (Builder $query) use ($value): void {
Expand Down

0 comments on commit 4414a30

Please sign in to comment.