Skip to content

Merge pull request #462 from wpengine/wpgraphql-logging-e2e-tests #425

Merge pull request #462 from wpengine/wpgraphql-logging-e2e-tests

Merge pull request #462 from wpengine/wpgraphql-logging-e2e-tests #425

Workflow file for this run

# This does the following:
# 1. Detects modified plugins that have .wp-env.json configuration
# 2. Runs Playwright E2E tests on those plugins using the custom action
# 3. Creates a matrix job for each plugin that has a quality configuration
# Bonus: This means you can have plugin specific badges e.g.
# [![E2E Te](https://img.shields.io/github/check-runs/wpengine/hwptoolkit/main?checkName=hwp-previews%20Playwright%20E2E%20Tests&label=End-to-End%20Tests)](https://github.com/wpengine/hwptoolkit/actions)
name: End-to-End Tests
on:
push:
branches:
- main
paths:
- 'plugins/*/**.php'
- 'plugins/*/**.js'
- 'plugins/*/**.css'
- 'plugins/*/**.json'
pull_request:
branches:
- main
paths:
- 'plugins/*/**.php'
- 'plugins/*/**.js'
- 'plugins/*/**.css'
- 'plugins/*/**.json'
jobs:
detect-plugin:
runs-on: ubuntu-latest
name: Detect plugin with E2E tests
outputs:
plugin: ${{ steps.detect.outputs.plugin }}
has-plugin: ${{ steps.detect.outputs.has-plugin }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed plugin directory
id: plugin
run: |
if [ "${{ github.event_name }}" = "push" ]; then
bash .github/scripts/get_plugin_slug.sh main
else
bash .github/scripts/get_plugin_slug.sh \
${{ github.event.pull_request.base.sha }} \
${{ github.event.pull_request.head.sha }}
fi
- name: Detect changed plugin with E2E config
id: detect
run: |
if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
echo "No plugin slug detected"
echo "plugin=" >> $GITHUB_OUTPUT
echo "has-plugin=false" >> $GITHUB_OUTPUT
exit 0
fi
PLUGIN="${{ steps.plugin.outputs.slug }}"
# Check for .wp-env.json file in the plugin directory
if [ -f "plugins/$PLUGIN/.wp-env.json" ]; then
echo "plugin=$PLUGIN" >> $GITHUB_OUTPUT
echo "has-plugin=true" >> $GITHUB_OUTPUT
echo "✅ Found .wp-env.json for plugin: $PLUGIN"
else
echo "plugin=" >> $GITHUB_OUTPUT
echo "has-plugin=false" >> $GITHUB_OUTPUT
echo "ℹ️ No .wp-env.json found for plugin: $PLUGIN, skipping E2E tests"
fi
playwright-e2e-tests:
needs: detect-plugin
if: needs.detect-plugin.outputs.has-plugin == 'true'
runs-on: ubuntu-24.04
name: ${{ needs.detect-plugin.outputs.plugin }} Playwright E2E Tests
env:
PLUGIN: ${{ needs.detect-plugin.outputs.plugin }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 10 # Min version required by the repo
- name: Install pnpm
run: pnpm install
- name: Setup PHP with Cached Composer
uses: ./.github/actions/setup-php-composer
with:
php-version: 8.2
working-directory: plugins/${{ env.PLUGIN }}
composer-options: '--no-progress --optimize-autoloader --no-dev'
- name: Install playwright browsers
run: pnpm dlx playwright install --with-deps
working-directory: plugins/${{ env.PLUGIN }}
- name: Start wp-env
run: |
pnpm wp-env start
working-directory: plugins/${{ env.PLUGIN }}
- name: Run Playwright tests
run: pnpm test:e2e
working-directory: plugins/${{ env.PLUGIN }}
- name: Stop wp-env
run: pnpm wp-env stop
working-directory: plugins/${{ env.PLUGIN }}