Skip to content

Commit 47f1e1c

Browse files
authored
Add CI, Pint, PHPStan (#11)
* Add CI, Pint, PHPStan * Add coverage config * Add bootstrap/cache folder * Fix vendor permissions * Bump minimum Laravel 11 version * Bump minimum testbench version in CI * Revert Laravel version in CI to 11.* * Revert Laravel version in CI to 11.* * Revert Laravel version in CI to 11.*
1 parent dedbe79 commit 47f1e1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+921
-39
lines changed

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
/art export-ignore
10+
/docs export-ignore
11+
/tests export-ignore
12+
/workbench export-ignore
13+
/.editorconfig export-ignore
14+
/.php_cs.dist.php export-ignore
15+
/psalm.xml export-ignore
16+
/psalm.xml.dist export-ignore
17+
/testbench.yaml export-ignore
18+
/CHANGELOG.md export-ignore
19+
/UPGRADING.md export-ignore
20+
/pint.json export-ignore
21+
/phpstan.neon.dist export-ignore
22+
/phpstan-baseline.neon export-ignore

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Please see the documentation for all configuration options:
2+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"
11+
labels:
12+
- "dependencies"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: dependabot-auto-merge
2+
on: pull_request_target
3+
4+
permissions:
5+
pull-requests: write
6+
contents: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
timeout-minutes: 5
12+
if: ${{ github.actor == 'dependabot[bot]' }}
13+
steps:
14+
15+
- name: Dependabot metadata
16+
id: metadata
17+
uses: dependabot/fetch-metadata@v2.3.0
18+
with:
19+
github-token: "${{ secrets.GITHUB_TOKEN }}"
20+
21+
- name: Auto-merge Dependabot PRs for semver-minor updates
22+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}}
23+
run: gh pr merge --auto --merge "$PR_URL"
24+
env:
25+
PR_URL: ${{github.event.pull_request.html_url}}
26+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
27+
28+
- name: Auto-merge Dependabot PRs for semver-patch updates
29+
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
30+
run: gh pr merge --auto --merge "$PR_URL"
31+
env:
32+
PR_URL: ${{github.event.pull_request.html_url}}
33+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Fix PHP code style issues
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
php-code-styling:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.head_ref }}
21+
22+
- name: Fix PHP code style issues
23+
uses: aglipanci/laravel-pint-action@2.5
24+
25+
- name: Commit changes
26+
uses: stefanzweifel/git-auto-commit-action@v5
27+
with:
28+
commit_message: Fix styling

.github/workflows/phpstan.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.php'
7+
- 'composer.lock'
8+
- 'phpstan.neon.dist'
9+
- '.github/workflows/phpstan.yml'
10+
11+
jobs:
12+
phpstan:
13+
name: phpstan
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 5
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: '8.4'
23+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, swoole, openssl
24+
coverage: none
25+
26+
- name: Install composer dependencies
27+
uses: ramsey/composer-install@v3
28+
29+
- name: Run PHPStan
30+
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/run-tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: run-tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: [8.3, 8.4]
17+
laravel: [11.*, 12.*]
18+
stability: [prefer-lowest, prefer-stable]
19+
include:
20+
- laravel: 11.*
21+
testbench: ^9.9
22+
carbon: ^2.63
23+
- laravel: 12.*
24+
testbench: 10.*
25+
carbon: ^2.63|^3.0
26+
27+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
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, soap, intl, gd, exif, iconv, imagick, fileinfo, swoole, openssl
38+
coverage: pcov
39+
40+
- name: Setup problem matchers
41+
run: |
42+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
43+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
44+
45+
- name: Install dependencies
46+
run: |
47+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
48+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
49+
50+
- name: List Installed Dependencies
51+
run: composer show -D
52+
53+
- name: Execute tests
54+
run: vendor/bin/pest --ci --bail --compact --memory --coverage --parallel
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "Update Changelog"
2+
3+
on:
4+
release:
5+
types: [released]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
update:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 5
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
ref: main
20+
21+
- name: Update Changelog
22+
uses: stefanzweifel/changelog-updater-action@v1
23+
with:
24+
latest-version: ${{ github.event.release.name }}
25+
release-notes: ${{ github.event.release.body }}
26+
27+
- name: Commit updated CHANGELOG
28+
uses: stefanzweifel/git-auto-commit-action@v5
29+
with:
30+
branch: main
31+
commit_message: Update CHANGELOG
32+
file_pattern: CHANGELOG.md

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
vendor
22
composer.lock
33
node_modules
4+
build
45
.pint.cache
56
.idea

composer.json

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
},
1111
"autoload-dev": {
1212
"psr-4": {
13-
"Tests\\": "tests/"
13+
"Tests\\": "tests/",
14+
"Workbench\\App\\": "workbench/app/",
15+
"Workbench\\Database\\Factories\\": "workbench/database/factories/",
16+
"Workbench\\Database\\Seeders\\": "workbench/database/seeders/"
1417
}
1518
},
1619
"authors": [
@@ -35,7 +38,7 @@
3538
}
3639
},
3740
"require-dev": {
38-
"pestphp/pest": "^3.7",
41+
"pestphp/pest": "^3.8",
3942
"illuminate/auth": "^11.0|^12.0",
4043
"orchestra/testbench": "^9.9|^10.0",
4144
"pestphp/pest-plugin-laravel": "^3.1",
@@ -44,15 +47,41 @@
4447
"livewire/livewire": "^3.5",
4548
"filament/support": "^3.2",
4649
"filament/notifications": "^3.2",
47-
"filament/filament": "^3.2"
50+
"filament/filament": "^3.2",
51+
"larastan/larastan": "^3.4"
4852
},
4953
"config": {
5054
"allow-plugins": {
5155
"pestphp/pest-plugin": true
5256
}
5357
},
5458
"scripts": {
55-
"fix-style": "./vendor/bin/pint --config pint.json",
56-
"check-style": "./vendor/bin/pint --config pint.json --test"
59+
"post-autoload-dump": [
60+
"@clear",
61+
"@prepare"
62+
],
63+
"clear": "@php vendor/bin/testbench package:purge-skeleton --ansi",
64+
"prepare": "@php vendor/bin/testbench package:discover --ansi",
65+
"build": "@php vendor/bin/testbench workbench:build --ansi",
66+
"serve": [
67+
"Composer\\Config::disableProcessTimeout",
68+
"@build",
69+
"@php vendor/bin/testbench serve --ansi"
70+
],
71+
"analyse": [
72+
"@php vendor/bin/phpstan analyse"
73+
],
74+
"lint": [
75+
"@php vendor/bin/pint --ansi"
76+
],
77+
"test": [
78+
"@clear",
79+
"@php vendor/bin/pest"
80+
],
81+
"check": [
82+
"@lint",
83+
"@analyse",
84+
"@test"
85+
]
5786
}
5887
}

0 commit comments

Comments
 (0)