mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-15 12:43:33 +09:00
797bc2fd98
git-subtree-dir: includes/lib/action-scheduler git-subtree-split: c828347715e6c3318c8ab8b4fea2d87b31d51aac
93 lines
3.1 KiB
YAML
93 lines
3.1 KiB
YAML
name: Run unit tests on PR
|
|
on:
|
|
pull_request
|
|
jobs:
|
|
test:
|
|
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }} MU ${{ matrix.multisite }}
|
|
timeout-minutes: 15
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
# We test against the earliest and latest PHP versions for each major supported version.
|
|
php: [ '7.0', '7.4', '8.0', '8.1', '8.2' ]
|
|
wp: [ '6.3', '6.4', '6.5', 'latest', 'nightly' ]
|
|
multisite: [ '0', '1' ]
|
|
exclude:
|
|
# WordPress 6.6+ requires PHP 7.2+
|
|
- php: 7.0
|
|
wp: latest
|
|
- php: 7.0
|
|
wp: nightly
|
|
|
|
services:
|
|
database:
|
|
image: mysql:5.6
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
ports:
|
|
- 3306:3306
|
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: ${{ matrix.php }}
|
|
tools: composer
|
|
extensions: mysql
|
|
coverage: none
|
|
|
|
- name: Tool versions
|
|
run: |
|
|
php --version
|
|
composer --version
|
|
|
|
- name: Get cached composer directories
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: ./vendor
|
|
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}
|
|
|
|
- name: Setup and install composer
|
|
run: composer install
|
|
|
|
- name: Setup PHPUnit
|
|
run: |
|
|
# PHPUnit 5.7 when using PHP 5.6 - 7.0.
|
|
if [ "$(php -r "echo version_compare( PHP_VERSION, '7.1', '<' );")" ]; then
|
|
curl -L https://phar.phpunit.de/phpunit-5.7.phar -o /tmp/phpunit
|
|
OVERWRITE=1
|
|
# PHPUnit 7.5 when using PHP 7.1 - 7.4.
|
|
elif [ "$(php -r "echo version_compare( PHP_VERSION, '8.0', '<' );")" ]; then
|
|
curl -L https://phar.phpunit.de/phpunit-7.5.phar -o /tmp/phpunit
|
|
OVERWRITE=1
|
|
# PHPUnit 7.5 (Custom Fork) when using PHP 8.0+.
|
|
else
|
|
curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip
|
|
unzip -d /tmp/phpunit-fork /tmp/phpunit-7.5-fork.zip
|
|
composer --working-dir=/tmp/phpunit-fork/phpunit-add-compatibility-with-php8-to-phpunit-7 install
|
|
rm ./vendor/bin/phpunit
|
|
ln -sf /tmp/phpunit-fork/phpunit-add-compatibility-with-php8-to-phpunit-7/phpunit ./vendor/bin/phpunit
|
|
fi
|
|
|
|
if [ $OVERWRITE ]; then
|
|
rm ./vendor/bin/phpunit
|
|
chmod +x /tmp/phpunit
|
|
mv /tmp/phpunit ./vendor/bin/phpunit
|
|
fi
|
|
|
|
- name: Init DB and WP
|
|
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
|
|
|
|
- name: Run tests
|
|
run: |
|
|
./vendor/bin/phpunit --version
|
|
WP_MULTISITE=${{ matrix.multisite }} ./vendor/bin/phpunit -c ./tests/phpunit.xml.dist
|
|
|
|
- name: Code Coverage
|
|
run: |
|
|
bash <(curl -s https://codecov.io/bash)
|