Skip to content

Commit 290e722

Browse files
committed
add php CI workflow
1 parent 5ee939a commit 290e722

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

.github/workflows/php.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
name: PHP Quality Assistance
3+
4+
on:
5+
# This event occurs when there is activity on a pull request. The workflow
6+
# will be run against the commits, after merge to the target branch (main).
7+
pull_request:
8+
paths:
9+
- '**.php'
10+
- '.config/phpcs.xml.dist'
11+
- 'tests/phpunit/phpunit.xml'
12+
- '.github/workflows/php.yml'
13+
- 'composer.json'
14+
- 'composer.lock'
15+
branches: [ main, feature/php-ci ]
16+
types: [ opened, reopened, synchronize ]
17+
# This event occurs when there is a push to the repository.
18+
push:
19+
paths:
20+
- '**.php'
21+
- '.config/phpcs.xml.dist'
22+
- 'tests/phpunit/phpunit.xml'
23+
- '.github/workflows/php.yml'
24+
- 'composer.json'
25+
- 'composer.lock'
26+
# Allow manually triggering the workflow.
27+
workflow_dispatch:
28+
29+
30+
# Cancels all previous workflow runs for the same branch that have not yet completed.
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.ref }}
33+
cancel-in-progress: true
34+
35+
permissions:
36+
# Needed to allow the "concurrency" section to cancel a workflow run.
37+
actions: write
38+
39+
jobs:
40+
# 01.preflight.php.lint-syntax.yml
41+
lint-php-syntax:
42+
name: PHP Syntax Linting
43+
runs-on: ubuntu-24.04
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: docker://pipelinecomponents/php-linter
47+
with:
48+
args: >-
49+
parallel-lint
50+
--exclude .git
51+
--exclude vendor
52+
--no-progress
53+
.
54+
# 01.quality.php.validate.dependencies-file.yml
55+
validate-dependencies-file:
56+
name: Validate dependencies file
57+
runs-on: ubuntu-24.04
58+
steps:
59+
- uses: actions/checkout@v4
60+
- run: >-
61+
composer validate
62+
--check-lock
63+
--no-plugins
64+
--no-scripts
65+
--strict
66+
# 02.test.php.test-unit.yml
67+
php-unittest:
68+
name: PHP Unit Tests
69+
needs:
70+
- lint-php-syntax
71+
- validate-dependencies-file
72+
runs-on: ubuntu-24.04
73+
strategy:
74+
fail-fast: false
75+
matrix:
76+
php:
77+
- '8.1' # from 2021-11 to 2023-11 (2025-12)
78+
- '8.2' # from 2022-12 to 2024-12 (2026-12)
79+
- '8.3' # from 2023-11 to 2025-12 (2027-12)
80+
steps:
81+
- uses: actions/checkout@v4
82+
- uses: shivammathur/setup-php@v2
83+
with:
84+
coverage: xdebug
85+
ini-values: error_reporting=E_ALL, display_errors=On
86+
php-version: ${{ matrix.php }}
87+
- name: Install and Cache Composer dependencies
88+
uses: "ramsey/composer-install@v2"
89+
env:
90+
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
91+
- run: bin/phpunit --configuration tests/phpunit/phpunit.xml
92+
# 03.quality.php.scan.dependencies-vulnerabilities.yml
93+
scan-dependencies-vulnerabilities:
94+
name: Scan Dependencies Vulnerabilities
95+
needs:
96+
- validate-dependencies-file
97+
runs-on: ubuntu-24.04
98+
steps:
99+
- uses: actions/checkout@v4
100+
- name: Install and Cache Composer dependencies
101+
uses: "ramsey/composer-install@v2"
102+
env:
103+
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GITHUB_TOKEN }}"}}'
104+
- run: >-
105+
composer audit
106+
--abandoned=report
107+
--no-dev
108+
--no-plugins
109+
--no-scripts
110+
# 03.quality.php.lint-version-compatibility.yml
111+
php-check-version-compatibility:
112+
name: PHP Version Compatibility
113+
needs:
114+
- lint-php-syntax
115+
runs-on: ubuntu-24.04
116+
strategy:
117+
fail-fast: false
118+
matrix:
119+
php:
120+
- '8.1' # from 2021-11 to 2023-11 (2025-12)
121+
- '8.2' # from 2022-12 to 2024-12 (2026-12)
122+
- '8.3' # from 2023-11 to 2025-12 (2027-12)
123+
steps:
124+
- uses: actions/checkout@v4
125+
- uses: docker://pipelinecomponents/php-codesniffer
126+
with:
127+
args: >-
128+
phpcs
129+
-s
130+
--extensions=php
131+
--ignore='*vendor/*'
132+
--runtime-set testVersion ${{ matrix.php }}
133+
--standard=PHPCompatibility
134+
.

0 commit comments

Comments
 (0)