woocommerce/.github/workflows/ci.yml

98 lines
3.0 KiB
YAML
Raw Normal View History

name: Run CI
on:
push:
branches:
- trunk
- 'release/**'
2021-10-13 13:15:12 +00:00
defaults:
run:
shell: bash
2022-04-21 18:29:53 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: PHP ${{ matrix.php }} WP ${{ matrix.wp }}
timeout-minutes: 20
runs-on: ubuntu-20.04
2021-08-09 16:55:53 +00:00
continue-on-error: ${{ matrix.wp == 'nightly' }}
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0' ]
wp: [ 'latest' ]
include:
- wp: nightly
php: '7.4'
- wp: '5.8'
php: 7.2
- wp: '5.7'
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:
- name: Checkout code
2022-04-21 18:29:53 +00:00
uses: actions/checkout@v3
- 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-04-21 18:29:53 +00:00
- name: Get cached composer and pnpm directories
uses: actions/cache@v3
id: cache-deps
with:
path: |
2022-04-21 18:29:53 +00:00
~/.pnpm-store
plugins/woocommerce/packages
plugins/woocommerce/**/vendor
2022-04-26 14:47:50 +00:00
key: ${{ runner.os }}-npm-composer-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }}
2022-04-21 18:29:53 +00:00
- name: Install PNPM
2022-05-02 16:39:40 +00:00
run: npm install -g pnpm@6.24.2
2022-04-21 18:29:53 +00:00
- name: Install dependencies
run: pnpm install
2021-11-17 02:17:35 +00:00
2022-04-21 18:29:53 +00:00
- name: Install Composer dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
2021-11-17 02:17:35 +00:00
run: pnpm nx composer-install woocommerce
- name: Build Admin feature config
2022-04-06 03:27:37 +00:00
run: pnpm nx build:feature-config woocommerce
- name: Add PHP8 Compatibility.
run: |
if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then
cd plugins/woocommerce
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/
2021-11-17 02:17:35 +00:00
pnpm nx composer-dump-autoload woocommerce
2021-08-09 16:00:29 +00:00
fi
- name: Init DB and WP
2022-04-21 18:29:53 +00:00
working-directory: plugins/woocommerce
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }}
- name: Run tests
2021-11-17 02:17:35 +00:00
run: pnpm nx test-unit woocommerce