diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bbd010..47958b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: php-version: '8.4' extensions: mbstring, xml coverage: pcov + tools: composer:v2 # Pure dependency install — no scripts to avoid environment pollution - name: Install dependencies @@ -42,6 +43,11 @@ jobs: - name: Initialize devkit (.kcode/ generation) run: kcode init + # src/Contract was removed in v4 — patch the generated phpstan.neon + - name: Patch phpstan.neon (remove stale excludePaths) + run: | + sed -i '/excludePaths:/,/- \.\.\/src\/Contract/d' .kcode/phpstan.neon + # cs-fixer → phpstan (L9) → psalm → phpunit # Exit code ≠ 0 fails the job (zero-tolerance policy) - name: Run full quality pipeline diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml new file mode 100644 index 0000000..23f0847 --- /dev/null +++ b/.github/workflows/code-quality.yml @@ -0,0 +1,212 @@ +name: Code Quality + +# ARFA 1.3 / KaririCode Spec V4.0 — Parallel Quality Gates +# Runs 5 parallel jobs with a quality-summary gate job. +# Triggers: main, develop, feature branches, PRs, and manual dispatch. + +on: + push: + branches: + - main + - develop + - 'feature/**' + pull_request: + branches: + - main + - develop + workflow_dispatch: + +jobs: + # ============================================================================ + # DEPENDENCY VALIDATION (Spec V4.0 — contract compliance) + # Validates that composer.json is valid and platform requirements are met. + # ============================================================================ + dependencies: + name: Dependency Validation + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + coverage: none + + - name: Validate composer.json + run: composer validate --strict --no-check-lock + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-scripts + + - name: Check platform requirements + run: composer check-platform-reqs + + # ============================================================================ + # SECURITY AUDIT (ARFA 1.3 — resilience pillar) + # Uses native composer audit — no deprecated security-checker. + # ============================================================================ + security: + name: Security Audit + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + tools: composer:v2 + coverage: none + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-scripts + + - name: Run composer audit + run: composer audit --format=plain + + # ============================================================================ + # STATIC ANALYSIS (Spec V4.0 S14 — Type Safety) + # kcode analyse runs PHPStan Level 9 + Psalm (100% type inference). + # Both tools must pass with zero errors — enforced by kcode exit code. + # ============================================================================ + analyse: + name: Static Analysis — PHPStan L9 + Psalm + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: mbstring, xml + coverage: none + tools: composer:v2 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-scripts + + - name: Install kcode + run: | + wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar + chmod +x kcode.phar + sudo mv kcode.phar /usr/local/bin/kcode + + - name: Initialize devkit + run: kcode init + + # src/Contract was removed in v4 — patch the generated phpstan.neon + - name: Patch phpstan.neon (remove stale excludePaths) + run: | + sed -i '/excludePaths:/,/- \.\.\/src\/Contract/d' .kcode/phpstan.neon + + # Runs PHPStan Level 9 then Psalm sequentially — both must pass + - name: Run PHPStan + Psalm via kcode + run: kcode analyse + + # ============================================================================ + # CODE STYLE (ARFA 1.3 Naming / Formatting Standards) + # kcode cs:fix enforces PSR-12 + PHP 8.4 migrations + KaririCode rules. + # --check: dry-run only — fails if any violation exists. + # ============================================================================ + cs-fixer: + name: Code Style — PHP CS Fixer + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: mbstring, xml + coverage: none + tools: composer:v2 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-scripts + + - name: Install kcode + run: | + wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar + chmod +x kcode.phar + sudo mv kcode.phar /usr/local/bin/kcode + + - name: Initialize devkit + run: kcode init + + - name: Check code style (dry-run) + run: kcode cs:fix --check + + # ============================================================================ + # UNIT & INTEGRATION TESTS (ARFA 1.3 §Testing — Zero Tolerance) + # pcov is the mandatory driver (performance + accuracy over Xdebug). + # Requires: 0 failures, 0 errors, 0 warnings, 0 risky tests. + # Target: 128 tests / 234 assertions (processor-pipeline baseline). + # ============================================================================ + tests: + name: PHPUnit — 128 Tests (pcov) + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: mbstring, xml + coverage: pcov + tools: composer:v2 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-scripts + + - name: Install kcode + run: | + wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar + chmod +x kcode.phar + sudo mv kcode.phar /usr/local/bin/kcode + + - name: Initialize devkit + run: kcode init + + - name: Run tests with coverage (pcov) + run: kcode test --coverage + + # ============================================================================ + # QUALITY SUMMARY — Gate job (if: always()) + # Aggregates all job results and fails the workflow if any check failed. + # Posts a markdown summary to the GitHub Actions run. + # ============================================================================ + quality-summary: + name: Quality Summary + runs-on: ubuntu-latest + needs: [dependencies, security, analyse, cs-fixer, tests] + if: always() + + steps: + - name: Post quality summary + run: | + echo "## KaririCode ProcessorPipeline — Quality Report (ARFA 1.3)" >> "$GITHUB_STEP_SUMMARY" + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "| Check | Result |" >> "$GITHUB_STEP_SUMMARY" + echo "|-------|--------|" >> "$GITHUB_STEP_SUMMARY" + echo "| Dependency Validation | ${{ needs.dependencies.result }} |" >> "$GITHUB_STEP_SUMMARY" + echo "| Security Audit | ${{ needs.security.result }} |" >> "$GITHUB_STEP_SUMMARY" + echo "| Static Analysis (PHPStan L9 + Psalm) | ${{ needs.analyse.result }} |" >> "$GITHUB_STEP_SUMMARY" + echo "| Code Style (CS Fixer) | ${{ needs.cs-fixer.result }} |" >> "$GITHUB_STEP_SUMMARY" + echo "| PHPUnit Tests (128 / pcov) | ${{ needs.tests.result }} |" >> "$GITHUB_STEP_SUMMARY" + + if [ "${{ needs.security.result }}" != "success" ] || \ + [ "${{ needs.analyse.result }}" != "success" ] || \ + [ "${{ needs.cs-fixer.result }}" != "success" ] || \ + [ "${{ needs.tests.result }}" != "success" ]; then + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "❌ One or more quality gates failed. Merge blocked." >> "$GITHUB_STEP_SUMMARY" + exit 1 + fi + + echo "" >> "$GITHUB_STEP_SUMMARY" + echo "✅ All quality gates passed — ARFA 1.3 compliant." >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d5cb908 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,107 @@ +name: Release + +# ARFA 1.3 / KaririCode Spec V4.0 — Release Pipeline +# Triggers on semantic version tags (v*). +# Full quality gate (kcode quality) must pass before release is published. + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + release: + name: Quality Gate + GitHub Release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + # PHP 8.4 + pcov: releases MUST pass with coverage (ARFA 1.3 §Testing) + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.4' + extensions: mbstring, xml + coverage: pcov + tools: composer:v2 + + # --no-scripts prevents accidental environment pollution during release + - name: Install dependencies + run: composer install --no-interaction --prefer-dist --no-progress --no-scripts + + - name: Install kcode (KaririCode Devkit) + run: | + wget -q https://github.com/KaririCode-Framework/kariricode-devkit/releases/latest/download/kcode.phar + chmod +x kcode.phar + sudo mv kcode.phar /usr/local/bin/kcode + + - name: Initialize devkit + run: kcode init + + # src/Contract was removed in v4 — patch the generated phpstan.neon + - name: Patch phpstan.neon (remove stale excludePaths) + run: | + sed -i '/excludePaths:/,/- \.\.\/src\/Contract/d' .kcode/phpstan.neon + + # Full pipeline: cs-fixer → phpstan (L9) → psalm → phpunit (pcov) + # Exit code ≠ 0 aborts the release — zero tolerance (ARFA 1.3) + - name: Run full quality pipeline (release gate) + run: kcode quality + + - name: Extract version from tag + id: version + run: echo "tag=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.version.outputs.tag }} + name: KaririCode ProcessorPipeline ${{ steps.version.outputs.tag }} + draft: false + prerelease: false + body: | + ## KaririCode\ProcessorPipeline ${{ steps.version.outputs.tag }} + + A robust, immutable processor pipeline component for the KaririCode Framework. + Enables modular, configurable processing chains for data transformation, + validation, and sanitization. **ARFA 1.3 compliant.** + + ## Installation + + ```bash + composer require kariricode/processor-pipeline + ``` + + ## Quick Start + + ```php + use KaririCode\ProcessorPipeline\ProcessorRegistry; + use KaririCode\ProcessorPipeline\ProcessorBuilder; + + $registry = new ProcessorRegistry(); + $registry + ->register('sanitizer', 'trim', new TrimProcessor()) + ->register('sanitizer', 'lowercase', new LowercaseProcessor()); + + $builder = new ProcessorBuilder($registry); + $pipeline = $builder->buildPipeline('sanitizer', ['trim', 'lowercase']); + + $result = $pipeline->process(' HELLO WORLD '); + // Result: 'hello world' + ``` + + ## Quality Metrics + + | Metric | Value | + |--------|-------| + | Tests | 128 passing | + | Assertions | 234 | + | PHPStan Level | 9 (0 errors) | + | Psalm | 100% (0 errors) | + | Coverage | 100% classes / methods / lines | + | PHP Version | 8.4+ | + + See [CHANGELOG.md](CHANGELOG.md) for details. diff --git a/README.md b/README.md index 0641d81..3cb6344 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ -# KaririCode Framework: ProcessorPipeline V4.0 +# KaririCode Framework: ProcessorPipeline -[![en](https://img.shields.io/badge/lang-en-red.svg)](README.md) -[![pt-br](https://img.shields.io/badge/lang-pt--br-green.svg)](README.pt-br.md) [![PHP 8.4+](https://img.shields.io/badge/PHP-8.4+-777BB4?style=flat-square&logo=php&logoColor=white)](https://www.php.net/) [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) [![ARFA 1.3](https://img.shields.io/badge/ARFA-1.3-orange.svg)](docs/specs/SPEC-001-processor-pipeline.md) @@ -214,11 +212,10 @@ ProcessorBuilder ──→ ProcessorRegistry ```bash git clone https://github.com/KaririCode-Framework/kariricode-processor-pipeline.git cd kariricode-processor-pipeline -make setup-env && make up && make composer-install -make test # Run tests -make coverage # Coverage report -make cs-fix # Code style -make quality # Full quality check +composer install +kcode init +kcode test # Run tests +kcode quality # Full quality check ``` ## Documentation diff --git a/src/Attribute/Process.php b/src/Attribute/Process.php index cf4f392..c10358c 100644 --- a/src/Attribute/Process.php +++ b/src/Attribute/Process.php @@ -54,7 +54,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 2.0.0 */ #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] diff --git a/src/Exception/InvalidProcessorConfigurationException.php b/src/Exception/InvalidProcessorConfigurationException.php index 9583f0d..3c76f7f 100644 --- a/src/Exception/InvalidProcessorConfigurationException.php +++ b/src/Exception/InvalidProcessorConfigurationException.php @@ -16,7 +16,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 4.0.0 * * @see \KaririCode\Contract\Processor\ConfigurableProcessor diff --git a/src/Exception/PipelineExecutionException.php b/src/Exception/PipelineExecutionException.php index ca31abf..21f5b45 100644 --- a/src/Exception/PipelineExecutionException.php +++ b/src/Exception/PipelineExecutionException.php @@ -14,7 +14,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 4.0.0 */ final class PipelineExecutionException extends ProcessorPipelineException diff --git a/src/Exception/ProcessorNotFoundException.php b/src/Exception/ProcessorNotFoundException.php index ed4d50d..476fd37 100644 --- a/src/Exception/ProcessorNotFoundException.php +++ b/src/Exception/ProcessorNotFoundException.php @@ -11,7 +11,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 2.0.0 */ final class ProcessorNotFoundException extends ProcessorPipelineException diff --git a/src/Exception/ProcessorPipelineException.php b/src/Exception/ProcessorPipelineException.php index b32356d..9e919d5 100644 --- a/src/Exception/ProcessorPipelineException.php +++ b/src/Exception/ProcessorPipelineException.php @@ -18,7 +18,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 1.0.0 */ class ProcessorPipelineException extends \RuntimeException diff --git a/src/Handler/ProcessorHandler.php b/src/Handler/ProcessorHandler.php index 44385ac..a52fa4c 100644 --- a/src/Handler/ProcessorHandler.php +++ b/src/Handler/ProcessorHandler.php @@ -24,7 +24,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 4.0.0 */ final readonly class ProcessorHandler implements Processor diff --git a/src/Pipeline/Pipeline.php b/src/Pipeline/Pipeline.php index f01f172..981a9c5 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -78,7 +78,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 1.0.0 * * @see \KaririCode\ProcessorPipeline\ProcessorBuilder Construction diff --git a/src/ProcessorBuilder.php b/src/ProcessorBuilder.php index 9106873..355e925 100644 --- a/src/ProcessorBuilder.php +++ b/src/ProcessorBuilder.php @@ -81,7 +81,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 1.0.0 * * @see \KaririCode\ProcessorPipeline\ProcessorRegistry Processor source diff --git a/src/ProcessorRegistry.php b/src/ProcessorRegistry.php index 24d0287..c7bda2e 100644 --- a/src/ProcessorRegistry.php +++ b/src/ProcessorRegistry.php @@ -108,7 +108,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 1.0.0 * * @see \KaririCode\ProcessorPipeline\ProcessorBuilder Pipeline construction diff --git a/src/Result/ProcessingResultCollection.php b/src/Result/ProcessingResultCollection.php index a47cbd4..d9fe848 100644 --- a/src/Result/ProcessingResultCollection.php +++ b/src/Result/ProcessingResultCollection.php @@ -61,7 +61,7 @@ * @author Walmir Silva * @copyright 2025 KaririCode * @license MIT - * @version 4.0.0 + * @version 2.0.0 * @since 1.0.0 * * @see \KaririCode\ProcessorPipeline\Pipeline\Pipeline Pipeline integration