Skip to content

E2e testing with Playwright #38

E2e testing with Playwright

E2e testing with Playwright #38

Workflow file for this run

name: Playwright Tests
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
strategy:
fail-fast: false # Ensures the matrix doesn't stop if one job fails
matrix:
include:
# - php_version: 5.6
# wp_version: null
- php_version: 7.3
wp_version: null
# - php_version: 8.2
# wp_version: 6.4.5
# - php_version: 8.2
# wp_version: 6.5.5
- php_version: 8.2
wp_version: 6.6.2
- php_version: 8.2
wp_version: null
name: PHP ${{ matrix.php_version }} and WP ${{ matrix.wp_version || 'latest' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Set the version suffix for the output
run: echo VERSION_SUFFIX=${GITHUB_REF_NAME//\//-} >> $GITHUB_ENV
- name: Set WP Version and create .wp-env.json
run: |
WP_VERSION="${{ matrix.wp_version }}"
core='"Wordpress/Wordpress#'${{ matrix.wp_version }}'"'
if [[ -z "$WP_VERSION" || "$WP_VERSION" == "null" ]]; then
WP_VERSION="latest"
core=null
fi
echo "WP_VERSION=$WP_VERSION" >> $GITHUB_ENV
echo '{
"core": '$core',
"phpVersion": "${{ matrix.php_version }}",
"plugins": [ "." ],
"config": {
"SCRIPT_DEBUG": false
}
}' > .wp-env.json
cat .wp-env.json
- name: Build Stackable Free Plugin
run: |
npm ci --legacy-peer-deps
npm run build:no-translate
- name: Install Playwright Browsers
run: npx playwright install chromium firefox webkit --with-deps
- name: Install wp-env
run: |
npm install -g @wordpress/env
- name: Start wp-env
run: wp-env start
- name: Run playwright tests
env:
WP_BASE_URL: http://localhost:8888
WP_AUTH_STORAGE: wp-auth.json
WP_USERNAME: admin
WP_PASSWORD: password
STACKABLE_SLUG: Stackable/plugin
run: npm run test
- uses: markpatterson27/markdown-to-output@v1
id: mto
if: ${{ !cancelled() }}
with:
filepath: ./playwright-errors/errors.md
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
id: artifact-upload-step
with:
name: playwright-report-${{ env.VERSION_SUFFIX }}
path: playwright-report/
overwrite: true
retention-days: 30
- name: Find Comment
uses: peter-evans/find-comment@v3
if: ${{ !cancelled() }}
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Playwright Report Artifact for PHP ${{ matrix.php_version }} and WP ${{ env.WP_VERSION }}
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v4
if: ${{ !cancelled() }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Playwright Report Artifact for PHP ${{ matrix.php_version }} and WP ${{ env.WP_VERSION }}
| file | commit |
| ---- | ------ |
| [playwright-report-${{ env.VERSION_SUFFIX }}.zip](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/${{ steps.artifact-upload-step.outputs.artifact-id }}) | ${{ github.sha }} |
${{ steps.mto.outputs.body }}
edit-mode: replace