chore: automated tests #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Playwright | |
on: | |
pull_request: | |
types: [labeled, synchronize, opened, reopened] | |
push: | |
branches: | |
- 'core' | |
paths-ignore: | |
- '**.md' | |
- '**.txt' | |
- '.gitignore' | |
- 'docs/**' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
actions: read | |
concurrency: | |
group: playwright-${{ github.event_name }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }} | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
jobs: | |
build-plugin: | |
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests') | |
name: Build plugin | |
uses: ./.github/workflows/build.yml | |
Playwright: | |
name: Playwright test on PHP 8.1 | |
runs-on: ubuntu-22.04 | |
needs: [build-plugin] | |
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'run-tests') | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: | | |
npm run prepare-environment:ci | |
cd src && composer install | |
- name: Download build artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.build-plugin.outputs.artifact_name }} | |
path: ./build | |
- name: Start WordPress environment | |
run: | | |
npm run wp-env:start | |
- name: Setup test data | |
run: npm run test:setup:playwright | |
- name: WordPress debug information | |
run: | | |
wp-env run cli wp core version | |
wp-env run cli wp --info | |
- name: Install playwright/test | |
run: | | |
npx playwright install chromium | |
- name: Run Playwright tests | |
run: npm run test:playwright | |
- name: Stop WordPress environment | |
if: always() | |
run: npm run wp-env:stop | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-test-results | |
path: test-results/ | |
if-no-files-found: ignore | |
retention-days: 2 | |
test-result: | |
needs: [Playwright] | |
if: always() && (needs.Playwright.result != 'skipped') | |
runs-on: ubuntu-22.04 | |
name: Playwright - Test Results | |
steps: | |
- name: Test status | |
run: echo "Test status is - ${{ needs.Playwright.result }}" | |
- name: Check Playwright status | |
if: ${{ needs.Playwright.result != 'success' && needs.Playwright.result != 'skipped' }} | |
run: exit 1 |