66 lines
1.9 KiB
YAML
66 lines
1.9 KiB
YAML
name: Tests - Run PHP compatibility and unit tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
test:
|
|
name: PHP ${{ matrix.php-versions }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
php-versions: ['7.0', '7.4', '8.0']
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php-versions }}
|
|
extensions: mbstring, intl, zip
|
|
tools: composer:v2
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
# Install base dependencies from lock file
|
|
composer install --prefer-dist --no-progress
|
|
|
|
# Update specific dependencies for higher PHP versions if needed
|
|
if [[ "${{ matrix.php-versions }}" == "7.4" || "${{ matrix.php-versions }}" == "8.0" ]]; then
|
|
echo "Updating dependencies for PHP ${{ matrix.php-versions }}..."
|
|
composer require --dev phpunit/phpunit:"^9.5" 10up/wp_mock:"^1.0" --no-update --no-plugins --no-scripts
|
|
elif [[ "${{ matrix.php-versions }}" == "7.0" ]]; then
|
|
# Force PHPUnit 6.5 for PHP 7.0
|
|
composer require --dev phpunit/phpunit:"^6.5" --update-with-dependencies
|
|
fi
|
|
|
|
- name: Run tests
|
|
run: ./vendor/bin/phpunit
|
|
|
|
code-style:
|
|
name: Code Style
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '7.4'
|
|
extensions: mbstring, intl, zip
|
|
tools: composer:v2, phpcs
|
|
|
|
- name: Install dependencies
|
|
run: composer install --prefer-dist --no-progress
|
|
|
|
- name: Run PHPCS
|
|
run: ./vendor/bin/phpcs --standard=WordPress ./includes ./admin ./wp-plugin-starter-template.php
|