Skip to content

Commit e295d16

Browse files
committed
ci: align workflows to property-inspector pattern (3-file, parallel gates)
1 parent 18e8373 commit e295d16

3 files changed

Lines changed: 320 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
php-version: '8.4'
2727
extensions: mbstring, xml
2828
coverage: pcov
29+
tools: composer:v2
2930

3031
# Pure dependency install — no scripts to avoid environment pollution
3132
- name: Install dependencies

.github/workflows/code-quality.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Code Quality
2+
3+
# ARFA 1.3 / KaririCode Spec V4.0 — Parallel Quality Gates
4+
# Runs 5 parallel jobs with a quality-summary gate job.
5+
# Triggers: main, develop, feature branches, PRs, and manual dispatch.
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
- develop
12+
- 'feature/**'
13+
pull_request:
14+
branches:
15+
- main
16+
- develop
17+
workflow_dispatch:
18+
19+
jobs:
20+
# ============================================================================
21+
# DEPENDENCY VALIDATION (Spec V4.0 — contract compliance)
22+
# Validates that composer.json is valid and platform requirements are met.
23+
# ============================================================================
24+
dependencies:
25+
name: Dependency Validation
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: '8.4'
34+
tools: composer:v2
35+
coverage: none
36+
37+
- name: Validate composer.json
38+
run: composer validate --strict --no-check-lock
39+
40+
- name: Install dependencies
41+
run: composer install --prefer-dist --no-progress --no-scripts
42+
43+
- name: Check platform requirements
44+
run: composer check-platform-reqs
45+
46+
# ============================================================================
47+
# SECURITY AUDIT (ARFA 1.3 — resilience pillar)
48+
# Uses native composer audit — no deprecated security-checker.
49+
# ============================================================================
50+
security:
51+
name: Security Audit
52+
runs-on: ubuntu-latest
53+
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- uses: shivammathur/setup-php@v2
58+
with:
59+
php-version: '8.4'
60+
tools: composer:v2
61+
coverage: none
62+
63+
- name: Install dependencies
64+
run: composer install --prefer-dist --no-progress --no-scripts
65+
66+
- name: Run composer audit
67+
run: composer audit --format=plain
68+
69+
# ============================================================================
70+
# STATIC ANALYSIS (Spec V4.0 S14 — Type Safety)
71+
# kcode analyse runs PHPStan Level 9 + Psalm (100% type inference).
72+
# Both tools must pass with zero errors — enforced by kcode exit code.
73+
# ============================================================================
74+
analyse:
75+
name: Static Analysis — PHPStan L9 + Psalm
76+
runs-on: ubuntu-latest
77+
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- uses: shivammathur/setup-php@v2
82+
with:
83+
php-version: '8.4'
84+
extensions: mbstring, xml
85+
coverage: none
86+
tools: composer:v2
87+
88+
- name: Install dependencies
89+
run: composer install --prefer-dist --no-progress --no-scripts
90+
91+
- name: Install kcode
92+
run: |
93+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
94+
chmod +x kcode.phar
95+
sudo mv kcode.phar /usr/local/bin/kcode
96+
97+
- name: Initialize devkit
98+
run: kcode init
99+
100+
# src/Contract was removed in v4 — patch the generated phpstan.neon
101+
- name: Patch phpstan.neon (remove stale excludePaths)
102+
run: |
103+
sed -i '/excludePaths:/,/- \.\.\/src\/Contract/d' .kcode/phpstan.neon
104+
105+
# Runs PHPStan Level 9 then Psalm sequentially — both must pass
106+
- name: Run PHPStan + Psalm via kcode
107+
run: kcode analyse
108+
109+
# ============================================================================
110+
# CODE STYLE (ARFA 1.3 Naming / Formatting Standards)
111+
# kcode cs:fix enforces PSR-12 + PHP 8.4 migrations + KaririCode rules.
112+
# --check: dry-run only — fails if any violation exists.
113+
# ============================================================================
114+
cs-fixer:
115+
name: Code Style — PHP CS Fixer
116+
runs-on: ubuntu-latest
117+
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- uses: shivammathur/setup-php@v2
122+
with:
123+
php-version: '8.4'
124+
extensions: mbstring, xml
125+
coverage: none
126+
tools: composer:v2
127+
128+
- name: Install dependencies
129+
run: composer install --prefer-dist --no-progress --no-scripts
130+
131+
- name: Install kcode
132+
run: |
133+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
134+
chmod +x kcode.phar
135+
sudo mv kcode.phar /usr/local/bin/kcode
136+
137+
- name: Initialize devkit
138+
run: kcode init
139+
140+
- name: Check code style (dry-run)
141+
run: kcode cs:fix --check
142+
143+
# ============================================================================
144+
# UNIT & INTEGRATION TESTS (ARFA 1.3 §Testing — Zero Tolerance)
145+
# pcov is the mandatory driver (performance + accuracy over Xdebug).
146+
# Requires: 0 failures, 0 errors, 0 warnings, 0 risky tests.
147+
# Target: 128 tests / 234 assertions (processor-pipeline baseline).
148+
# ============================================================================
149+
tests:
150+
name: PHPUnit — 128 Tests (pcov)
151+
runs-on: ubuntu-latest
152+
153+
steps:
154+
- uses: actions/checkout@v4
155+
156+
- uses: shivammathur/setup-php@v2
157+
with:
158+
php-version: '8.4'
159+
extensions: mbstring, xml
160+
coverage: pcov
161+
tools: composer:v2
162+
163+
- name: Install dependencies
164+
run: composer install --prefer-dist --no-progress --no-scripts
165+
166+
- name: Install kcode
167+
run: |
168+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
169+
chmod +x kcode.phar
170+
sudo mv kcode.phar /usr/local/bin/kcode
171+
172+
- name: Initialize devkit
173+
run: kcode init
174+
175+
- name: Run tests with coverage (pcov)
176+
run: kcode test --coverage
177+
178+
# ============================================================================
179+
# QUALITY SUMMARY — Gate job (if: always())
180+
# Aggregates all job results and fails the workflow if any check failed.
181+
# Posts a markdown summary to the GitHub Actions run.
182+
# ============================================================================
183+
quality-summary:
184+
name: Quality Summary
185+
runs-on: ubuntu-latest
186+
needs: [dependencies, security, analyse, cs-fixer, tests]
187+
if: always()
188+
189+
steps:
190+
- name: Post quality summary
191+
run: |
192+
echo "## KaririCode ProcessorPipeline — Quality Report (ARFA 1.3)" >> "$GITHUB_STEP_SUMMARY"
193+
echo "" >> "$GITHUB_STEP_SUMMARY"
194+
echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY"
195+
echo "|-------|--------|" >> "$GITHUB_STEP_SUMMARY"
196+
echo "| Dependency Validation | ${{ needs.dependencies.result }} |" >> "$GITHUB_STEP_SUMMARY"
197+
echo "| Security Audit | ${{ needs.security.result }} |" >> "$GITHUB_STEP_SUMMARY"
198+
echo "| Static Analysis (PHPStan L9 + Psalm) | ${{ needs.analyse.result }} |" >> "$GITHUB_STEP_SUMMARY"
199+
echo "| Code Style (CS Fixer) | ${{ needs.cs-fixer.result }} |" >> "$GITHUB_STEP_SUMMARY"
200+
echo "| PHPUnit Tests (128 / pcov) | ${{ needs.tests.result }} |" >> "$GITHUB_STEP_SUMMARY"
201+
202+
if [ "${{ needs.security.result }}" != "success" ] || \
203+
[ "${{ needs.analyse.result }}" != "success" ] || \
204+
[ "${{ needs.cs-fixer.result }}" != "success" ] || \
205+
[ "${{ needs.tests.result }}" != "success" ]; then
206+
echo "" >> "$GITHUB_STEP_SUMMARY"
207+
echo "❌ One or more quality gates failed. Merge blocked." >> "$GITHUB_STEP_SUMMARY"
208+
exit 1
209+
fi
210+
211+
echo "" >> "$GITHUB_STEP_SUMMARY"
212+
echo "✅ All quality gates passed — ARFA 1.3 compliant." >> "$GITHUB_STEP_SUMMARY"

