Skip to content

E2E Test

E2E Test #32

Workflow file for this run

name: E2E Test
env:
COMPOSER_VERSION: "2"
COMPOSER_CACHE: "${{ github.workspace }}/.composer-cache"
NODE_VERSION: "20"
NODE_CACHE: "${{ github.workspace }}/node_modules_cache"
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- develop
- trunk
pull_request:
branches:
- develop
- '[0-9].[0-9x]*' # Version branches: 4.x.x, 4.1.x, 5.x
jobs:
cypress_local:
name: ES ${{ matrix.esVersion }} - ${{ matrix.core.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
esVersion: ['7.10.1', '8.12.2']
core:
- {name: 'WP latest', version: ''}
- {name: 'WP minimum', version: '6.0'}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare npm cache
uses: actions/cache@v4
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-
- name: Prepare composer cache
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: :php-psr
tools: cs2pr
coverage: none
- name: composer install
run: composer install
- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci --include=dev
- name: Set up WP environment with Elasticsearch
run: ES_VERSION=${{ matrix.esVersion }} npm run env:start
- name: Check ES response
run: curl --connect-timeout 5 --max-time 10 --retry 5 --retry-max-time 40 --retry-all-errors http://localhost:8890
- name: Build asset
run: npm run build
- name: Set up database
run: npm run cypress:setup -- --wp-version=${{ matrix.core.version }}
- name: Test
run: npm run cypress:run
- name: Make artifacts available
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact-${{ matrix.esVersion }}-${{ matrix.core.name }}
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
- name: Stop Elasticsearch
if: always()
run: npm run es:stop
cypress_epio:
name: EP.io - ${{ matrix.core.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
core:
- {name: 'WP latest', version: ''}
- {name: 'WP minimum', version: '6.0'}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Prepare npm cache
uses: actions/cache@v4
with:
path: ${{ env.NODE_CACHE }}
key: npm-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.NODE_VERSION }}-
- name: Prepare composer cache
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE }}
key: composer-${{ env.COMPOSER_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
composer-${{ env.COMPOSER_VERSION }}-
- name: Set PHP version
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: :php-psr
tools: cs2pr
coverage: none
- name: composer install
run: composer install
- name: "Install node v${{ env.NODE_VERSION }}"
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm ci --include=dev
- name: Set up WP environment
run: |
npm run env start
npm run env:install-tests-cli
- name: Build asset
run: npm run build
- name: Set up database
env:
EPIO_HOST: ${{ vars.EPIO_HOST }}
EPIO_INDEX_PREFIX: ${{ vars.EPIO_INDEX_PREFIX }}
run: npm run cypress:setup -- --ep-host="$EPIO_HOST" --es-shield='${{ secrets.EP_CREDENTIALS }}' --ep-index-prefix="$EPIO_INDEX_PREFIX" --wp-version=${{ matrix.core.version }}
- name: Test
run: npm run cypress:run
- name: Make artifacts available
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact-epio-${{ matrix.core.name }}
retention-days: 2
path: |
${{ github.workspace }}/tests/cypress/screenshots/
${{ github.workspace }}/tests/cypress/videos/
${{ github.workspace }}/tests/cypress/logs/
- name: Delete Elasticsearch indices
if: always()
run: |
./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate elasticpress elasticpress-labs"
./bin/wp-env-cli tests-wordpress "wp --allow-root elasticpress-tests delete-all-indices"