Skip to content

Commit 13d784c

Browse files
authored
Merge pull request #7 from KaririCode-Framework/develop
Develop
2 parents 159454d + 4adffcf commit 13d784c

4 files changed

Lines changed: 366 additions & 72 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
# ARFA 1.3 / KaririCode Spec V4.0 — Unified CI Pipeline
4+
# Runs on every push and PR targeting main or develop.
5+
# Full pipeline: cs-fixer → phpstan (L9) → psalm → phpunit (pcov)
6+
# Zero tolerance: any tool failure blocks the merge.
7+
8+
on:
9+
push:
10+
branches: [main, develop]
11+
pull_request:
12+
branches: [main, develop]
13+
workflow_dispatch:
14+
15+
jobs:
16+
quality:
17+
name: Quality Pipeline (ARFA 1.3)
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
# PHP 8.4 + pcov (mandatory driver per ARFA 1.3 §Testing)
24+
- uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.4'
27+
extensions: mbstring, xml, openssl
28+
coverage: pcov
29+
30+
# Pure dependency install — no scripts to avoid environment pollution
31+
- name: Install dependencies
32+
run: composer install --no-interaction --prefer-dist --no-progress --no-scripts
33+
34+
# Bootstrap kcode.phar from the official KaririCode release
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+
# Generate .kcode/ configs: phpunit.xml.dist, phpstan.neon, psalm.xml, etc.
42+
- name: Initialize devkit (.kcode/ generation)
43+
run: kcode init
44+
45+
# cs-fixer → phpstan (L9) → psalm → phpunit
46+
# Exit code ≠ 0 fails the job (zero-tolerance policy)
47+
- name: Run full quality pipeline
48+
run: kcode quality

.github/workflows/code-quality.yml

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

.github/workflows/kariri-ci-cd.yml

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

0 commit comments

Comments
 (0)