Skip to content

Commit d5b4ec8

Browse files
authored
Add CI workflow for PHP with testing and analysis
1 parent b602f88 commit d5b4ec8

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/main.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
ci:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [8.1, 8.2]
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v3
21+
with:
22+
php-version: ${{ matrix.php }}
23+
extensions: imap, mbstring
24+
coverage: none
25+
26+
- name: Get Composer Cache
27+
uses: actions/cache@v4
28+
with:
29+
path: vendor
30+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-composer-
33+
34+
- name: Install dependencies
35+
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction
36+
37+
- name: Run PHPStan (level 8)
38+
# adjust path or config if needed
39+
run: |
40+
if [ -f phpstan.neon ]; then
41+
./vendor/bin/phpstan analyse --configuration=phpstan.neon --level=8 src tests || true
42+
else
43+
./vendor/bin/phpstan analyse --level=8 src tests || true
44+
fi
45+
46+
- name: Run tests
47+
# try PHPUnit first; adjust if you use Pest or other runner
48+
run: |
49+
if [ -x ./vendor/bin/phpunit ]; then
50+
./vendor/bin/phpunit --configuration phpunit.xml --colors=always --testdox
51+
elif [ -x ./vendor/bin/pest ]; then
52+
./vendor/bin/pest --min
53+
else
54+
echo "No test runner found (phpunit/pest). Ensure composer install created vendor binaries."
55+
exit 1
56+
fi

0 commit comments

Comments
 (0)