2021-01-21 12:03:07 +00:00
|
|
|
name: Run unit tests on PR
|
|
|
|
on:
|
|
|
|
pull_request
|
2021-10-13 03:51:07 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
shell: bash
|
2022-04-21 16:45:12 +00:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2021-01-21 12:03:07 +00:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }}
|
2022-05-31 14:58:54 +00:00
|
|
|
timeout-minutes: 30
|
2022-04-27 01:28:56 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2021-08-09 16:55:53 +00:00
|
|
|
continue-on-error: ${{ matrix.wp == 'nightly' }}
|
2021-01-21 12:03:07 +00:00
|
|
|
strategy:
|
2021-02-09 10:39:56 +00:00
|
|
|
fail-fast: false
|
2021-01-21 12:03:07 +00:00
|
|
|
matrix:
|
2022-03-18 09:08:37 +00:00
|
|
|
php: [ '7.2', '7.3', '7.4', '8.0' ]
|
2021-01-21 12:03:07 +00:00
|
|
|
wp: [ "latest" ]
|
|
|
|
include:
|
|
|
|
- wp: nightly
|
|
|
|
php: '7.4'
|
2022-05-25 21:17:17 +00:00
|
|
|
- wp: '5.9'
|
2021-01-21 12:03:07 +00:00
|
|
|
php: 7.2
|
2022-05-25 21:17:17 +00:00
|
|
|
- wp: '5.8'
|
2021-01-21 12:03:07 +00:00
|
|
|
php: 7.2
|
|
|
|
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:
|
2022-07-20 15:11:42 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-05-17 18:48:24 +00:00
|
|
|
|
|
|
|
- uses: ./.github/actions/cache-deps
|
|
|
|
with:
|
|
|
|
workflow_name: pr-unit-tests
|
|
|
|
workflow_cache: ${{ secrets.WORKFLOW_CACHE }}
|
2021-01-21 12:03:07 +00:00
|
|
|
|
|
|
|
- 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
|
|
|
|
|
2022-05-17 18:48:24 +00:00
|
|
|
- name: Install and Build
|
|
|
|
uses: ./.github/actions/install-build
|
2022-07-22 11:32:03 +00:00
|
|
|
with:
|
|
|
|
composer_no_dev: 0
|
2021-01-21 12:03:07 +00:00
|
|
|
|
2022-03-21 18:09:13 +00:00
|
|
|
- name: Build Admin feature config
|
|
|
|
run: |
|
2022-06-09 21:40:07 +00:00
|
|
|
pnpm build:feature-config --filter=woocommerce
|
2021-01-21 12:03:07 +00:00
|
|
|
|
2022-04-26 15:20:32 +00:00
|
|
|
- name: Add PHP8 Compatibility.
|
2021-01-21 12:03:07 +00:00
|
|
|
run: |
|
|
|
|
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
|
2022-04-26 14:07:15 +00:00
|
|
|
cd plugins/woocommerce
|
2021-01-21 12:03:07 +00:00
|
|
|
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}}'
|
2021-08-24 07:39:29 +00:00
|
|
|
composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs
|
|
|
|
rm -rf ./vendor/phpunit/
|
2022-06-09 21:40:07 +00:00
|
|
|
composer dump-autoload
|
2021-08-09 16:00:29 +00:00
|
|
|
fi
|
2021-01-21 12:03:07 +00:00
|
|
|
|
|
|
|
- name: Init DB and WP
|
2022-04-21 16:45:12 +00:00
|
|
|
working-directory: plugins/woocommerce
|
2021-01-21 12:03:07 +00:00
|
|
|
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
|
|
|
|
|
|
|
|
- name: Run tests
|
2022-06-16 04:55:25 +00:00
|
|
|
run: pnpm -- turbo run test --filter=woocommerce
|