163 lines
4.3 KiB
YAML
163 lines
4.3 KiB
YAML
name: WordPress Playground Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, feature/*, bugfix/* ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
concurrency:
|
|
group: playground-tests-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
code-quality:
|
|
name: Code Quality Check
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [18.18, 20]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Verify package.json and package-lock.json
|
|
run: |
|
|
echo "Verifying package.json and package-lock.json are in sync"
|
|
npm ci --dry-run
|
|
|
|
- name: Lint JavaScript files
|
|
run: |
|
|
echo "Linting JavaScript files"
|
|
# Add your linting command here when you have one
|
|
# For example: npm run lint
|
|
|
|
playground-single-test:
|
|
name: WordPress Playground Single Site Tests
|
|
runs-on: ubuntu-latest
|
|
needs: code-quality
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Add WordPress Playground CLI to dependencies
|
|
run: npm install --save-dev @wp-playground/cli
|
|
|
|
- name: Create plugin zip
|
|
run: |
|
|
mkdir -p dist
|
|
zip -r dist/plugin.zip . \
|
|
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**"
|
|
|
|
- name: Run tests with WordPress Playground
|
|
run: |
|
|
# Set base URL for Cypress
|
|
export CYPRESS_BASE_URL=http://localhost:8888
|
|
|
|
# Start WordPress Playground with our blueprint
|
|
npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login &
|
|
|
|
# Wait for WordPress Playground to be ready
|
|
echo "Waiting for WordPress Playground to be ready..."
|
|
timeout 60 bash -c 'until curl -s http://localhost:8888; do sleep 2; done'
|
|
|
|
# Run Cypress tests against WordPress Playground
|
|
npx cypress run --spec "cypress/e2e/playground-single-site.cy.js"
|
|
|
|
- name: Upload Cypress artifacts
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cypress-single-site-results
|
|
path: |
|
|
cypress/videos
|
|
cypress/screenshots
|
|
|
|
playground-multisite-test:
|
|
name: WordPress Playground Multisite Tests
|
|
runs-on: ubuntu-latest
|
|
needs: [code-quality, playground-single-test]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Add WordPress Playground CLI to dependencies
|
|
run: npm install --save-dev @wp-playground/cli
|
|
|
|
- name: Create plugin zip
|
|
run: |
|
|
mkdir -p dist
|
|
zip -r dist/plugin.zip . \
|
|
-x "node_modules/**" "dist/**" ".git/**" ".github/**" ".wiki/**"
|
|
|
|
- name: Run tests with WordPress Playground
|
|
run: |
|
|
# Set base URL for Cypress
|
|
export CYPRESS_BASE_URL=http://localhost:80
|
|
|
|
# Start WordPress Playground with our blueprint
|
|
# Use port 80 for multisite as WordPress multisites don't support custom ports
|
|
npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 80 --login &
|
|
|
|
# Wait for WordPress Playground to be ready
|
|
echo "Waiting for WordPress Playground to be ready..."
|
|
timeout 60 bash -c 'until curl -s http://localhost:80; do sleep 2; done'
|
|
|
|
# Run Cypress tests against WordPress Playground
|
|
npx cypress run --spec "cypress/e2e/playground-multisite.cy.js"
|
|
|
|
- name: Upload Cypress artifacts
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cypress-multisite-results
|
|
path: |
|
|
cypress/videos
|
|
cypress/screenshots
|
|
|
|
performance-test:
|
|
name: WordPress Performance Tests
|
|
runs-on: ubuntu-latest
|
|
needs: code-quality
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: WordPress Performance Tests
|
|
uses: swissspidy/wp-performance-action@v2.0.3
|
|
with:
|
|
plugins: |
|
|
./
|
|
urls: |
|
|
/
|
|
/wp-admin/
|
|
php-version: '8.0'
|
|
wp-version: 'latest'
|