Skip to content

Commit 7dded8d

Browse files
committed
ci: revamp workflow with matrix testing, lint, and security jobs
Split CI into three jobs: lint (Pint PSR-12), test (PHP 8.1-8.4 matrix), and security (composer audit). Fix action versions (checkout@v4, cache@v4). Add composer validation and dependency caching per PHP version.
1 parent 204189d commit 7dded8d

1 file changed

Lines changed: 70 additions & 27 deletions

File tree

.github/workflows/php.yml

Lines changed: 70 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: PHP Composer
1+
name: CI
22

33
on:
44
push:
@@ -10,41 +10,84 @@ permissions:
1010
contents: read
1111

1212
jobs:
13-
build:
13+
lint:
14+
name: Lint (Pint)
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: "8.4"
24+
tools: composer:v2
25+
26+
- name: Cache Composer dependencies
27+
uses: actions/cache@v4
28+
with:
29+
path: vendor
30+
key: ${{ runner.os }}-php-8.4-${{ hashFiles('**/composer.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-php-8.4-
33+
34+
- name: Install dependencies
35+
run: composer install --prefer-dist --no-progress
1436

37+
- name: Check code style (PSR-12)
38+
run: composer run print-test
39+
40+
test:
41+
name: Test (PHP ${{ matrix.php }})
1542
runs-on: ubuntu-latest
1643

44+
strategy:
45+
fail-fast: false
46+
matrix:
47+
php: ["8.1", "8.2", "8.3", "8.4"]
48+
1749
steps:
18-
- uses: actions/checkout@v7
50+
- uses: actions/checkout@v4
51+
52+
- name: Setup PHP
53+
uses: shivammathur/setup-php@v2
54+
with:
55+
php-version: ${{ matrix.php }}
56+
coverage: none
57+
tools: composer:v2
1958

20-
- name: Setup PHP
21-
uses: shivammathur/setup-php@v2
22-
with:
23-
php-version: "8.4"
59+
- name: Validate composer.json
60+
run: composer validate --strict
2461

25-
- name: Validate composer.json and composer.lock
26-
run: composer validate --strict
62+
- name: Cache Composer dependencies
63+
uses: actions/cache@v4
64+
with:
65+
path: vendor
66+
key: ${{ runner.os }}-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
67+
restore-keys: |
68+
${{ runner.os }}-php-${{ matrix.php }}-
2769
28-
- name: Cache Composer packages
29-
id: composer-cache
30-
uses: actions/cache@v6
31-
with:
32-
path: vendor
33-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
34-
restore-keys: |
35-
${{ runner.os }}-php-
70+
- name: Install dependencies
71+
run: composer install --prefer-dist --no-progress
3672

37-
- name: Install dependencies
38-
run: composer install --prefer-dist --no-progress
73+
- name: Run tests
74+
run: composer test
3975

40-
# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
41-
# Docs: https://getcomposer.org/doc/articles/scripts.md
76+
security:
77+
name: Security audit
78+
runs-on: ubuntu-latest
79+
80+
steps:
81+
- uses: actions/checkout@v4
4282

43-
- name: Run test suite
44-
run: composer run-script test
83+
- name: Setup PHP
84+
uses: shivammathur/setup-php@v2
85+
with:
86+
php-version: "8.4"
87+
tools: composer:v2
4588

46-
- name: Run print
47-
run: composer run-script print-test
89+
- name: Install dependencies
90+
run: composer install --prefer-dist --no-progress
4891

49-
- name: Check for vulnerable dependencies
50-
run: composer audit
92+
- name: Check for vulnerable dependencies
93+
run: composer audit

0 commit comments

Comments
 (0)