woocommerce/plugins/woocommerce-admin/.github/workflows/test-php.yml

83 lines
3.4 KiB
YAML

name: Run PHP unit tests
on: [pull_request]
jobs:
test-php:
env:
WP_CORE_DIR: '/tmp/wordpress'
COMPOSER_DEV: 1
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3']
wordpress: ['5.4', '5.6']
woocommerce: ['4.8.0', '4.9.1']
phpunit: ['7.5.20']
composer: ['2.0.6']
include:
- php: '7.0'
wordpress: '5.5'
woocommerce: 'latest'
phpunit: '6.5.9'
composer: '1.10.19'
- php: '7.0'
wordpress: '5.6'
woocommerce: '4.9.1'
phpunit: '6.5.9'
composer: '2.0.6'
- php: '8.0'
wordpress: '5.6'
woocommerce: '5.1.0'
phpunit: '7.5.20'
composer: '2.0.6'
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.7.0
with:
access_token: ${{ github.token }}
- name: Check out repository code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@2.9.0
with:
php-version: ${{matrix.php}}
tools: phpunit:${{matrix.phpunit}}
extensions: mysqli
- name: Setup Node.js
uses: actions/setup-node@v2-beta
with:
node-version: '14'
- name: Set up the tests
env:
WP_VERSION: ${{matrix.wordpress}}
WC_VERSION: ${{matrix.woocommerce}}
PHP_UNIT: ${{matrix.phpunit}}
COMPOSER_VERSION: ${{matrix.composer}}
run: |
sudo /etc/init.d/mysql start
bash bin/ci/gh-install-wp-tests.sh wc_admin_test root 'root' localhost
cd "$WP_CORE_DIR/wp-content/plugins/woocommerce-admin/"
npm run build:feature-config
composer install
node --version
npm --version
timedatectl
- name: Add PHP8 Compatibility.
run: |
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
cd "$WP_CORE_DIR/wp-content/plugins/woocommerce-admin/"
composer install
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-7.5-fork /tmp/phpunit-7.5-fork.zip
composer bin phpunit config --unset platform
composer bin phpunit config repositories.0 '{"type": "path", "url": "/tmp/phpunit-7.5-fork/phpunit-add-compatibility-with-php8-to-phpunit-7", "options": {"symlink": false}}'
composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs
rm -rf ./vendor/phpunit/
composer dump-autoload
fi
- name: Run the PHP unit tests
run: bin/phpunit.sh
shell: bash