fix: auto-install composer deps in pre-commit; fix PHPCS arrow alignment #1527
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| phpunit: | |
| name: PHPUnit (WP ${{ matrix.wp }}) | |
| runs-on: ubuntu-latest | |
| # Plugin requires WP 7.0+; trunk is the only pre-release target. | |
| # Allow trunk failures since the API may still be in flux. | |
| continue-on-error: ${{ matrix.wp == 'trunk' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| wp: ['trunk'] | |
| services: | |
| mariadb: | |
| image: mariadb:lts | |
| env: | |
| MARIADB_ROOT_PASSWORD: root | |
| MARIADB_DATABASE: wordpress_test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="healthcheck.sh --connect --innodb_initialized" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring, intl, zip, pdo_sqlite, mysqli | |
| tools: composer:v2 | |
| coverage: none | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Install subversion | |
| run: sudo apt-get update && sudo apt-get install -y subversion | |
| - name: Install WordPress test suite | |
| run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wp }} true | |
| - name: Run PHPUnit | |
| run: vendor/bin/phpunit | |
| coverage: | |
| name: PHPUnit Coverage | |
| runs-on: ubuntu-latest | |
| # Plugin requires WP 7.0+; trunk is the only pre-release target. | |
| # Allow failures since trunk API may still be in flux. | |
| continue-on-error: true | |
| services: | |
| mariadb: | |
| image: mariadb:lts | |
| env: | |
| MARIADB_ROOT_PASSWORD: root | |
| MARIADB_DATABASE: wordpress_test | |
| ports: | |
| - 3306:3306 | |
| options: >- | |
| --health-cmd="healthcheck.sh --connect --innodb_initialized" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring, intl, zip, pdo_sqlite, mysqli | |
| tools: composer:v2 | |
| coverage: pcov | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install Composer dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Install subversion | |
| run: sudo apt-get update && sudo apt-get install -y subversion | |
| - name: Install WordPress test suite | |
| # Plugin requires WP 7.0+; use trunk until 7.0 is released as stable | |
| run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1 trunk true | |
| - name: Run PHPUnit with coverage | |
| run: vendor/bin/phpunit | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./coverage.xml | |
| flags: phpunit | |
| fail_ci_if_error: false | |
| phpcs: | |
| name: PHPCS | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring | |
| tools: composer:v2 | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Run PHPCS | |
| run: vendor/bin/phpcs | |
| phpstan: | |
| name: PHPStan | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: mbstring | |
| tools: composer:v2 | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Run PHPStan | |
| run: vendor/bin/phpstan analyse --error-format=github |