Skip to content

Commit b488d72

Browse files
committed
add CI scripts for PHP validation, linting, and static analysis closes 25
1 parent 6520910 commit b488d72

3 files changed

Lines changed: 70 additions & 16 deletions

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
8+
- package-ecosystem: "composer"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/main.yml

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,99 @@
11
name: "CI"
2-
# Controls when the action will run.
2+
33
on:
4-
# Triggers the workflow on push or pull request events but only for the main branch
54
push:
5+
branches:
6+
- "main"
67
pull_request:
7-
8-
# Allows you to run this workflow manually from the Actions tab
8+
branches:
9+
- "main"
910
workflow_dispatch:
1011

1112
permissions:
1213
contents: "read"
1314

14-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
concurrency:
16+
group: "ci-${{ github.workflow }}-${{ github.ref }}"
17+
cancel-in-progress: true
18+
1519
jobs:
16-
# composer validation
1720
composer:
1821
name: "composer config validation"
1922
runs-on: "ubuntu-latest"
23+
timeout-minutes: 10
2024
steps:
21-
- uses: "actions/checkout@v3"
25+
- name: "git checkout"
26+
uses: "actions/checkout@v4"
2227
- name: "Validate composer.json"
2328
run: "composer validate --strict"
24-
# PHP lint and PHPStan for different PHP versions
29+
2530
php:
31+
name: "PHP ${{ matrix.php-version }}"
32+
needs: "composer"
2633
runs-on: "ubuntu-latest"
34+
timeout-minutes: 15
2735
strategy:
36+
fail-fast: false
2837
matrix:
2938
php-version:
3039
- "8.1"
3140
- "8.2"
3241
- "8.3"
33-
name: "PHP ${{ matrix.php-version }}"
3442
steps:
3543
- name: "git checkout"
36-
uses: "actions/checkout@v3"
44+
uses: "actions/checkout@v4"
3745
- name: "setup PHP"
3846
uses: "shivammathur/setup-php@v2"
3947
with:
4048
php-version: "${{ matrix.php-version }}"
49+
extensions: "json"
4150
coverage: "xdebug"
51+
tools: "composer:v2"
52+
cache: "composer"
4253
- name: "check PHP version"
4354
run: "php -v"
4455
- name: "lint PHP files"
45-
run: "php -l src/"
56+
run: "find src -type f -name '*.php' -print0 | xargs -0 -n1 php -l"
57+
- name: "install composer dependencies"
58+
run: "composer install --prefer-dist --no-interaction --no-progress"
59+
60+
phpstan:
61+
name: "PHPStan"
62+
needs: "composer"
63+
runs-on: "ubuntu-latest"
64+
timeout-minutes: 15
65+
steps:
66+
- name: "git checkout"
67+
uses: "actions/checkout@v4"
68+
- name: "setup PHP"
69+
uses: "shivammathur/setup-php@v2"
70+
with:
71+
php-version: "8.3"
72+
extensions: "json"
73+
tools: "composer:v2"
74+
cache: "composer"
4675
- name: "install composer dependencies"
47-
run: "composer install --prefer-dist --no-progress"
48-
# PHPStan
76+
run: "composer install --prefer-dist --no-interaction --no-progress"
4977
- name: "PHPStan static analysis"
5078
run: "vendor/bin/phpstan analyse --configuration=phpstan.neon"
79+
5180
codesniffer:
81+
name: "PHP CodeSniffer"
82+
needs: "composer"
5283
runs-on: "ubuntu-latest"
84+
timeout-minutes: 15
5385
steps:
5486
- name: "git checkout"
55-
uses: "actions/checkout@v3"
87+
uses: "actions/checkout@v4"
5688
- name: "setup PHP"
5789
uses: "shivammathur/setup-php@v2"
5890
with:
59-
php-version: "8.1"
91+
php-version: "8.3"
92+
extensions: "json"
93+
tools: "composer:v2"
94+
cache: "composer"
6095
- name: "install composer dependencies"
61-
run: "composer install --prefer-dist --no-progress"
96+
run: "composer install --prefer-dist --no-interaction --no-progress"
6297
- name: "check PHP_CodeSniffer version"
6398
run: "vendor/bin/phpcs --version"
6499
- name: "PHP CodeSniffer"

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
"phpsap\\interfaces\\": "src/"
3030
}
3131
},
32+
"scripts": {
33+
"ci": [
34+
"@composer validate --strict",
35+
"@php -l src/",
36+
"@php vendor/bin/phpstan analyse --configuration=phpstan.neon",
37+
"@php vendor/bin/phpcs"
38+
]
39+
},
3240
"require-dev": {
3341
"phpstan/phpstan": "^2.2",
3442
"squizlabs/php_codesniffer": "^4.0"

0 commit comments

Comments
 (0)