Skip to content

Commit a2db5b5

Browse files
author
farhadzand
committed
add github action
1 parent b585364 commit a2db5b5

File tree

7 files changed

+187
-1
lines changed

7 files changed

+187
-1
lines changed

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.github export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/pint.json export-ignore
10+
/phpstan.neon export-ignore
11+
/tests export-ignore
12+
/docs export-ignore
13+
/art export-ignore
14+
/.editorconfig export-ignore
15+
16+
# Configure diff output for .php files.
17+
*.php diff=php
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Coding Standards
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
lint:
11+
name: PHP CS & Static Analysis
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: 8.2
22+
extensions: dom, curl, libxml, mbstring, zip, pcntl, bcmath, intl
23+
coverage: none
24+
25+
- name: Install dependencies
26+
run: composer update --prefer-dist --no-interaction --no-progress
27+
28+
- name: Check code style with Laravel Pint
29+
run: vendor/bin/pint --test
30+
31+
- name: Run PHPStan
32+
run: vendor/bin/phpstan analyse

.github/workflows/tests.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
schedule:
9+
- cron: '0 0 * * *' # Run daily at midnight
10+
11+
jobs:
12+
tests:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
fail-fast: true
16+
matrix:
17+
php: [8.2, 8.3, 8.4]
18+
laravel: [11.*, 12.*]
19+
stability: [prefer-lowest, prefer-stable]
20+
exclude:
21+
# Skip incompatible PHP versions and Laravel versions
22+
- php: 8.2
23+
laravel: 12.*
24+
- php: 8.4
25+
stability: prefer-lowest
26+
27+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }}
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Setup PHP
34+
uses: shivammathur/setup-php@v2
35+
with:
36+
php-version: ${{ matrix.php }}
37+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, exif, iconv
38+
coverage: xdebug
39+
ini-values: error_reporting=E_ALL
40+
41+
- name: Setup problem matchers
42+
run: |
43+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
44+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
45+
46+
- name: Install dependencies
47+
run: |
48+
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
49+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
50+
51+
- name: Run PHPUnit tests
52+
run: vendor/bin/phpunit --coverage-text
53+
54+
- name: Run PHP Static Analysis
55+
run: |
56+
if [ -f vendor/bin/phpstan ]; then
57+
vendor/bin/phpstan analyze
58+
fi

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,44 @@ For MongoDB, collections are created with similar fields and appropriate indexes
400400
composer require mongodb/laravel-mongodb
401401
```
402402

403+
## Development
404+
405+
### Testing
406+
407+
Run the tests with:
408+
409+
```bash
410+
composer test
411+
```
412+
413+
### Code Style
414+
415+
This package follows the Laravel coding style. You can check and fix the code style with:
416+
417+
```bash
418+
# Check code style
419+
composer pint:test
420+
421+
# Fix code style issues
422+
composer pint
423+
```
424+
425+
### Static Analysis
426+
427+
Run static analysis with PHPStan:
428+
429+
```bash
430+
composer analyse
431+
```
432+
433+
### Continuous Integration
434+
435+
This package uses GitHub Actions for continuous integration. The following checks are run on each push and pull request:
436+
437+
- **Tests**: PHPUnit tests against multiple PHP and Laravel versions
438+
- **Coding Standards**: Laravel Pint for code style
439+
- **Static Analysis**: PHPStan for static analysis
440+
403441
## License
404442

405443
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

composer.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"require-dev": {
2222
"phpunit/phpunit": "^10.0|^11.0",
2323
"orchestra/testbench": "^8.0|^9.0",
24-
"mockery/mockery": "^1.6"
24+
"mockery/mockery": "^1.6",
25+
"phpstan/phpstan": "^1.10",
26+
"phpstan/phpstan-strict-rules": "^1.5",
27+
"laravel/pint": "^1.13"
2528
},
2629
"autoload": {
2730
"psr-4": {
@@ -40,6 +43,16 @@
4043
]
4144
}
4245
},
46+
"scripts": {
47+
"test": "vendor/bin/phpunit",
48+
"analyse": "vendor/bin/phpstan analyse",
49+
"pint": "vendor/bin/pint",
50+
"pint:test": "vendor/bin/pint --test",
51+
"cs": [
52+
"@pint",
53+
"@analyse"
54+
]
55+
},
4356
"minimum-stability": "stable",
4457
"prefer-stable": true
4558
}

phpstan.neon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
includes:
2+
- vendor/phpstan/phpstan-strict-rules/rules.neon
3+
4+
parameters:
5+
level: 5
6+
paths:
7+
- src
8+
9+
checkMissingIterableValueType: false
10+
checkGenericClassInNonGenericObjectType: false
11+
reportUnmatchedIgnoredErrors: false
12+
13+
ignoreErrors:
14+
# Add specific error patterns to ignore if needed
15+
- '#PHPDoc tag @var#'

pint.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"declare_strict_types": true,
5+
"single_trait_insert_per_statement": true,
6+
"fully_qualified_strict_types": true,
7+
"final_class": true,
8+
"ordered_imports": {
9+
"sort_algorithm": "length"
10+
},
11+
"no_unused_imports": true
12+
}
13+
}

0 commit comments

Comments
 (0)