Skip to content

Commit b61c875

Browse files
committed
chore(ci): refactor workflows and update dev tooling
* Replace `php-tests.yml` with `ci.yml` including QA and Test jobs. * Update `composer.json` scripts and add dev dependencies (PHPStan, AI Reporter). * Configure Codeception coverage and AI reporter extension. * Update Release workflow trigger and pin action version. * Update README CI badge. Signed-off-by: Benjamin Fahl <git@fahl-design.de>
1 parent 38d96d9 commit b61c875

17 files changed

Lines changed: 668 additions & 319 deletions

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
on: [ push, pull_request ]
2+
name: "CI"
3+
4+
jobs:
5+
qa:
6+
name: "QA (lint + static analysis)"
7+
if: "!startsWith(github.event.head_commit.message, 'chore(release)')"
8+
runs-on: "ubuntu-latest"
9+
env:
10+
PHP_CS_FIXER_IGNORE_ENV: true
11+
steps:
12+
- name: "Checkout"
13+
uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
14+
15+
- name: "Install PHP"
16+
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # 2.36.0
17+
with:
18+
coverage: "none"
19+
php-version: "8.3"
20+
21+
- name: "Validate composer.json and composer.lock"
22+
run: "composer validate --ansi --strict"
23+
24+
- name: "Determine composer cache directory"
25+
uses: "ergebnis/.github/actions/composer/determine-cache-directory@4103ff7c010d2c18dc84f72d6704227868412482" # 1.10.0
26+
27+
- name: "Cache dependencies installed with composer"
28+
uses: "actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306" # v5.0.3
29+
with:
30+
path: "${{ env.COMPOSER_CACHE_DIR }}"
31+
key: "php-8.3-composer-locked-${{ hashFiles('composer.lock') }}"
32+
restore-keys: |
33+
php-8.3-composer-locked-${{ github.ref_name }}
34+
php-8.3-composer-locked-
35+
php-8.3-composer-main
36+
37+
- name: "Install locked dependencies with composer"
38+
uses: "ergebnis/.github/actions/composer/install@4103ff7c010d2c18dc84f72d6704227868412482" # 1.10.0
39+
with:
40+
dependencies: "locked"
41+
42+
- name: "Check coding style"
43+
run: "vendor/bin/codecept build"
44+
45+
- name: "Check coding style"
46+
run: "composer cs:check"
47+
48+
- name: "Run static analysis"
49+
run: "composer stan"
50+
51+
tests:
52+
name: "Run codeception tests"
53+
needs: [ qa ]
54+
runs-on: "ubuntu-latest"
55+
strategy:
56+
matrix:
57+
include:
58+
- { php-version: 8.3, dependencies: locked, coverage: pcov, with_coverage: true, allow-fail: false }
59+
60+
- { php-version: 8.4, dependencies: highest, coverage: pcov, with_coverage: false, allow-fail: true }
61+
- { php-version: 8.5, dependencies: highest, coverage: pcov, with_coverage: false, allow-fail: true }
62+
steps:
63+
- name: "Checkout"
64+
uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
65+
66+
- name: "Install PHP"
67+
uses: "shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1" # 2.36.0
68+
with:
69+
coverage: "${{ matrix.coverage }}"
70+
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
71+
php-version: "${{ matrix.php-version }}"
72+
73+
- name: "Set up problem matchers for PHP"
74+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
75+
76+
- name: "Set up problem matchers for phpunit/phpunit"
77+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""
78+
79+
- name: "Validate composer.json and composer.lock"
80+
run: "composer validate --ansi --strict"
81+
82+
- name: "Determine composer cache directory"
83+
uses: "ergebnis/.github/actions/composer/determine-cache-directory@4103ff7c010d2c18dc84f72d6704227868412482" # 1.10.0
84+
85+
- name: "Cache dependencies installed with composer"
86+
uses: "actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306" # v5.0.3
87+
with:
88+
path: "${{ env.COMPOSER_CACHE_DIR }}"
89+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
90+
restore-keys: |
91+
php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ github.ref_name }}
92+
php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
93+
php-${{ matrix.php-version }}-composer-main
94+
95+
- name: "Install ${{ matrix.dependencies }} dependencies with composer"
96+
uses: "ergebnis/.github/actions/composer/install@4103ff7c010d2c18dc84f72d6704227868412482" # 1.10.0
97+
with:
98+
dependencies: "${{ matrix.dependencies }}"
99+
100+
- name: "Run Tests (coverage)"
101+
if: matrix.with_coverage == true
102+
run: |
103+
vendor/bin/codecept build
104+
vendor/bin/codecept run --coverage --coverage-xml=coverage.xml --xml --report
105+
106+
- name: "Run Tests"
107+
if: matrix.with_coverage != true
108+
run: |
109+
vendor/bin/codecept build
110+
vendor/bin/codecept run --xml --report
111+
112+
- name: "Upload coverage artifact"
113+
if: matrix.with_coverage == true
114+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
115+
with:
116+
name: code-coverage-results
117+
path: tests/_output/
118+
retention-days: 5

