Skip to content

Commit 615111e

Browse files
Merge pull request #19 from devaction-labs/feat/improve
chore: add GitHub workflows and documentation files
2 parents faf53c3 + b72f646 commit 615111e

18 files changed

+1070
-527
lines changed

.github/workflows/secrutinizer.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
checks:
2+
php: true
3+
4+
coding_style:
5+
php:
6+
spaces:
7+
around_operators:
8+
concatenation: true
9+
ternary_operator:
10+
before_condition: true
11+
after_condition: true
12+
before_alternative: true
13+
after_alternative: true
14+
15+
filter:
16+
paths:
17+
- src/*
18+
excluded_paths:
19+
- tests/*
20+
- vendor/*
21+
22+
tools:
23+
php_analyzer: true
24+
php_mess_detector: true
25+
php_code_sniffer:
26+
config:
27+
standard: PSR12
28+
sensiolabs_security_checker: true
29+
php_code_coverage: true
30+
php_sim: true
31+
php_pdepend: true
32+
php_loc: true
33+
external_code_coverage:
34+
timeout: 600
35+
runs: 3
36+
37+
build:
38+
nodes:
39+
analysis:
40+
environment:
41+
php: 8.2
42+
project_setup:
43+
override:
44+
- composer install --no-interaction --prefer-dist
45+
tests:
46+
override:
47+
- php-scrutinizer-run
48+
- phpcs-run
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Release & Code Quality
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
branches:
10+
- main
11+
- master
12+
13+
jobs:
14+
test:
15+
name: Test PHP ${{ matrix.php }}
16+
runs-on: ubuntu-latest
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php: ['8.2', '8.3', '8.4']
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup PHP
27+
uses: shivammathur/setup-php@v2
28+
with:
29+
php-version: ${{ matrix.php }}
30+
extensions: mbstring, dom, fileinfo, json, libxml, zip
31+
coverage: xdebug
32+
33+
- name: Get composer cache directory
34+
id: composer-cache
35+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
36+
37+
- name: Cache dependencies
38+
uses: actions/cache@v4
39+
with:
40+
path: ${{ steps.composer-cache.outputs.dir }}
41+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
42+
restore-keys: ${{ runner.os }}-php-${{ matrix.php }}-composer-
43+
44+
- name: Install dependencies
45+
run: composer install --prefer-dist --no-progress
46+
47+
- name: Run Tests
48+
run: composer test:unit
49+
50+
code-quality:
51+
name: Code Quality
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v4
56+
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: '8.2'
61+
extensions: mbstring, dom, fileinfo, json, libxml, zip
62+
coverage: xdebug
63+
64+
- name: Get composer cache directory
65+
id: composer-cache
66+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
67+
68+
- name: Cache dependencies
69+
uses: actions/cache@v4
70+
with:
71+
path: ${{ steps.composer-cache.outputs.dir }}
72+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
73+
restore-keys: ${{ runner.os }}-composer-
74+
75+
- name: Install dependencies
76+
run: composer install --prefer-dist --no-progress
77+
78+
- name: Run PHP_CodeSniffer
79+
run: composer test:lint
80+
81+
- name: Run PHPStan
82+
run: composer test:types
83+
84+
- name: Check code style with Rector
85+
run: composer test:refacto
86+
87+
release-tag:
88+
name: Create Release Tag
89+
runs-on: ubuntu-latest
90+
needs: [test, code-quality]
91+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
92+
93+
steps:
94+
- name: Checkout code
95+
uses: actions/checkout@v4
96+
with:
97+
fetch-depth: 0
98+
99+
- name: Get version from composer.json
100+
id: get-version
101+
run: |
102+
VERSION=$(grep -oP '"version":\s*"\K[^"]+' composer.json)
103+
echo "version=$VERSION" >> $GITHUB_OUTPUT
104+
echo "Version found: $VERSION"
105+
106+
- name: Check if tag exists
107+
id: check-tag
108+
run: |
109+
if git rev-parse "v${{ steps.get-version.outputs.version }}" >/dev/null 2>&1; then
110+
echo "exists=true" >> $GITHUB_OUTPUT
111+
echo "Tag already exists"
112+
else
113+
echo "exists=false" >> $GITHUB_OUTPUT
114+
echo "Tag does not exist"
115+
fi
116+
117+
- name: Create and push tag
118+
if: steps.check-tag.outputs.exists == 'false'
119+
run: |
120+
git config --local user.email "action@github.com"
121+
git config --local user.name "GitHub Action"
122+
git tag -a "v${{ steps.get-version.outputs.version }}" -m "Release v${{ steps.get-version.outputs.version }}"
123+
git push origin "v${{ steps.get-version.outputs.version }}"
124+
125+
- name: Create Release
126+
if: steps.check-tag.outputs.exists == 'false'
127+
uses: softprops/action-gh-release@v2
128+
with:
129+
tag_name: v${{ steps.get-version.outputs.version }}
130+
name: Release v${{ steps.get-version.outputs.version }}
131+
draft: false
132+
prerelease: false
133+
body: |
134+
Release v${{ steps.get-version.outputs.version }}
135+
136+
Please refer to the [CHANGELOG.md](CHANGELOG.md) for details.
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- develop
9+
pull_request:
10+
branches:
11+
- main
12+
- master
13+
- develop
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: true
20+
matrix:
21+
php: [8.2, 8.3]
22+
laravel: [^11.0, ^12.0]
23+
dependency-version: [prefer-stable]
24+
include:
25+
- laravel: ^11.0
26+
testbench: ^9.0
27+
- laravel: ^12.0
28+
testbench: ^9.0
29+
30+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
31+
32+
steps:
33+
- name: Checkout code
34+
uses: actions/checkout@v3
35+
36+
- name: Cache dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: ~/.composer/cache/files
40+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
41+
42+
- name: Setup PHP
43+
uses: shivammathur/setup-php@v2
44+
with:
45+
php-version: ${{ matrix.php }}
46+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
47+
coverage: none
48+
49+
- name: Install dependencies
50+
run: |
51+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
52+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction
53+
54+
- name: Execute tests
55+
run: vendor/bin/pest

CHANGELOG.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Changelog
2+
3+
All notable changes to `filterable-package` will be documented in this file.
4+
5+
## 1.0.22 - 2025-04-04
6+
7+
### Added
8+
- Initial release with core functionality
9+
- Filterable trait implementation
10+
- Support for various filter types (exact, like, in, between, gt, gte, lt, lte)
11+
- JSON filtering support
12+
- Relationship filtering
13+
- Dynamic sorting capabilities
14+
- Pagination integration
15+
- Performance optimizations including validation caching
16+
17+
### Changed
18+
- Implementamos várias otimizações de performance importantes no trait Filterable, incluindo:
19+
20+
1. Caching de validações repetidas
21+
- Armazenamos em cache resultados de verificações como isValidRelationship e hasFilterConditionalLogic
22+
- Usamos cache para atributos resolvidos evitando recálculos
23+
2. Otimização de estruturas de dados
24+
- Substituímos array_unique por array associativo como "Set" para manter relacionamentos únicos
25+
- Pré-alocamos arrays para condições com estimativa de tamanho
26+
3. Otimização de SQL
27+
- Implementamos casos especiais para filtros simples em relacionamentos
28+
- Reduzimos consultas aninhadas desnecessárias
29+
4. Refatorações inteligentes
30+
- Substituímos encadeamentos de if/elseif por switch e match expressions
31+
- Extraímos verificações comuns para métodos utilitários
32+
5. Testes de performance
33+
- Criamos testes específicos que verificam o comportamento otimizado
34+
- Verificamos tempo de execução para conjuntos grandes de filtros
35+
36+
### Fixed
37+
- N/A
38+
39+
## [Unreleased]
40+
41+
### Added
42+
- Support for advanced date filtering with Carbon
43+
- Enhanced performance through attribute caching
44+
- Conditional relationship filtering with whereAny, whereAll, and whereNone
45+
- Custom LIKE patterns for more flexible text searching
46+
- Database-specific JSON field handling optimizations
47+
48+
### Changed
49+
- Improved README documentation with comprehensive examples
50+
- Optimization for relationship loading to avoid duplications
51+
52+
### Fixed
53+
- Better validation for array values in filters

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

0 commit comments

Comments
 (0)