ci: adopt estate CI standard + convert 7 hand-rolled tests to PHPUnit (v0.7.0)

- Replace hand-rolled ci.yml jobs with thin caller to reusable estate workflow
  (peptiderepo/peptide-e2e/.github/workflows/ci.yml@main); tests: stubs; has_js: false.
  workflow_call + permissions: contents: write added per estate standard so deploy.yml
  can gate on it and phpcbf auto-commit step has required token scope.

- Convert 7 hand-rolled test-*.php scripts to PHPUnit TestCase classes:
    PeptideCptTest        <- test-peptide-cpt.php
    VerificationScannerTest <- test-verification-scanner.php
    VerificationSettingsTest <- test-verification-settings.php
    Migration0004Test     <- test-migration-0004.php
    JsonldTest            <- test-jsonld.php
    JsonldWebpageTest     <- test-jsonld-webpage.php
    JsonldPeptidePieceTest <- test-jsonld-peptide-piece.php

  All assertions preserved; old scripts remain in tests/unit/ but CI no longer
  runs them (PHPUnit discovery matches *Test.php only).

- Rewrite tests/bootstrap.php: full WP stub library for PHPUnit (WP_Post, WP_Error,
  all option/cron/CPT/taxonomy/permalink stubs); registers PR_Core_Autoloader.
- Add phpunit.xml.dist (bootstrap, unit suite, includes/ coverage).
- Add phpunit/phpunit ^9.6 + yoast/phpunit-polyfills ^2.0 to require-dev.
- Add composer test script (vendor/bin/phpunit --configuration phpunit.xml.dist).
- deploy.yml: add permissions: contents: write.
- Version bump 0.6.2 -> 0.7.0.

Agent-Session: claude-adopt-ci-20260616
This commit is contained in:
peptiderepo
2026-06-16 15:23:48 +00:00
parent d0b5875fd8
commit 08d7696444
14 changed files with 1884 additions and 194 deletions

View File

@@ -1,78 +1,27 @@
##
# Thin CI caller — peptide-repo-core
#
# Delegates all lint/test/file-size jobs to the estate reusable workflow.
# Per estate standard: workflow_call is required so deploy.yml can gate on it.
# See: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main for job definitions.
##
name: CI
on:
pull_request: {}
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_call:
branches: [main]
workflow_call: {}
# Required: calling workflow must declare contents: write so the reusable
# phpcs job can commit phpcbf auto-fixes back to the PR branch.
permissions:
contents: read
contents: write
jobs:
# ── PHP Syntax Check ─────────────────────────────────────────────
lint-php:
name: PHP Lint (${{ matrix.php }})
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '8.1', '8.2', '8.3' ]
steps:
- uses: actions/checkout@v4
- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Syntax check all PHP files
run: find . -name "*.php" -not -path "./vendor/*" | xargs -n 1 php -l
- name: Unit tests (lightweight, no PHPUnit)
run: |
for test in tests/unit/test-*.php; do
echo "=== Running $test ==="
php "$test"
done
# ── 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: composer run lint
continue-on-error: true
# ── 300-line file check ──────────────────────────────────────────
file-size:
name: 300-line file check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check no PHP file exceeds 300 lines
run: |
violations=0
while IFS= read -r file; do
lines=$(wc -l < "$file")
if [ "$lines" -gt 300 ]; then
echo "VIOLATION: $file ($lines lines)"
violations=$((violations + 1))
fi
done < <(find . -name "*.php" -not -path "./vendor/*" -not -path "./tests/*")
if [ "$violations" -gt 0 ]; then
echo "$violations file(s) exceed 300 lines"
exit 1
fi
echo "All PHP files are 300 lines or fewer."
ci:
uses: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main
with:
tests: stubs
has_js: false
secrets: inherit

View File

@@ -4,8 +4,10 @@ on:
push:
branches: [ main ]
# contents: write required so the ci.yml caller can pass write permission
# through to the phpcbf auto-commit step in the reusable workflow.
permissions:
contents: read
contents: write
concurrency:
group: deploy-peptide-repo-core