.github/workflows/php-tests.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
name: Release
22
"on":
33
workflow_run:
4-
workflows: ["Tests"]
4+
workflows: ["CI"]
55
types:
66
- completed
77
branches:
88
- main
99
jobs:
1010
release:
11-
if: github.event.workflow_run.conclusion == 'success'
11+
if: >-
12+
github.event.workflow_run.conclusion == 'success'
13+
&& !startsWith(github.event.workflow_run.head_commit.message, 'chore(release)')
1214
name: release
1315
runs-on: ubuntu-latest
1416
steps:
@@ -28,7 +30,7 @@ jobs:
2830

2931
- name: Semantic Release
3032
id: semantic
31-
uses: cycjimmy/semantic-release-action@v4
33+
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
3234
with:
3335
tag_format: ${version}
3436
branches: |
@@ -41,4 +43,4 @@ jobs:
4143
@semantic-release/git
4244
conventional-changelog-conventionalcommits
4345
env:
44-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
46+
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}

.php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
'ordered_imports' => [
5858
'imports_order' => [
5959
// symfony order: Class Function Const
60-
// OEG:
6160
'const',
6261
'class',
6362
'function',
@@ -92,5 +91,6 @@
9291
$config->setRiskyAllowed(true);
9392
$config->setParallelConfig(ParallelConfigFactory::detect());
9493
$config->setFinder($finder);
94+
$config->setUnsupportedPhpVersionAllowed(true);
9595

9696
return $config;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PHP Docker API Client
22

3-
[![Tests](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/php-tests.yml/badge.svg)](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/php-tests.yml)
3+
[![CI](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/ci.yml/badge.svg)](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/ci.yml)
44
[![Release](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/release.yml/badge.svg)](https://github.com/WebProject-xyz/php-docker-api-client/actions/workflows/release.yml)
55
[![PHP Version](https://img.shields.io/packagist/php-v/webproject-xyz/docker-api-client)](https://packagist.org/packages/webproject-xyz/docker-api-client)
66
[![Latest Stable Version](https://img.shields.io/packagist/v/webproject-xyz/docker-api-client)](https://packagist.org/packages/webproject-xyz/docker-api-client)

codeception.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ actor_suffix: Tester
1010
extensions:
1111
enabled:
1212
- Codeception\Extension\RunFailed
13+
- WebProject\Codeception\Module\AiReporter\Extension\AiReporter:
14+
format: both
15+
output: tests/_output
16+
max_frames: 8
17+
include_steps: true
18+
include_artifacts: true
19+
compact_paths: true
20+
coverage:
21+
enabled: true
22+
include:
23+
- src/*
24+
- generated/*
25+
exclude:
26+
- tests/*

composer.json

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
"license": "MIT",
55
"type": "library",
66
"homepage": "https://www.webproject.xyz",
7+
"authors": [
8+
{
9+
"name": "Benjamin Fahl",
10+
"email": "ben+github@webproject.xyz",
11+
"role": "developer"
12+
}
13+
],
714
"require": {
815
"php": "~8.3.0 || ~8.4.0 || ~8.5.0",
916
"jane-php/open-api-runtime": "^7.10.4",
@@ -24,7 +31,11 @@
2431
"friendsofphp/php-cs-fixer": "3.94.0",
2532
"jane-php/open-api-3": "^7.10.4",
2633
"roave/security-advisories": "dev-latest",
27-
"symfony/var-dumper": "7.4.0 || ^8.0"
34+
"symfony/var-dumper": "7.4.0 || ^8.0",
35+
"phpstan/phpstan": "^2.1.39",
36+
"phpstan/phpstan-webmozart-assert": "^2.0.0",
37+
"phpstan/extension-installer": "^1.4.3",
38+
"webproject-xyz/codeception-module-ai-reporter": "^1.0.1"
2839
},
2940
"autoload": {
3041
"psr-4": {
@@ -41,13 +52,24 @@
4152
"bin/docker-api"
4253
],
4354
"config": {
55+
"platform": {
56+
"php": "8.3.0"
57+
},
4458
"allow-plugins": {
4559
"php-http/discovery": true,
46-
"symfony/runtime": true
47-
}
60+
"symfony/runtime": true,
61+
"phpstan/extension-installer": true
62+
},
63+
"sort-packages": true,
64+
"optimize-autoloader": true
4865
},
4966
"scripts": {
5067
"generate": "XDEBUG_MODE=off jane-openapi generate",
51-
"tests": "vendor/bin/codecept run"
68+
"cs:check": "php-cs-fixer fix --allow-risky=yes --dry-run --diff",
69+
"cs:fix": "php-cs-fixer fix --allow-risky=yes",
70+
"stan": "phpstan analyse --no-progress --debug",
71+
"test": "codecept run --report",
72+
"test:coverage": "XDEBUG_MODE=coverage codecept run --coverage --coverage-xml=coverage.xml --xml --report",
73+
"test:build": "codecept build"
5274
}
5375
}

0 commit comments

Comments
 (0)