Skip to content

Commit 970be83

Browse files
committed
Add GitHub CI workflows: PHPUnit, PHPStan, PHPCS, composer validate
1 parent ac1008a commit 970be83

36 files changed

Lines changed: 3873 additions & 1120 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Validate composer.json
2+
3+
on:
4+
push:
5+
paths:
6+
- 'composer.json'
7+
pull_request:
8+
paths:
9+
- 'composer.json'
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
validate:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: "8.2"
26+
tools: composer:v2
27+
28+
- name: Validate composer.json
29+
run: composer validate --strict

.github/workflows/phpcs.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PHP_CodeSniffer
2+
3+
on:
4+
push:
5+
branches: ["master", "main", "v3.x", "v3.0.x"]
6+
pull_request:
7+
branches: ["master", "main", "v3.x", "v3.0.x"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
phpcs:
14+
name: PSR-12 lint
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: "8.2"
25+
coverage: none
26+
tools: composer:v2
27+
28+
- name: Cache Composer dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cache/composer
32+
key: composer-${{ runner.os }}-cs-${{ hashFiles('**/composer.json') }}
33+
restore-keys: |
34+
composer-${{ runner.os }}-cs-
35+
36+
- name: Install dependencies
37+
run: composer update --prefer-dist --no-progress --no-interaction
38+
39+
- name: Run PHP_CodeSniffer
40+
run: composer cs-ci

.github/workflows/phpstan.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: PHPStan
2+
3+
on:
4+
push:
5+
branches: ["master", "main", "v3.x", "v3.0.x"]
6+
pull_request:
7+
branches: ["master", "main", "v3.x", "v3.0.x"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
phpstan:
14+
name: Static analysis (level 6)
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: "8.2"
25+
coverage: none
26+
tools: composer:v2
27+
28+
- name: Cache Composer dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: ~/.cache/composer
32+
key: composer-${{ runner.os }}-stan-${{ hashFiles('**/composer.json') }}
33+
restore-keys: |
34+
composer-${{ runner.os }}-stan-
35+
36+
- name: Install dependencies
37+
run: composer update --prefer-dist --no-progress --no-interaction
38+
39+
- name: Run PHPStan
40+
run: composer stan

.github/workflows/phpunit.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PHPUnit
2+
3+
on:
4+
push:
5+
branches: ["master", "main", "v3.x", "v3.0.x"]
6+
pull_request:
7+
branches: ["master", "main", "v3.x", "v3.0.x"]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: PHP ${{ matrix.php-version }}
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
php-version: ["8.1", "8.2", "8.3", "8.4"]
21+
include:
22+
- php-version: "8.3"
23+
coverage: "true"
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: ${{ matrix.php-version }}
33+
extensions: pdo, pdo_sqlite
34+
coverage: ${{ matrix.coverage == 'true' && 'xdebug' || 'none' }}
35+
tools: composer:v2
36+
37+
- name: Cache Composer dependencies
38+
uses: actions/cache@v4
39+
with:
40+
path: ~/.cache/composer
41+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
42+
restore-keys: |
43+
composer-${{ runner.os }}-${{ matrix.php-version }}-
44+
45+
- name: Install dependencies
46+
run: composer update --prefer-dist --no-progress --no-interaction
47+
48+
- name: Run tests
49+
if: matrix.coverage != 'true'
50+
run: vendor/bin/phpunit --no-coverage
51+
52+
- name: Run tests with coverage
53+
if: matrix.coverage == 'true'
54+
run: vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml
55+
56+
- name: Upload coverage artifact
57+
if: matrix.coverage == 'true'
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: coverage-report
61+
path: build/coverage.xml
62+
retention-days: 7

.gitignore

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
/.idea/
2-
/.vs/
3-
/.vscode/
4-
/vendor/
5-
/composer.lock
6-
/.phpunit.result.cache
7-
/nbproject/private/
8-
/*.log
1+
/.idea/
2+
/.vs/
3+
/.vscode/
4+
/vendor/
5+
/composer.lock
6+
/.phpunit.result.cache
7+
/.phpunit.cache/
8+
/build/
9+
/coverage/
10+
/nbproject/private/
11+
/*.log

0 commit comments

Comments
 (0)