From 29ab4e76d22ca83931a15f6efdeee9a60fed9967 Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Tue, 14 Apr 2026 16:48:35 +0700 Subject: [PATCH] ci: add PHPUnit workflow that runs the existing test suite 59 tests exist across 8 files but were never running in CI. This adds a ci.yml with PHP Lint + PHPCS + PHPUnit against WP test framework on a MySQL service. Agent-Session: cowork-pr-theme-tests-20260414 --- .github/workflows/ci.yml | 105 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..531bc1c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,105 @@ +name: CI — Lint & Test + +# Runs on every PR and every push to main. +# Three jobs in parallel: +# 1. PHP Lint — syntax check across supported PHP versions +# 2. PHPCS — WordPress coding standards (non-blocking during theme rollout) +# 3. PHPUnit — runs the theme's test suite against the WordPress test framework + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + php-lint: + name: PHP Lint (${{ matrix.php }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['7.4', '8.1', '8.3'] + steps: + - uses: actions/checkout@v4 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + - name: Syntax check all PHP files + run: | + set -e + find . -name '*.php' \ + -not -path './vendor/*' \ + -not -path './node_modules/*' \ + -not -path './.git/*' \ + -print0 | xargs -0 -n1 -P4 php -l > /dev/null + + phpcs: + name: PHPCS (WordPress standards) + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + coverage: none + tools: composer:v2 + - name: Install dependencies + run: composer install --no-progress --no-interaction --prefer-dist + - name: Run PHPCS + run: vendor/bin/phpcs --standard=.phpcs.xml.dist + + phpunit: + name: PHPUnit (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1'] + wp: ['latest'] + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: wp_tests + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + steps: + - uses: actions/checkout@v4 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer:v2 + extensions: mysqli + - name: Install composer dependencies + run: composer install --no-progress --no-interaction --prefer-dist + - name: Wait for MySQL + run: | + for i in {1..30}; do + if mysqladmin ping -h 127.0.0.1 -P 3306 -u root -proot --silent; then + echo "MySQL is up"; break + fi + echo "Waiting for MySQL..."; sleep 2 + done + - name: Install WordPress test suite + env: + WP_TESTS_DIR: /tmp/wordpress-tests-lib + WP_CORE_DIR: /tmp/wordpress + run: | + chmod +x bin/install-wp-tests.sh + bin/install-wp-tests.sh wp_tests root root 127.0.0.1:3306 ${{ matrix.wp }} + - name: Run PHPUnit + env: + WP_TESTS_DIR: /tmp/wordpress-tests-lib + run: vendor/bin/phpunit --colors=always