Skip to content

Setup and Write E2E tests #1

Setup and Write E2E tests

Setup and Write E2E tests #1

Workflow file for this run

name: E2E Tests
on:
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop
jobs:
build:
name: NPM Install
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use desired version of NodeJS
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Cache Node
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache
~/.npm
key: ${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm install
cypress:
name: ${{ matrix.core.name }} / ${{ matrix.php.name }}
needs: [build]
## Pending upgrade of `@wordpress/env` package.
continue-on-error: ${{ matrix.core.version == 'WordPress/WordPress#master' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- {name: 'PHP Default', version: null}
core:
- {name: 'WP stable', version: 'latest'}
- {name: 'WP 6.3', version: 'WordPress/WordPress#6.3'}
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}
include:
- php: {name: 'PHP 7.4', version: '7.4'}
core: {name: 'WP 6.3', version: 'WordPress/WordPress#6.3'}
- php: {name: 'PHP 8.1', version: '8.1'}
core: {name: 'WP stable', version: 'latest'}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use desired version of NodeJS
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Check versions
run: npm -v; node -v
- name: Cache Node
uses: actions/cache@v3
with:
path: |
node_modules
~/.cache
~/.npm
key: ${{ hashFiles('package-lock.json') }}
- name: Install dependencies
run: npm install
- name: Composer install
run: composer install
- name: Build
run: npm run build
- name: Set the core version
run: |
./tests/bin/set-core-version.js ${{ matrix.core.version }} ${{ matrix.php.version }}
- name: Set up WP environment
run: npm run env:start
- name: Log WP environment versions
run: |
npx wp-env run cli "wp core version"
npx wp-env run cli "php --version"
- name: Test
run: npm run cypress:run
- name: Update summary
if: always()
run: |
npx mochawesome-merge ./tests/cypress/reports/*.json -o tests/cypress/reports/mochawesome.json
rm -rf ./tests/cypress/reports/mochawesome-*.json
npx mochawesome-json-to-md -p ./tests/cypress/reports/mochawesome.json -o ./tests/cypress/reports/mochawesome.md
npx mochawesome-report-generator tests/cypress/reports/mochawesome.json -o tests/cypress/reports/
cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY
- name: Make artifacts available
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
${{ github.workspace }}/tests/cypress/reports/