diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cc41a7..fa063e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,15 +6,17 @@ on: pull_request: branches: [ main ] -jobs: - lint: - name: PHP Lint + PHPCS - runs-on: ubuntu-latest +permissions: + contents: read +jobs: + # ── PHP Syntax Check ───────────────────────────────────────────── + lint-php: + name: PHP Lint (${{ matrix.php }}) + runs-on: ubuntu-latest strategy: matrix: - php: [ '8.0', '8.1', '8.2' ] - + php: [ '8.1', '8.2', '8.3' ] steps: - uses: actions/checkout@v4 @@ -22,37 +24,30 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - tools: composer, cs2pr - extensions: mbstring - - name: PHP syntax check + - name: Syntax check all PHP files run: find . -name "*.php" -not -path "./vendor/*" | xargs -n 1 php -l - - name: Install PHPCS + WordPress standards - run: | - composer global require --with-all-dependencies \ - "squizlabs/php_codesniffer=^3.13" \ - "wp-coding-standards/wpcs=^3.0" \ - "phpcsstandards/phpcsutils=^1.0" - phpcs --config-set installed_paths $(composer global config home)/vendor/wp-coding-standards/wpcs + # ── WordPress Coding Standards (PHP CodeSniffer) ────────────────── + lint-phpcs: + name: WordPress Coding Standards + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Install Composer dependencies + run: composer install --no-interaction --prefer-dist --no-progress - name: Run PHPCS - run: | - phpcs --standard=WordPress --extensions=php \ - --ignore=vendor/*,node_modules/*,tests/* \ - --report=checkstyle \ - --warning-severity=0 \ - . | cs2pr || true - - - name: Run PHPCS (strict — fail on errors) - run: | - phpcs --standard=WordPress --extensions=php \ - --ignore=vendor/*,node_modules/*,tests/* \ - --error-severity=1 --warning-severity=0 \ - --report=summary \ - . + run: composer run lint continue-on-error: true + # ── 300-line file check ────────────────────────────────────────── file-size: name: 300-line file check runs-on: ubuntu-latest diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 9d18aa3..db9e11e 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -48,10 +48,12 @@ peptide-repo-core/ ├── ARCHITECTURE.md # This file ├── CONVENTIONS.md # Naming patterns, extension guides ├── CHANGELOG.md # Semantic versioning changelog +├── composer.json # Dev dependencies (PHPCS, WPCS) and lint scripts +├── phpcs.xml.dist # PHPCS ruleset configuration │ ├── .github/ │ └── workflows/ -│ └── ci.yml # PHP lint (8.0-8.2), PHPCS, 300-line check +│ └── ci.yml # PHP lint (8.1-8.3), PHPCS WordPress, 300-line check │ ├── assets/ │ └── css/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..ce73219 --- /dev/null +++ b/composer.json @@ -0,0 +1,24 @@ +{ + "name": "peptiderepo/peptide-repo-core", + "description": "Canonical peptide data layer for the peptiderepo.com ecosystem.", + "type": "wordpress-plugin", + "license": "GPL-2.0-or-later", + "require": { + "php": ">=8.1" + }, + "require-dev": { + "squizlabs/php_codesniffer": "^3.13", + "wp-coding-standards/wpcs": "^3.0", + "phpcsstandards/phpcsutils": "^1.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "scripts": { + "lint": "phpcs", + "lint:fix": "phpcbf" + } +} diff --git a/peptide-repo-core.php b/peptide-repo-core.php index fc35fcf..dfdabeb 100644 --- a/peptide-repo-core.php +++ b/peptide-repo-core.php @@ -8,7 +8,7 @@ * Author URI: https://peptiderepo.com * License: GPL-2.0-or-later * Text Domain: peptide-repo-core - * Requires PHP: 8.0 + * Requires PHP: 8.1 * * @see ARCHITECTURE.md — Full data flow and file tree. * @see CONVENTIONS.md — Naming patterns and extension guides. diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..31dcb0a --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,17 @@ + + + WordPress coding standards for Peptide Repo Core. + + . + + /vendor/* + /node_modules/* + /tests/* + + + + + + + +