Skip to content

Commit 4b791f3

Browse files
committed
ci: add ARFA 1.3 workflows, gitattributes and composer.json
0 parents  commit 4b791f3

84 files changed

Lines changed: 6794 additions & 0 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.

.gitattributes

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Normalize line endings across OSes
2+
* text=auto
3+
4+
# PHP files — LF only
5+
*.php text eol=lf
6+
*.json text eol=lf
7+
*.yml text eol=lf
8+
*.yaml text eol=lf
9+
*.md text eol=lf
10+
*.xml text eol=lf
11+
*.neon text eol=lf
12+
13+
# Exclude from export
14+
.gitattributes export-ignore
15+
.gitignore export-ignore
16+
.github/ export-ignore
17+
tests/ export-ignore
18+
docs/ export-ignore

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
tools: composer:v2
30+
31+
# Pure dependency install — no scripts to avoid environment pollution
32+
- name: Install dependencies
33+
run: composer install --no-interaction --prefer-dist --no-progress --no-scripts
34+
35+
# Bootstrap kcode.phar from the official KaririCode release
36+
- name: Install kcode (KaririCode Devkit)
37+
run: |
38+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
39+
chmod +x kcode.phar
40+
sudo mv kcode.phar /usr/local/bin/kcode
41+
42+
# Generate .kcode/ configs: phpunit.xml.dist, phpstan.neon, psalm.xml, etc.
43+
- name: Initialize devkit (.kcode/ generation)
44+
run: kcode init
45+
46+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
47+
# "not a valid target" warnings for classes extending vendor base classes
48+
- name: Patch phpunit.xml.dist
49+
run: |
50+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
51+
52+
# cs-fixer → phpstan (L9) → psalm → phpunit
53+
# Exit code ≠ 0 fails the job (zero-tolerance policy)
54+
- name: Run full quality pipeline
55+
run: kcode quality

.github/workflows/code-quality.yml

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
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+
# ============================================================================
23+
dependencies:
24+
name: Dependency Validation
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: '8.4'
33+
tools: composer:v2
34+
coverage: none
35+
36+
- name: Validate composer.json
37+
run: composer validate --strict --no-check-lock
38+
39+
- name: Install dependencies
40+
run: composer install --prefer-dist --no-progress --no-scripts
41+
42+
- name: Check platform requirements
43+
run: composer check-platform-reqs
44+
45+
# ============================================================================
46+
# SECURITY AUDIT (ARFA 1.3 — resilience pillar)
47+
# ============================================================================
48+
security:
49+
name: Security Audit
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v4
54+
55+
- uses: shivammathur/setup-php@v2
56+
with:
57+
php-version: '8.4'
58+
tools: composer:v2
59+
coverage: none
60+
61+
- name: Install dependencies
62+
run: composer install --prefer-dist --no-progress --no-scripts
63+
64+
- name: Run composer audit
65+
run: composer audit --format=plain
66+
67+
# ============================================================================
68+
# STATIC ANALYSIS (Spec V4.0 S14 — Type Safety)
69+
# kcode analyse runs PHPStan Level 9 + Psalm (100% type inference).
70+
# ============================================================================
71+
analyse:
72+
name: Static Analysis — PHPStan L9 + Psalm
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- uses: shivammathur/setup-php@v2
79+
with:
80+
php-version: '8.4'
81+
extensions: mbstring, xml
82+
coverage: none
83+
tools: composer:v2
84+
85+
- name: Install dependencies
86+
run: composer install --prefer-dist --no-progress --no-scripts
87+
88+
- name: Install kcode
89+
run: |
90+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
91+
chmod +x kcode.phar
92+
sudo mv kcode.phar /usr/local/bin/kcode
93+
94+
- name: Initialize devkit
95+
run: kcode init
96+
97+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
98+
# "not a valid target" warnings for classes extending vendor base classes
99+
- name: Patch phpunit.xml.dist
100+
run: |
101+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
102+
103+
# Runs PHPStan Level 9 then Psalm sequentially — both must pass
104+
- name: Run PHPStan + Psalm via kcode
105+
run: kcode analyse
106+
107+
# ============================================================================
108+
# CODE STYLE (ARFA 1.3 Naming / Formatting Standards)
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+
# ============================================================================
143+
tests:
144+
name: PHPUnit — Tests (pcov)
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- uses: actions/checkout@v4
149+
150+
- uses: shivammathur/setup-php@v2
151+
with:
152+
php-version: '8.4'
153+
extensions: mbstring, xml
154+
coverage: pcov
155+
tools: composer:v2
156+
157+
- name: Install dependencies
158+
run: composer install --prefer-dist --no-progress --no-scripts
159+
160+
- name: Install kcode
161+
run: |
162+
wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar
163+
chmod +x kcode.phar
164+
sudo mv kcode.phar /usr/local/bin/kcode
165+
166+
- name: Initialize devkit
167+
run: kcode init
168+
169+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
170+
# "not a valid target" warnings for classes extending vendor base classes
171+
- name: Patch phpunit.xml.dist
172+
run: |
173+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
174+
175+
- name: Run tests with coverage (pcov)
176+
run: kcode test --coverage
177+
178+
# ============================================================================
179+
# QUALITY SUMMARY — Gate job (if: always())
180+
# ============================================================================
181+
quality-summary:
182+
name: Quality Summary
183+
runs-on: ubuntu-latest
184+
needs: [dependencies, security, analyse, cs-fixer, tests]
185+
if: always()
186+
187+
steps:
188+
- name: Post quality summary
189+
run: |
190+
echo "## KaririCode ClassDiscovery — Quality Report (ARFA 1.3)" >> "$GITHUB_STEP_SUMMARY"
191+
echo "" >> "$GITHUB_STEP_SUMMARY"
192+
echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY"
193+
echo "|-------|--------|" >> "$GITHUB_STEP_SUMMARY"
194+
echo "| Dependency Validation | ${{ needs.dependencies.result }} |" >> "$GITHUB_STEP_SUMMARY"
195+
echo "| Security Audit | ${{ needs.security.result }} |" >> "$GITHUB_STEP_SUMMARY"
196+
echo "| Static Analysis (PHPStan L9 + Psalm) | ${{ needs.analyse.result }} |" >> "$GITHUB_STEP_SUMMARY"
197+
echo "| Code Style (CS Fixer) | ${{ needs.cs-fixer.result }} |" >> "$GITHUB_STEP_SUMMARY"
198+
echo "| PHPUnit Tests (pcov) | ${{ needs.tests.result }} |" >> "$GITHUB_STEP_SUMMARY"
199+
200+
if [ "${{ needs.security.result }}" != "success" ] || \
201+
[ "${{ needs.analyse.result }}" != "success" ] || \
202+
[ "${{ needs.cs-fixer.result }}" != "success" ] || \
203+
[ "${{ needs.tests.result }}" != "success" ]; then
204+
echo "" >> "$GITHUB_STEP_SUMMARY"
205+
echo "❌ One or more quality gates failed. Merge blocked." >> "$GITHUB_STEP_SUMMARY"
206+
exit 1
207+
fi
208+
209+
echo "" >> "$GITHUB_STEP_SUMMARY"
210+
echo "✅ All quality gates passed — ARFA 1.3 compliant." >> "$GITHUB_STEP_SUMMARY"

