name: WordPress Playground Tests on: push: branches: [ main, feature/* ] pull_request: branches: [ main ] workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node.js uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2 with: node-version: ${{ matrix.node-version }} cache: 'npm' - name: Install dependencies run: npm ci --legacy-peer-deps - 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: npm run lint:js playground-single-test: name: WordPress Playground Single Site Tests runs-on: ubuntu-latest needs: code-quality steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node.js uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci --legacy-peer-deps - name: Add WordPress Playground CLI to dependencies run: | echo "Installing WordPress Playground CLI..." npm install --save-dev @wp-playground/cli @wp-playground/blueprints @wp-playground/client echo "WordPress Playground CLI installed" npx @wp-playground/cli --version - name: Create plugin zip uses: ./.github/actions/create-plugin-zip - name: Run tests with WordPress Playground run: | # Set base URL for Cypress export CYPRESS_BASE_URL=http://localhost:8888 # Check if blueprint file exists echo "Checking blueprint file..." ls -la playground/ cat playground/blueprint.json # Start WordPress Playground with our blueprint echo "Starting WordPress Playground server..." npx @wp-playground/cli server --blueprint playground/blueprint.json --port 8888 --login & SERVER_PID=$! # 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' echo "WordPress Playground is ready" # Run Cypress tests against WordPress Playground echo "Running Cypress tests..." npx cypress run --spec "cypress/e2e/playground-single-site.cy.js" TEST_EXIT_CODE=$? # Kill the server process kill $SERVER_PID || true # Return the test exit code exit $TEST_EXIT_CODE - 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node.js uses: actions/setup-node@60edb5dd545a775178f52524a9de5299b6d2bbed # v4.0.2 with: node-version: '20' cache: 'npm' - name: Install dependencies run: npm ci --legacy-peer-deps - name: Add WordPress Playground CLI to dependencies run: | echo "Installing WordPress Playground CLI..." npm install --save-dev @wp-playground/cli @wp-playground/blueprints @wp-playground/client echo "WordPress Playground CLI installed" npx @wp-playground/cli --version - name: Create plugin zip uses: ./.github/actions/create-plugin-zip - name: Run tests with WordPress Playground run: | # Set base URL for Cypress export CYPRESS_BASE_URL=http://localhost:8889 # Check if blueprint file exists echo "Checking multisite blueprint file..." ls -la playground/ cat playground/multisite-blueprint.json # Start WordPress Playground with our blueprint # Use a different port for multisite to avoid conflicts with single site tests echo "Starting WordPress Playground server for multisite..." npx @wp-playground/cli server --blueprint playground/multisite-blueprint.json --port 8889 --login & SERVER_PID=$! # Wait for WordPress Playground to be ready echo "Waiting for WordPress Playground to be ready..." timeout 60 bash -c 'until curl -s http://localhost:8889; do sleep 2; done' echo "WordPress Playground is ready" # Run Cypress tests against WordPress Playground echo "Running Cypress multisite tests..." npx cypress run --spec "cypress/e2e/playground-multisite.cy.js" TEST_EXIT_CODE=$? # Kill the server process kill $SERVER_PID || true # Return the test exit code exit $TEST_EXIT_CODE - 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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: WordPress Performance Tests uses: swissspidy/wp-performance-action@b7e3ffcf0fc4a48b62492e021e0ebeb51430ff11 # v2.0.3 with: plugins: | ./ urls: | / /wp-admin/ php-version: '8.0' wp-version: '6.4'