Skip to content

Commit 6eb723f

Browse files
authored
Merge pull request #4 from KaririCode-Framework/develop
Develop
2 parents d8410b2 + a33c0f7 commit 6eb723f

129 files changed

Lines changed: 4231 additions & 5125 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.docker/php/Dockerfile

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

.docker/php/kariricode-php.ini

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

.env.example

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

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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
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+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
46+
# "not a valid target" warnings for classes extending vendor base classes
47+
- name: Patch phpunit.xml.dist
48+
run: |
49+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
50+
51+
# cs-fixer → phpstan (L9) → psalm → phpunit
52+
# Exit code ≠ 0 fails the job (zero-tolerance policy)
53+
- name: Run full quality pipeline
54+
run: kcode quality

.github/workflows/code-quality.yml

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
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+
# Transformer 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
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+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
102+
# "not a valid target" warnings for classes extending vendor base classes
103+
- name: Patch phpunit.xml.dist
104+
run: |
105+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
106+
107+
# Runs PHPStan Level 9 then Psalm sequentially — both must pass
108+
- name: Run PHPStan + Psalm via kcode
109+
run: kcode analyse
110+
111+
# ============================================================================
112+
# CODE STYLE (ARFA 1.3 Naming / Formatting Standards)
113+
# kcode cs:fix enforces PSR-12 + PHP 8.4 migrations + KaririCode rules.
114+
# --check: dry-run only — fails if any violation exists.
115+
# ============================================================================
116+
cs-fixer:
117+
name: Code Style — PHP CS Fixer
118+
runs-on: ubuntu-latest
119+
120+
steps:
121+
- uses: actions/checkout@v4
122+
123+
- uses: shivammathur/setup-php@v2
124+
with:
125+
php-version: '8.4'
126+
extensions: mbstring, xml
127+
coverage: none
128+
tools: composer:v2
129+
130+
- name: Install dependencies
131+
run: composer install --prefer-dist --no-progress --no-scripts
132+
133+
- name: Install kcode
134+
run: |
135+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
136+
chmod +x kcode.phar
137+
sudo mv kcode.phar /usr/local/bin/kcode
138+
139+
- name: Initialize devkit
140+
run: kcode init
141+
142+
- name: Check code style (dry-run)
143+
run: kcode cs:fix --check
144+
145+
# ============================================================================
146+
# UNIT & INTEGRATION TESTS (ARFA 1.3 §Testing — Zero Tolerance)
147+
# pcov is the mandatory driver (performance + accuracy over Xdebug).
148+
# Requires: 0 failures, 0 errors, 0 warnings, 0 risky tests.
149+
# ============================================================================
150+
tests:
151+
name: PHPUnit Tests (pcov)
152+
runs-on: ubuntu-latest
153+
154+
steps:
155+
- uses: actions/checkout@v4
156+
157+
- uses: shivammathur/setup-php@v2
158+
with:
159+
php-version: '8.4'
160+
extensions: mbstring, xml
161+
coverage: pcov
162+
tools: composer:v2
163+
164+
- name: Install dependencies
165+
run: composer install --prefer-dist --no-progress --no-scripts
166+
167+
- name: Install kcode
168+
run: |
169+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
170+
chmod +x kcode.phar
171+
sudo mv kcode.phar /usr/local/bin/kcode
172+
173+
- name: Initialize devkit
174+
run: kcode init
175+
176+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
177+
# "not a valid target" warnings for classes extending vendor base classes
178+
- name: Patch phpunit.xml.dist
179+
run: |
180+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
181+
182+
- name: Run tests with coverage (pcov)
183+
run: kcode test --coverage
184+
185+
# ============================================================================
186+
# QUALITY SUMMARY — Gate job (if: always())
187+
# Aggregates all job results and fails the workflow if any check failed.
188+
# Posts a markdown summary to the GitHub Actions run.
189+
# ============================================================================
190+
quality-summary:
191+
name: Quality Summary
192+
runs-on: ubuntu-latest
193+
needs: [dependencies, security, analyse, cs-fixer, tests]
194+
if: always()
195+
196+
steps:
197+
- name: Post quality summary
198+
run: |
199+
echo "## KaririCode Transformer — Quality Report (ARFA 1.3)" >> "$GITHUB_STEP_SUMMARY"
200+
echo "" >> "$GITHUB_STEP_SUMMARY"
201+
echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY"
202+
echo "|-------|--------|" >> "$GITHUB_STEP_SUMMARY"
203+
echo "| Dependency Validation | ${{ needs.dependencies.result }} |" >> "$GITHUB_STEP_SUMMARY"
204+
echo "| Security Audit | ${{ needs.security.result }} |" >> "$GITHUB_STEP_SUMMARY"
205+
echo "| Static Analysis (PHPStan L9 + Psalm) | ${{ needs.analyse.result }} |" >> "$GITHUB_STEP_SUMMARY"
206+
echo "| Code Style (CS Fixer) | ${{ needs.cs-fixer.result }} |" >> "$GITHUB_STEP_SUMMARY"
207+
echo "| PHPUnit Tests (pcov) | ${{ needs.tests.result }} |" >> "$GITHUB_STEP_SUMMARY"
208+
209+
if [ "${{ needs.security.result }}" != "success" ] || \
210+
[ "${{ needs.analyse.result }}" != "success" ] || \
211+
[ "${{ needs.cs-fixer.result }}" != "success" ] || \
212+
[ "${{ needs.tests.result }}" != "success" ]; then
213+
echo "" >> "$GITHUB_STEP_SUMMARY"
214+
echo "❌ One or more quality gates failed. Merge blocked." >> "$GITHUB_STEP_SUMMARY"
215+
exit 1
216+
fi
217+
218+
echo "" >> "$GITHUB_STEP_SUMMARY"
219+
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)