Skip to content

Tests

Tests #1

Workflow file for this run

name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
name: PHP ${{ matrix.php-version }} Tests
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd
coverage: xdebug
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Run PHPUnit tests
run: composer test
- name: Run tests with coverage
if: matrix.php-version == '8.1'
run: composer test:coverage
- name: Check coverage threshold
if: matrix.php-version == '8.1'
run: composer coverage:check
- name: Upload coverage reports to Codecov
if: matrix.php-version == '8.1'
uses: codecov/codecov-action@v3
with:
file: ./coverage/clover.xml
fail_ci_if_error: true
code-quality:
runs-on: ubuntu-latest
name: Code Quality
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: dom, curl, libxml, mbstring, zip
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Run PHPCS
run: vendor/bin/phpcs --standard=phpcs.xml simple-wp-optimizer.php
- name: Run PHPMD
run: vendor/bin/phpmd simple-wp-optimizer.php text phpmd.xml
- name: Run PHPStan
run: vendor/bin/phpstan analyse --configuration=phpstan.neon