Skip to content

Merge pull request #868 from newfold-labs/dependabot/npm_and_yarn/dev… #371

Merge pull request #868 from newfold-labs/dependabot/npm_and_yarn/dev…

Merge pull request #868 from newfold-labs/dependabot/npm_and_yarn/dev… #371

name: E2E/Playwright Tests
on:
push:
branches:
- 'main'
- 'develop'
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}
jobs:
build:
name: Build Plugin
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
dist: ${{ steps.workflow.outputs.DIST }}
package: ${{ steps.workflow.outputs.PACKAGE }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
php-version: '8.3'
coverage: none
tools: composer, cs2pr
- name: Setup workflow context
id: workflow
working-directory: ${{ runner.temp }}
env:
REPO: ${{ github.repository }}
run: |
mkdir dist
echo "DIST=${PWD}/dist" >> "$GITHUB_OUTPUT"
echo "PACKAGE=${REPO##*/}" >> "$GITHUB_OUTPUT"
- name: Use Node.js 24.x
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 24.x
cache: 'npm'
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer vendor directory
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- name: Show versions
run: |
php --version
composer --version
node --version
npm --version
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install PHP Dependencies
run: composer install --no-progress --no-dev --optimize-autoloader --prefer-source
- name: NPM Install
run: npm install --legacy-peer-deps
- name: Build JavaScript
run: npm run build
- name: Create Distribution Copy
env:
DIST: ${{ steps.workflow.outputs.DIST }}
PACKAGE: ${{ steps.workflow.outputs.PACKAGE }}
run: rsync -r --include-from=.distinclude --exclude-from=.distignore . "$DIST/$PACKAGE"
- name: List Distribution Files
env:
DIST: ${{ steps.workflow.outputs.DIST }}
run: |
cd "$DIST"
find .
- name: Upload artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
path: ${{ steps.workflow.outputs.DIST }}
name: ${{ steps.workflow.outputs.PACKAGE }}
retention-days: 7
test:
name: Run Playwright Tests
runs-on: ubuntu-latest
timeout-minutes: 60
needs: build
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0
with:
php-version: '8.3'
coverage: none
tools: composer, cs2pr
- name: Use Node.js 24.x
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
with:
node-version: 24.x
cache: 'npm'
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer vendor directory
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
- name: Install PHP Dependencies
run: composer install --no-progress --no-dev --optimize-autoloader --prefer-source
- name: NPM Install
run: npm install --legacy-peer-deps
- name: Setup workflow context
id: workflow
working-directory: ${{ runner.temp }}
env:
REPO: ${{ github.repository }}
run: |
mkdir dist
echo "DIST=${PWD}/dist" >> "$GITHUB_OUTPUT"
- name: Download build artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
path: ${{ steps.workflow.outputs.DIST }}
name: ${{ needs.build.outputs.package }}
- name: Configure WordPress
env:
DIST: ${{ steps.workflow.outputs.DIST }}
PACKAGE: ${{ needs.build.outputs.package }}
run: |
jq -n \
--arg plugin "$DIST/$PACKAGE" \
'{plugins: [$plugin]}' > .wp-env.override.json
- name: Install WordPress
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
with:
timeout_minutes: 4
max_attempts: 3
command: npx wp-env start --debug
- name: Verify WordPress is ready
run: |
echo "Verifying WordPress is ready..."
npx wp-env run cli wp core version
echo "WordPress is ready!"
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Run Playwright Tests
run: npx playwright test --reporter=line
env:
CI: true
- name: Store Playwright test results
if: always()
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: playwright-report
path: tests/playwright/test-results/
retention-days: 10
- name: Output debug.log file contents
if: always()
continue-on-error: true
run: |
npx wp-env run wordpress cat /var/www/html/wp-content/debug.log
- name: Output wordpress docker logs
if: always()
continue-on-error: true
run: |
npx wp-env logs --watch=false --debug=true