.github/workflows/release.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Release
2+
3+
# ARFA 1.3 / KaririCode Spec V4.0 — Release Pipeline
4+
# Triggers on semantic version tags (v*).
5+
# Full quality gate (kcode quality) must pass before release is published.
6+
7+
on:
8+
push:
9+
tags:
10+
- 'v*'
11+
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
name: Quality Gate + GitHub Release
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
# PHP 8.4 + pcov: releases MUST pass with coverage (ARFA 1.3 §Testing)
24+
- uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.4'
27+
extensions: mbstring, xml
28+
coverage: pcov
29+
tools: composer:v2
30+
31+
# --no-scripts prevents accidental environment pollution during release
32+
- name: Install dependencies
33+
run: composer install --no-interaction --prefer-dist --no-progress --no-scripts
34+
35+
- name: Install kcode (KaririCode Devkit)
36+
run: |
37+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
38+
chmod +x kcode.phar
39+
sudo mv kcode.phar /usr/local/bin/kcode
40+
41+
- name: Initialize devkit
42+
run: kcode init
43+
44+
# src/Contract was removed in v4 — patch the generated phpstan.neon
45+
- name: Patch phpstan.neon (remove stale excludePaths)
46+
run: |
47+
sed -i '/excludePaths:/,/- \.\.\/src\/Contract/d' .kcode/phpstan.neon
48+
49+
# Full pipeline: cs-fixer → phpstan (L9) → psalm → phpunit (pcov)
50+
# Exit code ≠ 0 aborts the release — zero tolerance (ARFA 1.3)
51+
- name: Run full quality pipeline (release gate)
52+
run: kcode quality
53+
54+
- name: Extract version from tag
55+
id: version
56+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
57+
58+
- name: Create GitHub Release
59+
uses: softprops/action-gh-release@v2
60+
with:
61+
tag_name: ${{ steps.version.outputs.tag }}
62+
name: KaririCode ProcessorPipeline ${{ steps.version.outputs.tag }}
63+
draft: false
64+
prerelease: false
65+
body: |
66+
## KaririCode\ProcessorPipeline ${{ steps.version.outputs.tag }}
67+
68+
A robust, immutable processor pipeline component for the KaririCode Framework.
69+
Enables modular, configurable processing chains for data transformation,
70+
validation, and sanitization. **ARFA 1.3 compliant.**
71+
72+
## Installation
73+
74+
```bash
75+
composer require kariricode/processor-pipeline
76+
```
77+
78+
## Quick Start
79+
80+
```php
81+
use KaririCode\ProcessorPipeline\ProcessorRegistry;
82+
use KaririCode\ProcessorPipeline\ProcessorBuilder;
83+
84+
$registry = new ProcessorRegistry();
85+
$registry
86+
->register('sanitizer', 'trim', new TrimProcessor())
87+
->register('sanitizer', 'lowercase', new LowercaseProcessor());
88+
89+
$builder = new ProcessorBuilder($registry);
90+
$pipeline = $builder->buildPipeline('sanitizer', ['trim', 'lowercase']);
91+
92+
$result = $pipeline->process(' HELLO WORLD ');
93+
// Result: 'hello world'
94+
```
95+
96+
## Quality Metrics
97+
98+
| Metric | Value |
99+
|--------|-------|
100+
| Tests | 128 passing |
101+
| Assertions | 234 |
102+
| PHPStan Level | 9 (0 errors) |
103+
| Psalm | 100% (0 errors) |
104+
| Coverage | 100% classes / methods / lines |
105+
| PHP Version | 8.4+ |
106+
107+
See [CHANGELOG.md](CHANGELOG.md) for details.

0 commit comments

Comments
 (0)