woocommerce/plugins/woocommerce-blocks/.github/workflows/unit-tests.yml

138 lines
4.8 KiB
YAML
Raw Normal View History

name: Unit tests
on:
push:
branches: [trunk]
pull_request:
jobs:
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 }}-
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
- name: Use Node.js 16.13.2
uses: actions/setup-node@v1
with:
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
node-version: 16.13.2
- 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
- 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 }}-
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
- name: Use Node.js 16.13.2
uses: actions/setup-node@v1
with:
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
node-version: 16.13.2
- name: Npm install #build is not needed
run: |
npm ci
- name: blocks.ini setup
run: |
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)
run: |
JSON='{"plugins": [".","https://downloads.wordpress.org/plugin/woocommerce.zip"]}'
echo $JSON > .wp-env.override.json
npm run wp-env start
npm run test:php
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 }}-
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
- name: Use Node.js 16.13.2
uses: actions/setup-node@v1
with:
Fix 404 and 500 errors in E2E test logs, editor and front-end. (https://github.com/woocommerce/woocommerce-blocks/pull/5989) * Change atomic blocks to not use custom webpack build paths we want to always load lazy loaded components from their default paths to avoid having to handle importing components in different ways for regular and atomic component packages * Add footer parts to test themes The Site Editor is expecting the footer parts to be there or it will try to load them anyways and throw a 404. It's not breaking, but it's polluting the console. * Use REST API to tear down the templates Previously, we used a util called `trashAllPosts` which navigated to the post UI and deleted all the posts to tear down any side-effects of template editing tests. However, with a [recent change](https://github.com/WordPress/wordpress-develop/commit/14e20f72b568cfb5a85f57c77eaa538c17a5f302), WP Core removed the UI for those and that made our tests meet a 500 error. Using the REST API should also make everything faster. * Remove deprecated pupeteer waitFor usage was still present in attribute-filter.test.js * Update package-lock.json * pin package versions * Unify all atomic blocks to register on php side * Remove Atomic Blcoks chunk_translation handling from AllBlocks Before it was responsible for enabling translations for all the atomic blocks * Add per atomic block chunk_translation registration * update @wordpress/e2e-test-utils to 6.0.2 * add optional puppeteer * pin workflows node version to 16.13.2 * upgrade package-lock * upgrade package-lock * set react and react-dom as peerDeps * remove atomic block registration Co-authored-by: Lucio Giannotta <lucio.giannotta@a8c.com> Co-authored-by: Luigi <gigitux@gmail.com>
2022-03-10 10:00:23 +00:00
node-version: 16.13.2
- 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