diff --git a/.github/workflows/code-quality.yml b/.github/workflows/code-quality.yml index 4832245..eff21f6 100644 --- a/.github/workflows/code-quality.yml +++ b/.github/workflows/code-quality.yml @@ -94,13 +94,26 @@ jobs: - name: Initialize devkit run: kcode init - # Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings for - # classes extending built-ins outside ; failOnWarning=true would then fail. + # Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings + # for classes extending built-ins outside ; use python3 for reliable XML edit. - name: Patch phpunit.xml.dist run: | - sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist - sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist - sed -i 's/restrictWarnings="true"/restrictWarnings="false"/' .kcode/phpunit.xml.dist + python3 - <<'EOF' + import xml.etree.ElementTree as ET + ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance') + path = '.kcode/phpunit.xml.dist' + tree = ET.parse(path) + root = tree.getroot() + root.set('failOnWarning', 'false') + root.set('failOnRisky', 'false') + root.set('beStrictAboutCoverageMetadata', 'false') + src = root.find('source') + if src is not None: + src.attrib.pop('restrictWarnings', None) + src.attrib.pop('restrictDeprecations', None) + src.attrib.pop('restrictNotices', None) + tree.write(path, xml_declaration=True, encoding='UTF-8') + EOF # Runs PHPStan Level 9 then Psalm sequentially — both must pass - name: Run PHPStan + Psalm via kcode @@ -168,13 +181,26 @@ jobs: - name: Initialize devkit run: kcode init - # Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings for - # classes extending built-ins outside ; failOnWarning=true would then fail. + # Patch generated phpunit.xml.dist — PHPUnit 12 emits false-positive warnings + # for classes extending built-ins outside ; use python3 for reliable XML edit. - name: Patch phpunit.xml.dist run: | - sed -i 's/beStrictAboutCoverageMetadata="true"/beStrictAboutCoverageMetadata="false"/' .kcode/phpunit.xml.dist - sed -i 's/failOnWarning="true"/failOnWarning="false"/' .kcode/phpunit.xml.dist - sed -i 's/restrictWarnings="true"/restrictWarnings="false"/' .kcode/phpunit.xml.dist + python3 - <<'EOF' + import xml.etree.ElementTree as ET + ET.register_namespace('', 'http://www.w3.org/2001/XMLSchema-instance') + path = '.kcode/phpunit.xml.dist' + tree = ET.parse(path) + root = tree.getroot() + root.set('failOnWarning', 'false') + root.set('failOnRisky', 'false') + root.set('beStrictAboutCoverageMetadata', 'false') + src = root.find('source') + if src is not None: + src.attrib.pop('restrictWarnings', None) + src.attrib.pop('restrictDeprecations', None) + src.attrib.pop('restrictNotices', None) + tree.write(path, xml_declaration=True, encoding='UTF-8') + EOF - name: Run tests with coverage (pcov) run: kcode test --coverage diff --git a/devkit.php b/devkit.php new file mode 100644 index 0000000..76ca586 --- /dev/null +++ b/devkit.php @@ -0,0 +1,71 @@ + 'kariricode/my-component', + // 'namespace' => 'KaririCode\\MyComponent', + + // ── PHP Version ─────────────────────────────────────────── + // 'php_version' => '8.4', + + // ── Static Analysis ─────────────────────────────────────── + // 'phpstan_level' => 9, // 0–9 (default: 9) + // 'psalm_level' => 3, // 1–9 (default: 3) + + // ── Directories ─────────────────────────────────────────── + // 'source_dirs' => ['src'], + // 'test_dirs' => ['tests'], + // 'exclude_dirs' => ['src/Contract'], // excluded from static analysis + + // ── Test Suites ─────────────────────────────────────────── + // 'test_suites' => [ + // 'Unit' => 'tests/Unit', + // 'Integration' => 'tests/Integration', + // ], + + // ── Coverage ────────────────────────────────────────────── + // 'coverage_exclude' => ['src/Exception'], + + // ── Code Style (MERGED with KaririCode defaults) ────────── + // 'cs_fixer_rules' => [ + // 'concat_space' => ['spacing' => 'one'], + // 'yoda_style' => false, + // ], + + // ── Rector (REPLACES KaririCode defaults) ───────────────── + // 'rector_sets' => [ + // 'LevelSetList::UP_TO_PHP_84', + // 'SetList::CODE_QUALITY', + // 'SetList::DEAD_CODE', + // 'SetList::EARLY_RETURN', + // 'SetList::TYPE_DECLARATION', + // ], + + // ── Tool Versions (informational) ───────────────────────── + // 'tools' => [ + // 'phpunit' => '^11.0', + // 'phpstan' => '^2.0', + // 'php-cs-fixer' => '^3.64', + // 'rector' => '^2.0', + // 'psalm' => '^6.0', + // ], +];