2021-02-09 10:39:56 +00:00
|
|
|
name: Run code coverage on PR
|
|
|
|
on:
|
|
|
|
pull_request
|
2021-10-12 13:33:04 +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-02-09 10:39:56 +00:00
|
|
|
jobs:
|
|
|
|
test:
|
|
|
|
name: Code coverage (PHP 7.4, WP Latest)
|
2022-03-30 00:27:07 +00:00
|
|
|
timeout-minutes: 20
|
2021-02-09 10:39:56 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
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 16:45:12 +00:00
|
|
|
uses: actions/checkout@v3
|
2021-03-14 01:08:46 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 100
|
2021-02-09 10:39:56 +00:00
|
|
|
|
|
|
|
- name: Setup PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: 7.4
|
|
|
|
tools: composer
|
|
|
|
extensions: mysql
|
|
|
|
coverage: none
|
|
|
|
|
|
|
|
- name: Tool versions
|
|
|
|
run: |
|
|
|
|
php --version
|
|
|
|
composer --version
|
|
|
|
|
2022-04-21 16:45:12 +00:00
|
|
|
- name: Get cached composer and pnpm directories
|
|
|
|
uses: actions/cache@v3
|
|
|
|
id: cache-deps
|
2021-02-09 10:39:56 +00:00
|
|
|
with:
|
|
|
|
path: |
|
2022-04-21 16:45:12 +00:00
|
|
|
~/.pnpm-store
|
|
|
|
plugins/woocommerce/packages
|
|
|
|
plugins/woocommerce/vendor
|
|
|
|
key: ${{ runner.os }}-npm-composer-${{ hashFiles('plugins/woocommerce/composer.lock', '**/pnpm-lock.yaml') }}
|
2021-02-09 10:39:56 +00:00
|
|
|
|
2022-04-21 16:45:12 +00:00
|
|
|
- name: Install PNPM
|
|
|
|
run: npm install -g pnpm
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: pnpm install
|
2021-11-16 15:26:33 +00:00
|
|
|
|
2022-04-21 16:45:12 +00:00
|
|
|
- name: Install Composer dependencies
|
|
|
|
if: steps.cache-deps.outputs.cache-hit != 'true'
|
2021-11-16 15:26:33 +00:00
|
|
|
run: pnpm nx composer-install woocommerce
|
2022-03-21 19:05:45 +00:00
|
|
|
|
|
|
|
- name: Build Admin feature config
|
|
|
|
run: |
|
2022-04-06 03:27:37 +00:00
|
|
|
pnpm nx build:feature-config woocommerce
|
2021-02-09 10:39:56 +00:00
|
|
|
|
|
|
|
- name: Init DB and WP
|
2021-11-16 15:26:33 +00:00
|
|
|
run: pnpm nx install-unit-test-db woocommerce
|
2021-02-09 10:39:56 +00:00
|
|
|
|
|
|
|
- name: Run unit tests with code coverage. Allow to fail.
|
|
|
|
run: |
|
2021-11-16 15:26:33 +00:00
|
|
|
pnpm nx test-code-coverage woocommerce
|
2021-02-09 10:39:56 +00:00
|
|
|
exit 0
|
2021-03-14 01:08:46 +00:00
|
|
|
|
|
|
|
- name: Send code coverage to Codecov.
|
|
|
|
run: |
|
|
|
|
bash <(curl -s https://codecov.io/bash)
|