.github/workflows/release.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
# Patch generated phpunit.xml.dist — beStrictAboutCoverageMetadata causes false
45+
# "not a valid target" warnings for classes extending vendor base classes
46+
- name: Patch phpunit.xml.dist
47+
run: |
48+
sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist
49+
50+
# Full pipeline: cs-fixer → phpstan (L9) → psalm → phpunit (pcov)
51+
# Exit code ≠ 0 aborts the release — zero tolerance (ARFA 1.3)
52+
- name: Run full quality pipeline (release gate)
53+
run: kcode quality
54+
55+
- name: Extract version from tag
56+
id: version
57+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
58+
59+
- name: Create GitHub Release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
tag_name: ${{ steps.version.outputs.tag }}
63+
name: KaririCode ClassDiscovery ${{ steps.version.outputs.tag }}
64+
draft: false
65+
prerelease: false
66+
body: |
67+
## KaririCode\ClassDiscovery ${{ steps.version.outputs.tag }}
68+
69+
Zero-dependency PHP 8.4+ class discovery component with token-based scanning,
70+
attribute filtering, multi-tier caching, and dependency analysis.
71+
**ARFA 1.3 compliant.**
72+
73+
## Installation
74+
75+
```bash
76+
composer require kariricode/class-discovery
77+
```
78+
79+
## Quick Start
80+
81+
```php
82+
use KaririCode\ClassDiscovery\Scanner\DirectoryScanner;
83+
use KaririCode\ClassDiscovery\Scanner\FileScanner;
84+
85+
$scanner = new DirectoryScanner(new FileScanner());
86+
$results = $scanner->scan(__DIR__ . '/src');
87+
88+
foreach ($results as $class) {
89+
echo $class->fullyQualifiedName . PHP_EOL;
90+
}
91+
```
92+
93+
## Quality Metrics
94+
95+
| Metric | Value |
96+
|--------|-------|
97+
| PHPStan Level | 9 (0 errors) |
98+
| Psalm | 100% (0 errors) |
99+
| Coverage | 100% classes / methods / lines |
100+
| PHP Version | 8.4+ |
101+
| External Dependencies | 0 |
102+
103+
See [CHANGELOG.md](CHANGELOG.md) for details.

0 commit comments

Comments
 (0)