|
| 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" |
0 commit comments