2021-03-23 12:31:42 +00:00
|
|
|
name: Unit tests
|
|
|
|
|
|
|
|
on:
|
2021-08-17 12:25:11 +00:00
|
|
|
push:
|
|
|
|
branches: [trunk]
|
|
|
|
pull_request:
|
2021-03-23 12:31:42 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-08-17 12:25:11 +00:00
|
|
|
Setup:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Setup
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
env:
|
|
|
|
cache-name: cache-node-modules
|
|
|
|
with:
|
|
|
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
|
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-
|
|
|
|
|
2022-03-10 10:00:23 +00:00
|
|
|
- name: Use Node.js 16.13.2
|
2021-08-17 12:25:11 +00:00
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2022-03-10 10:00:23 +00:00
|
|
|
node-version: 16.13.2
|
2021-08-17 12:25:11 +00:00
|
|
|
|
|
|
|
- name: Npm install and build
|
|
|
|
run: |
|
|
|
|
npm ci
|
|
|
|
FORCE_REDUCED_MOTION=true npm run build:e2e-test
|
|
|
|
|
|
|
|
- name: Get Composer Cache Directory
|
|
|
|
id: composer-cache
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ${{ steps.composer-cache.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-composer-
|
|
|
|
|
|
|
|
- name: Set up PHP
|
|
|
|
uses: shivammathur/setup-php@v2
|
|
|
|
with:
|
|
|
|
php-version: 7.4
|
|
|
|
coverage: none
|
|
|
|
tools: composer
|
|
|
|
|
|
|
|
- name: Composer install
|
|
|
|
run: |
|
|
|
|
composer install
|
|
|
|
|
|
|
|
PHPUnitTests:
|
|
|
|
name: PHP Unit Tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2021-08-20 13:58:32 +00:00
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
env:
|
|
|
|
cache-name: cache-node-modules
|
2021-08-17 12:25:11 +00:00
|
|
|
with:
|
2021-08-20 13:58:32 +00:00
|
|
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
2021-08-17 12:25:11 +00:00
|
|
|
restore-keys: |
|
2021-08-20 13:58:32 +00:00
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
|
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-
|
2022-03-10 10:00:23 +00:00
|
|
|
- name: Use Node.js 16.13.2
|
2021-08-20 13:58:32 +00:00
|
|
|
uses: actions/setup-node@v1
|
2021-08-17 12:25:11 +00:00
|
|
|
with:
|
2022-03-10 10:00:23 +00:00
|
|
|
node-version: 16.13.2
|
2021-08-17 12:25:11 +00:00
|
|
|
|
2021-08-20 13:58:32 +00:00
|
|
|
- name: Npm install #build is not needed
|
2021-08-17 12:25:11 +00:00
|
|
|
run: |
|
2021-08-20 13:58:32 +00:00
|
|
|
npm ci
|
2021-08-17 12:25:11 +00:00
|
|
|
- name: blocks.ini setup
|
|
|
|
run: |
|
2021-08-20 13:58:32 +00:00
|
|
|
echo 'woocommerce_blocks_phase = 3' > blocks.ini
|
|
|
|
- name: Setup Environment
|
|
|
|
run: |
|
|
|
|
chmod -R 767 ./ #TODO: Might get implemented in wp-env
|
|
|
|
npm run wp-env start
|
|
|
|
- name: Run PHPUnit tests
|
|
|
|
run: npm run test:php
|
|
|
|
- name: Run PHPUnit tests (WooCommerce Development Version)
|
2021-08-17 12:25:11 +00:00
|
|
|
run: |
|
2021-08-20 13:58:32 +00:00
|
|
|
JSON='{"plugins": [".","https://downloads.wordpress.org/plugin/woocommerce.zip"]}'
|
|
|
|
echo $JSON > .wp-env.override.json
|
|
|
|
npm run wp-env start
|
|
|
|
npm run test:php
|
2021-08-17 12:25:11 +00:00
|
|
|
|
|
|
|
JSUnitTests:
|
|
|
|
name: JS Unit Tests
|
|
|
|
needs: Setup
|
|
|
|
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v2
|
|
|
|
env:
|
|
|
|
cache-name: cache-node-modules
|
|
|
|
with:
|
|
|
|
# npm cache files are stored in `~/.npm` on Linux/macOS
|
|
|
|
path: ~/.npm
|
|
|
|
key: ${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-${{ env.cache-name }}-
|
|
|
|
${{ runner.OS }}-build-${{ secrets.CACHE_VERSION }}-
|
|
|
|
|
2022-03-10 10:00:23 +00:00
|
|
|
- name: Use Node.js 16.13.2
|
2021-08-17 12:25:11 +00:00
|
|
|
uses: actions/setup-node@v1
|
|
|
|
with:
|
2022-03-10 10:00:23 +00:00
|
|
|
node-version: 16.13.2
|
2021-08-17 12:25:11 +00:00
|
|
|
|
|
|
|
- name: Npm install and build
|
|
|
|
run: |
|
|
|
|
npm ci
|
|
|
|
FORCE_REDUCED_MOTION=true npm run build:e2e-test
|
|
|
|
|
|
|
|
- name: blocks.ini setup
|
|
|
|
run: |
|
|
|
|
echo -e 'woocommerce_blocks_phase = 3\nwoocommerce_blocks_env = tests' > blocks.ini
|
|
|
|
|
|
|
|
- name: Run JavaScript Unit tests
|
|
|
|
run: |
|
|
|
|
npm run test
|