Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package.json
package-lock.json
phpcs.xml.dist
phpunit.xml.dist
psalm.xml.dist
README.md
webpack.config.js
yarn.lock
34 changes: 32 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
{
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ]
}
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ],
"overrides": [
{
"files": [ "tests/js/**/*.js" ],
"env": {
"jest": true,
"browser": true
},
"settings": {
"jsdoc": {
"tagNamePreference": {
"jest-environment": "jest-environment"
}
}
},
"rules": {
"jsdoc/check-tag-names": [
"error",
{
"definedTags": [ "jest-environment" ]
}
]
}
},
{
"files": [ "tests/playwright/**/*.js" ],
"rules": {
"jsdoc/check-tag-names": "off"
}
}
]
}
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
/package.json export-ignore
/package-lock.json export-ignore -diff
/phpcs.xml.dist export-ignore
/psalm.xml.dist export-ignore
/README.md export-ignore
/webpack.config.js export-ignore
/yarn.lock export-ignore
172 changes: 172 additions & 0 deletions .github/workflows/tests-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: E2E Tests

on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
paths:
- '**/*.php'
- 'src/**'
- 'tests/playwright/**'
- 'tests/bin/initialize.sh'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- '.wp-env.test.json'
- '.github/workflows/tests-e2e.yml'
push:
branches:
- main
paths:
- '**/*.php'
- 'src/**'
- 'tests/playwright/**'
- 'tests/bin/initialize.sh'
- 'composer.json'
- 'composer.lock'
- 'package.json'
- 'package-lock.json'
- '.wp-env.test.json'
- '.github/workflows/tests-e2e.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
prepare:
name: Build assets and prepare Chromium
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install npm dependencies
run: npm ci

- name: Build plugin assets
run: npm run build

- name: Archive build assets
uses: actions/upload-artifact@v4
with:
name: dist-assets
path: build

- name: Cache Chromium
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('package-lock.json') }}

- name: Install Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium

# Zip artifacts strip Unix execute bits; tar preserves them for Playwright binaries.
- name: Pack Chromium cache
run: tar -C "$HOME/.cache" -czf playwright-chromium.tar.gz ms-playwright

- name: Archive Chromium
uses: actions/upload-artifact@v4
with:
name: playwright-chromium
path: playwright-chromium.tar.gz

test-e2e:
name: E2E - WP ${{ matrix.core || 'latest' }} / PHP ${{ matrix.php }}
needs: prepare
runs-on: ubuntu-22.04
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- php: '8.1'
core: 'WordPress/WordPress#6.2'
- php: '8.3'
core: null
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install npm dependencies
run: npm ci

- name: Restore build assets
uses: actions/download-artifact@v4
with:
name: dist-assets
path: build

- name: Restore Chromium
uses: actions/download-artifact@v4
with:
name: playwright-chromium
path: .

- name: Unpack Chromium cache
run: |
mkdir -p "$HOME/.cache"
tar -C "$HOME/.cache" -xzf playwright-chromium.tar.gz

- name: Install Chromium operating-system dependencies
run: npx playwright install-deps chromium

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none

- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader

- name: Launch test environment
env:
WP_ENV_PHP_VERSION: ${{ matrix.php }}
WP_ENV_CORE: ${{ matrix.core }}
run: npm run env:start-ci

- name: Run E2E tests
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
run: npm run test:e2e

- name: Sanitize Core version for artifact name
id: core-label
if: failure()
run: |
echo "core=${{ matrix.core || 'latest' }}" | tr '/\\#:*?"<>|' '-' >> "$GITHUB_OUTPUT"

- name: Archive failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-${{ steps.core-label.outputs.core }}-php-${{ matrix.php }}
path: artifacts/test-results
if-no-files-found: ignore

- name: Stop test environment
if: always()
continue-on-error: true
run: npm run env:stop-tests
50 changes: 50 additions & 0 deletions .github/workflows/tests-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow

name: JS Unit Tests

on: # yamllint disable-line rule:truthy
workflow_dispatch:
pull_request:
paths:
- 'src/**'
- 'tests/js/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/tests-js.yml'
push:
branches:
- main
paths:
- 'src/**'
- 'tests/js/**'
- 'package.json'
- 'package-lock.json'
- '.github/workflows/tests-js.yml'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
test-js:
name: Jest unit tests
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: 'npm'

- name: Install npm dependencies
run: npm ci

- name: Run JS unit tests
run: npm run test:unit:js
Loading
Loading