From f56e2fccc566270562c30e42811a4b3e11d1e303 Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 25 Mar 2026 12:35:45 -0600 Subject: [PATCH 1/2] fix: resolve ECONNREFUSED in WP Performance Metrics CI job The swissspidy/wp-performance-action@v2 composite action starts the WordPress Playground server in background and immediately runs Playwright tests with no readiness check. When the server takes longer than 60s to start (WordPress download + blueprint steps including multisite conversion), the Playwright globalSetup times out with ECONNREFUSED on port 9400. Fix: inline the composite action's steps in our workflow with an explicit 'Wait for WordPress Playground server' step between server start and test run. The wait step polls port 9400 with curl every 5s for up to 300s, ensuring the server is fully ready before Playwright attempts to connect. The action is pinned to SHA b7e3ffcf (v2) for reproducibility. Closes #475 --- .github/workflows/tests.yml | 116 ++++++++++++++++++++++++++++++++---- 1 file changed, 105 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 92c72cbbc..d1bebd530 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -116,16 +116,110 @@ jobs: - name: Install PHP Dependencies run: composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: lts/* + + - name: Checkout wp-performance-action + uses: actions/checkout@v4 + with: + repository: swissspidy/wp-performance-action + ref: b7e3ffcf0fc4a48b62492e021e0ebeb51430ff11 + path: .wp-performance-action + + - name: Install performance action dependencies + run: npm ci + working-directory: .wp-performance-action/env + + - name: Install Playwright browsers + run: npx playwright install --with-deps + working-directory: .wp-performance-action/env + + - name: Start WordPress Playground server + run: | + PLUGIN_REALPATH=$(realpath "$GITHUB_WORKSPACE") + PLUGIN_BASENAME=$(basename "$PLUGIN_REALPATH") + BLUEPRINT=$(realpath "$GITHUB_WORKSPACE/.github/performance-blueprint.json") + + MERGED_BLUEPRINT=./blueprints/tmp-merged.json + jq -s 'map(to_entries)|flatten|group_by(.key)|map({(.[0].key):map(.value)|add})|add' \ + ./blueprints/setup.json "$BLUEPRINT" > "$MERGED_BLUEPRINT" + + echo "Merged blueprint:" + cat "$MERGED_BLUEPRINT" | jq '.' + + ./node_modules/@wp-playground/cli/wp-playground.js server \ + --mount="./wp-content/mu-plugins:/wordpress/wp-content/mu-plugins" \ + --mount="$PLUGIN_REALPATH:/wordpress/wp-content/plugins/$PLUGIN_BASENAME" \ + --blueprint="$MERGED_BLUEPRINT" \ + --wp=6.8 \ + --php=8.2 & + working-directory: .wp-performance-action/env + + - name: Wait for WordPress Playground server on port 9400 + run: | + echo "Waiting for WordPress Playground to be ready on port 9400..." + for i in $(seq 1 60); do + if curl -sf --max-time 5 http://127.0.0.1:9400/ > /dev/null 2>&1; then + echo "Server is ready after ${i}s" + exit 0 + fi + echo " attempt $i/60..." + sleep 5 + done + echo "ERROR: Server did not become ready within 300 seconds" + exit 1 + - name: Run WP Performance Tests - uses: swissspidy/wp-performance-action@v2 + run: npm run test:performance + working-directory: .wp-performance-action/env + env: + WP_BASE_URL: http://127.0.0.1:9400 + WP_ARTIFACTS_PATH: ${{ github.workspace }}/.wp-performance-action/env/artifacts + BLOB_REPORT_PATH: ${{ github.workspace }}/.wp-performance-action/env/blob-report + SHARD: "" + URLS_TO_TEST: / + DEBUG: "true" + TEST_ITERATIONS: "20" + TEST_REPETITIONS: "2" + + - name: Stop server + if: always() + run: npm run stop-server + working-directory: .wp-performance-action/env + + - name: Print performance results + if: always() + run: | + if [ -f "$WP_ARTIFACTS_PATH/performance-results.md" ]; then + cat "$WP_ARTIFACTS_PATH/performance-results.md" >> "$GITHUB_STEP_SUMMARY" + fi + env: + WP_ARTIFACTS_PATH: ${{ github.workspace }}/.wp-performance-action/env/artifacts + + - name: Upload performance results + if: always() + uses: actions/upload-artifact@v4 + with: + name: performance-results-${{ github.run_number }} + path: .wp-performance-action/env/artifacts/ + retention-days: 30 + + - name: Check if a comment was already made + id: find-comment + if: github.event_name == 'pull_request' + uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad + with: + issue-number: ${{ github.event.pull_request.number }} + body-includes: Performance test results for + + - name: Comment on PR with performance results + if: github.event_name == 'pull_request' + uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 with: - plugins: | - ./ - blueprint: .github/performance-blueprint.json - wp-version: "6.8" - urls: | - / - create-comment: ${{ github.event_name == 'pull_request' }} - print-results: true - upload-artifacts: true - debug: true + issue-number: ${{ github.event.pull_request.number }} + comment-id: ${{ steps.find-comment.outputs.comment-id }} + edit-mode: replace + body-path: .wp-performance-action/env/artifacts/performance-results.md + token: ${{ secrets.GITHUB_TOKEN }} From 1c8ce396e2d5b8e2004a6d158fa6bca65d28b13d Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 25 Mar 2026 12:43:22 -0600 Subject: [PATCH 2/2] fix: add performance results report generation step The test run generates performance-results.json but the markdown report (performance-results.md) needed for PR comments and step summary requires a separate 'test:performance:results' npm script invocation. Add 'Generate performance results report' step that: - Copies results JSON to a temp file - Runs test:performance:results to generate the markdown report - Guards PR comment step with hashFiles() to avoid errors when no report Also fix 'Add workflow summary' step to use correct artifacts path. --- .github/workflows/tests.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d1bebd530..30b2273fd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -189,14 +189,28 @@ jobs: run: npm run stop-server working-directory: .wp-performance-action/env - - name: Print performance results + - name: Generate performance results report + id: prepare-results if: always() run: | + WP_ARTIFACTS_PATH="$GITHUB_WORKSPACE/.wp-performance-action/env/artifacts" + RESULTS_JSON="$WP_ARTIFACTS_PATH/performance-results.json" + if [ -f "$RESULTS_JSON" ]; then + UUID=$(uuidgen) + cp "$RESULTS_JSON" "$RUNNER_TEMP/performance-results-$UUID.json" + echo "results=$RUNNER_TEMP/performance-results-$UUID.json" >> "$GITHUB_OUTPUT" + REPOSITORY_URL="${{ github.server_url }}/${{ github.repository }}" \ + npm run test:performance:results "$RUNNER_TEMP/performance-results-$UUID.json" + fi + working-directory: .wp-performance-action/env + + - name: Add workflow summary + if: always() + run: | + WP_ARTIFACTS_PATH="$GITHUB_WORKSPACE/.wp-performance-action/env/artifacts" if [ -f "$WP_ARTIFACTS_PATH/performance-results.md" ]; then cat "$WP_ARTIFACTS_PATH/performance-results.md" >> "$GITHUB_STEP_SUMMARY" fi - env: - WP_ARTIFACTS_PATH: ${{ github.workspace }}/.wp-performance-action/env/artifacts - name: Upload performance results if: always() @@ -215,7 +229,7 @@ jobs: body-includes: Performance test results for - name: Comment on PR with performance results - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && hashFiles('.wp-performance-action/env/artifacts/performance-results.md') != '' uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 with: issue-number: ${{ github.event.pull_request.number }}