From 5e132e815df22e972a97466a1bbe762cae28fe67 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Mon, 16 Mar 2026 16:38:35 +0530 Subject: [PATCH 01/38] ci(github): add container support for self-hosted runners Switch all workflows to use containers on self-hosted runners for improved consistency and isolation. Add system dependency installation steps and configure Docker and Git safe directory where needed. Update job dependencies and permissions for better security and workflow reliability. This enables better compatibility with shared self-hosted environments. chore(ci): use public-repo runner in all workflows Replace the custom self-hosted runner labels with [public-repo] in all GitHub Actions workflow files. This change standardizes the runner environment and improves compatibility for public repositories. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> fix the core volume mount problem Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> fix(ci): update wp-env test config and add --update flag - Remove "plugins" field from .wp-env.test.json to prevent broken mounts - Add dynamic host mapping for plugin in test config - Add --update flag to npm run wp-env:test start commands for fresh env Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> ci: improve Docker mapping and plugin activation Update workflows to fix wp-env host mapping, add plugin activation steps, and ensure Docker environments are properly started and stopped. Switch PHPUnit commands to use tests-cli for accurate environment handling. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 24 ++++-- .github/workflows/reusable-build.yml | 59 +++++++++++++- .github/workflows/reusable-e2e.yml | 66 ++++++++++++++-- .github/workflows/reusable-jest.yml | 11 ++- .github/workflows/reusable-lint-css-js.yml | 11 ++- .github/workflows/reusable-phpcs.yml | 16 +++- .github/workflows/reusable-phpstan.yml | 16 +++- .github/workflows/reusable-phpunit.yml | 77 ++++++++++++++++--- .../reusable-wp-playground-pr-preview.yml | 15 +++- .wp-env.test.json | 5 +- package.json | 2 +- 11 files changed, 259 insertions(+), 43 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 145dfb2..17edbc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,15 @@ concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} cancel-in-progress: true -permissions: {} +permissions: + contents: read jobs: detect: name: Detect Changes - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: contents: read @@ -36,10 +39,16 @@ jobs: jest: ${{ steps.filter.outputs.jest }} steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - with: - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Detect file changes uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 @@ -138,6 +147,7 @@ jobs: contents: read strategy: fail-fast: false + max-parallel: 1 matrix: php: ['8.4', '8.3', '8.2'] wp: ['latest'] @@ -153,8 +163,8 @@ jobs: e2e: name: E2E Tests - needs: detect - if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' + needs: [detect, phpunit] + if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') uses: ./.github/workflows/reusable-e2e.yml permissions: contents: read @@ -163,6 +173,8 @@ jobs: build-plugin-zip: name: Build Plugin Zip + needs: [e2e] + if: needs.e2e.result == 'success' || needs.e2e.result == 'skipped' permissions: contents: read uses: ./.github/workflows/reusable-build.yml diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 66658f5..b7ef17b 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -12,15 +12,43 @@ on: jobs: build: - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 + options: --user root -v /var/run/docker.sock:/var/run/docker.sock permissions: contents: read steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git curl sudo unzip jq + + - name: setup Docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + - name: Configure Docker group permissions + run: | + useradd -m wpuser + SOCK_GID=$(stat -c '%g' /var/run/docker.sock) + groupmod -g $SOCK_GID -o docker + usermod -aG docker wpuser + + - name: Configure environment variables + run: | + # Unique variables for wp-env to prevent conflicts on shared self-hosted runners + UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') + echo "COMPOSE_PROJECT_NAME=wpenv_reusable_build_${UNIQUE_ID}" >> "$GITHUB_ENV" + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 @@ -45,15 +73,34 @@ jobs: - name: Build plugin for release run: npm run build:prod + - name: Fix wp-env host mapping + run: | + # Get the host path for the workspace by inspecting the container's own mounts + HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}') + + # Construct the full host path for the current plugin directory + RELATIVE_PATH=$(pwd | sed 's|^/__w||') + PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}" + + echo "Host Workspace: $HOST_WORKSPACE_PATH" + echo "Plugin Host Path: $PLUGIN_HOST_PATH" + + # Update .wp-env.json (default env) + jq --arg path "$PLUGIN_HOST_PATH" \ + 'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \ + .wp-env.json > .wp-env.json.tmp && mv .wp-env.json.tmp .wp-env.json + + cat .wp-env.json + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: timeout_minutes: 10 max_attempts: 3 - command: npm run wp-env start + command: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env start -- --update - name: Generate Translation files - run: npm run i18n:make-pot + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -64,3 +111,7 @@ jobs: name: ${{ inputs.artifact-name }} path: plugin-skeleton-d.zip if-no-files-found: error + + - name: Stop the Docker testing environment + if: always() + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env destroy diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index e5dce7d..4358abb 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -8,20 +8,49 @@ on: required: true type: string -permissions: {} +permissions: + contents: read jobs: e2e: name: Playwright E2E Tests - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 + options: --user root -v /var/run/docker.sock:/var/run/docker.sock timeout-minutes: 20 steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git curl sudo unzip jq + + - name: setup Docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + - name: Configure Docker group permissions + run: | + useradd -m wpuser + SOCK_GID=$(stat -c '%g' /var/run/docker.sock) + groupmod -g $SOCK_GID -o docker + usermod -aG docker wpuser + + - name: Configure environment variables + run: | + # Unique variables for wp-env to prevent conflicts on shared self-hosted runners + UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') + echo "COMPOSE_PROJECT_NAME=wpenv_${UNIQUE_ID}" >> "$GITHUB_ENV" + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 @@ -44,15 +73,38 @@ jobs: - name: Build development assets run: npm run build:dev + - name: Fix wp-env host mapping + run: | + # Get the host path for the workspace by inspecting the container's own mounts + HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}') + + # Construct the full host path for the current plugin directory + RELATIVE_PATH=$(pwd | sed 's|^/__w||') + PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}" + + echo "Host Workspace: $HOST_WORKSPACE_PATH" + echo "Plugin Host Path: $PLUGIN_HOST_PATH" + + # Update .wp-env.test.json + jq --arg path "$PLUGIN_HOST_PATH" \ + 'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \ + .wp-env.test.json > .wp-env.test.json.tmp && mv .wp-env.test.json.tmp .wp-env.test.json + + cat .wp-env.test.json + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: timeout_minutes: 10 max_attempts: 3 - command: WP_ENV_PORT=8889 WP_ENV_TESTS_PORT=8891 npm run wp-env:test start + command: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" "WP_ENV_PORT=8889" "WP_ENV_TESTS_PORT=8891" npm run wp-env:test start -- --update + + - name: Activate plugin + run: | + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Run E2E tests - run: npm run test:e2e + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -62,3 +114,7 @@ jobs: path: tests/_output retention-days: 2 if-no-files-found: ignore + + - name: Stop the Docker testing environment + if: always() + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test destroy diff --git a/.github/workflows/reusable-jest.yml b/.github/workflows/reusable-jest.yml index 719dc08..e514a9c 100644 --- a/.github/workflows/reusable-jest.yml +++ b/.github/workflows/reusable-jest.yml @@ -9,12 +9,15 @@ on: type: boolean default: true -permissions: {} +permissions: + contents: read jobs: jest: name: Jest Unit Tests${{ inputs.coverage && ' with coverage' || '' }} - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: node:22 timeout-minutes: 10 steps: @@ -22,7 +25,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Setup Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 diff --git a/.github/workflows/reusable-lint-css-js.yml b/.github/workflows/reusable-lint-css-js.yml index c855250..c64166b 100644 --- a/.github/workflows/reusable-lint-css-js.yml +++ b/.github/workflows/reusable-lint-css-js.yml @@ -3,12 +3,15 @@ name: Run JS Lint on: workflow_call: -permissions: {} +permissions: + contents: read jobs: lint-js: name: JS Lint & TypeScript - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: node:22 timeout-minutes: 20 steps: @@ -16,7 +19,9 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Setup Node.js uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 diff --git a/.github/workflows/reusable-phpcs.yml b/.github/workflows/reusable-phpcs.yml index d2a6bc5..2b7b0c1 100644 --- a/.github/workflows/reusable-phpcs.yml +++ b/.github/workflows/reusable-phpcs.yml @@ -8,20 +8,30 @@ on: required: true type: string -permissions: {} +permissions: + contents: read jobs: phpcs: name: PHPCS Coding Standards - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 timeout-minutes: 20 steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git curl sudo unzip + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 diff --git a/.github/workflows/reusable-phpstan.yml b/.github/workflows/reusable-phpstan.yml index 6701091..9e81f3a 100644 --- a/.github/workflows/reusable-phpstan.yml +++ b/.github/workflows/reusable-phpstan.yml @@ -8,20 +8,30 @@ on: required: true type: string -permissions: {} +permissions: + contents: read jobs: phpstan: name: PHPStan Static Analysis - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 timeout-minutes: 20 steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git curl sudo unzip + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 2a990ba..133ff00 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -23,18 +23,39 @@ on: type: boolean default: false -permissions: {} +permissions: + contents: read jobs: phpunit: name: PHPUnit (PHP ${{ inputs.php-version }}, WP ${{ inputs.wp-version }})${{ inputs.coverage && ' with coverage' || '' }}${{ inputs.multisite && ' multisite' || '' }} - runs-on: ubuntu-24.04 - timeout-minutes: 20 + runs-on: [public-repo] + container: + image: ubuntu:24.04 + options: --user root -v /var/run/docker.sock:/var/run/docker.sock + # timeout-minutes: 20 env: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} steps: + - name: Install system dependencies + run: | + apt update + apt-get install -y git curl sudo unzip jq + + - name: setup Docker + run: | + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + - name: Configure Docker group permissions + run: | + useradd -m wpuser -s /bin/bash + SOCK_GID=$(stat -c '%g' /var/run/docker.sock) + groupmod -g $SOCK_GID -o docker + usermod -aG docker wpuser + - name: Configure environment variables run: | echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" @@ -44,7 +65,15 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} - persist-credentials: false + + - name: Configure Git for Safe Directory + run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" + + - name: Configure environment variables + run: | + # Unique variables for wp-env to prevent conflicts on shared self-hosted runners + UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') + echo "COMPOSE_PROJECT_NAME=wpenv_${UNIQUE_ID}" >> "$GITHUB_ENV" - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 @@ -67,6 +96,27 @@ jobs: - name: Build development assets run: npm run build:dev + - name: Fix wp-env host mapping + run: | + # Get the host path for the workspace by inspecting the container's own mounts + HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}') + + # Construct the full host path for the current plugin directory + # We strip the internal /__w prefix and append it to the host workspace path + RELATIVE_PATH=$(pwd | sed 's|^/__w||') + PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}" + + echo "Host Workspace: $HOST_WORKSPACE_PATH" + echo "Plugin Host Path: $PLUGIN_HOST_PATH" + + # 1. Remove the "plugins" field to prevent broken automatic mounts + # 2. Add the host mapping + jq --arg path "$PLUGIN_HOST_PATH" \ + 'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \ + .wp-env.test.json > .wp-env.test.json.tmp && mv .wp-env.test.json.tmp .wp-env.test.json + + cat .wp-env.test.json + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: @@ -74,18 +124,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - npm run wp-env:test start -- --xdebug=coverage + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test start -- --xdebug=coverage --update --debug else - npm run wp-env:test start + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test start -- --update fi + - name: Activate plugin + run: | + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + - name: Log versions run: | - npm run wp-env:test -- run cli php -- -v - npm run wp-env:test -- run cli wp core version + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test -- run tests-cli php -- -v + sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -103,3 +158,7 @@ jobs: name: wp-code-coverage-${{ inputs.php-version }}-${{ inputs.wp-version }} path: tests/_output/html overwrite: true + + - name: Stop the Docker testing environment + if: always() + run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test destroy diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index e25a1b1..270166b 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -23,18 +23,29 @@ on: type: string default: '2' -permissions: {} +permissions: + contents: read jobs: playground-preview: name: Post Playground Preview - runs-on: ubuntu-24.04 + runs-on: [public-repo] + container: + image: ubuntu:24.04 permissions: actions: read contents: write pull-requests: write steps: + - name: Install system dependencies + run: | + apt-get update + apt-get install -y git curl + + # - name: Configure Git for Safe Directory + # run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" + - name: Extract PR metadata and artifact info id: pr-metadata uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/.wp-env.test.json b/.wp-env.test.json index b8f64fd..b5cf45d 100644 --- a/.wp-env.test.json +++ b/.wp-env.test.json @@ -2,14 +2,11 @@ "$schema": "https://schemas.wp.org/trunk/wp-env.json", "core": null, "port": 8889, - "testsEnvironment": false, + "testsEnvironment": true, "plugins": [ "." ], "config": { "FS_METHOD": "direct", "WP_DEBUG": true, "WP_DEBUG_LOG": "/var/www/html/wp-content/plugins/plugin-skeleton-d/tests/_output/debug-test.log" - }, - "mappings": { - "wp-content/plugins/plugin-skeleton-d": "." } } diff --git a/package.json b/package.json index 65e3422..6411f1b 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "test:js": "wp-scripts test-unit-js", "test:js:watch": "wp-scripts test-unit-js --watch", "test:js:coverage": "wp-scripts test-unit-js --coverage", - "test:php": "npm run wp-env:test -- run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ vendor/bin/phpunit -c phpunit.xml.dist", + "test:php": "npm run wp-env:test -- run tests-cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ vendor/bin/phpunit -c phpunit.xml.dist", "wp-env": "wp-env", "wp-env:cli": "wp-env run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/", "wp-env:test": "wp-env --config=.wp-env.test.json" From 9f2654401bdc2111aacdddfefae13ca16f3d79af Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Mon, 16 Mar 2026 17:08:36 +0530 Subject: [PATCH 02/38] ci: unify env vars and ports for self-hosted runners Refactor GitHub Actions workflows to standardize environment variable usage and port assignments for wp-env across build, E2E, and PHPUnit jobs. Removes dynamic COMPOSE_PROJECT_NAME generation and sets static WP_ENV_PORT and WP_ENV_TESTS_PORT values to avoid conflicts on shared self-hosted runners. Updates .wp-env.test.json to include testsPort. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 25 ++++++++++++------------ .github/workflows/reusable-e2e.yml | 27 +++++++++++++------------- .github/workflows/reusable-phpunit.yml | 26 +++++++++++-------------- .wp-env.test.json | 1 + 4 files changed, 37 insertions(+), 42 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index b7ef17b..ec721bb 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -18,6 +18,11 @@ jobs: options: --user root -v /var/run/docker.sock:/var/run/docker.sock permissions: contents: read + + env: + WP_ENV_PORT: 8889 + WP_ENV_TESTS_PORT: 8891 + steps: - name: Install system dependencies run: | @@ -36,12 +41,6 @@ jobs: groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser - - name: Configure environment variables - run: | - # Unique variables for wp-env to prevent conflicts on shared self-hosted runners - UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') - echo "COMPOSE_PROJECT_NAME=wpenv_reusable_build_${UNIQUE_ID}" >> "$GITHUB_ENV" - - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -77,19 +76,19 @@ jobs: run: | # Get the host path for the workspace by inspecting the container's own mounts HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}') - + # Construct the full host path for the current plugin directory RELATIVE_PATH=$(pwd | sed 's|^/__w||') PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}" - + echo "Host Workspace: $HOST_WORKSPACE_PATH" echo "Plugin Host Path: $PLUGIN_HOST_PATH" - + # Update .wp-env.json (default env) jq --arg path "$PLUGIN_HOST_PATH" \ 'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \ .wp-env.json > .wp-env.json.tmp && mv .wp-env.json.tmp .wp-env.json - + cat .wp-env.json - name: Start the Docker testing environment @@ -97,10 +96,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update - name: Generate Translation files - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run i18n:make-pot + run: sudo -u wpuser env "PATH=$PATH" npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -114,4 +113,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 4358abb..06a7bf8 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -18,8 +18,13 @@ jobs: container: image: ubuntu:24.04 options: --user root -v /var/run/docker.sock:/var/run/docker.sock + timeout-minutes: 20 + env: + WP_ENV_PORT: 8889 + WP_ENV_TESTS_PORT: 8891 + steps: - name: Install system dependencies run: | @@ -38,12 +43,6 @@ jobs: groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser - - name: Configure environment variables - run: | - # Unique variables for wp-env to prevent conflicts on shared self-hosted runners - UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') - echo "COMPOSE_PROJECT_NAME=wpenv_${UNIQUE_ID}" >> "$GITHUB_ENV" - - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -77,19 +76,19 @@ jobs: run: | # Get the host path for the workspace by inspecting the container's own mounts HOST_WORKSPACE_PATH=$(docker inspect $(hostname) --format '{{ range .Mounts }}{{ if eq .Destination "/__w" }}{{ .Source }}{{ end }}{{ end }}') - + # Construct the full host path for the current plugin directory RELATIVE_PATH=$(pwd | sed 's|^/__w||') PLUGIN_HOST_PATH="${HOST_WORKSPACE_PATH}${RELATIVE_PATH}" - + echo "Host Workspace: $HOST_WORKSPACE_PATH" echo "Plugin Host Path: $PLUGIN_HOST_PATH" - + # Update .wp-env.test.json jq --arg path "$PLUGIN_HOST_PATH" \ 'del(.plugins) | .mappings["wp-content/plugins/plugin-skeleton-d"] = $path' \ .wp-env.test.json > .wp-env.test.json.tmp && mv .wp-env.test.json.tmp .wp-env.test.json - + cat .wp-env.test.json - name: Start the Docker testing environment @@ -97,14 +96,14 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" "WP_ENV_PORT=8889" "WP_ENV_TESTS_PORT=8891" npm run wp-env:test start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run test:e2e + run: sudo -u wpuser env "PATH=$PATH" npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -117,4 +116,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 133ff00..b18e615 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -33,10 +33,12 @@ jobs: container: image: ubuntu:24.04 options: --user root -v /var/run/docker.sock:/var/run/docker.sock - # timeout-minutes: 20 + timeout-minutes: 20 env: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} + WP_ENV_PORT: 8889 + WP_ENV_TESTS_PORT: 8891 steps: - name: Install system dependencies @@ -69,12 +71,6 @@ jobs: - name: Configure Git for Safe Directory run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - - name: Configure environment variables - run: | - # Unique variables for wp-env to prevent conflicts on shared self-hosted runners - UNIQUE_ID=$(cat /proc/sys/kernel/random/uuid | sed 's/-//g') - echo "COMPOSE_PROJECT_NAME=wpenv_${UNIQUE_ID}" >> "$GITHUB_ENV" - - name: Set up PHP uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 with: @@ -124,23 +120,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test start -- --update + sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test -- run tests-cli php -- -v - sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test -- run tests-cli wp core version + sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli php -- -v + sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -u wpuser env "PATH=$PATH" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -161,4 +157,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" npm run wp-env:test destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy diff --git a/.wp-env.test.json b/.wp-env.test.json index b5cf45d..6297e6e 100644 --- a/.wp-env.test.json +++ b/.wp-env.test.json @@ -2,6 +2,7 @@ "$schema": "https://schemas.wp.org/trunk/wp-env.json", "core": null, "port": 8889, + "testsPort": 8891, "testsEnvironment": true, "plugins": [ "." ], "config": { From a3c68ff9718ff4b016ce309c8831a9255e1158d0 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:10:16 +0530 Subject: [PATCH 03/38] fix(ci): add --yes flag to wp-env destroy commands Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 2 +- .github/workflows/reusable-e2e.yml | 2 +- .github/workflows/reusable-phpunit.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index ec721bb..056f183 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -113,4 +113,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy --yes diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 06a7bf8..17f30d1 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -116,4 +116,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy --yes diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index b18e615..64fcb6d 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -157,4 +157,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy --yes From a8a7ab83674549e4d75c1d55bcda1ae9812083f6 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:34:40 +0530 Subject: [PATCH 04/38] fixed the --yes of wp-env destroy with --force Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 2 +- .github/workflows/reusable-e2e.yml | 2 +- .github/workflows/reusable-phpunit.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 056f183..d82152a 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -113,4 +113,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy --yes + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 17f30d1..0d6c107 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -116,4 +116,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy --yes + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 64fcb6d..741c566 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -157,4 +157,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy --yes + run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy -- --force From 872e914771ac06342c45b1a818808f834dbc1820 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 11:45:01 +0530 Subject: [PATCH 05/38] added a pause for indepth analysis Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-phpunit.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 741c566..f7626bf 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -33,7 +33,7 @@ jobs: container: image: ubuntu:24.04 options: --user root -v /var/run/docker.sock:/var/run/docker.sock - timeout-minutes: 20 + # timeout-minutes: 20 env: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} @@ -135,6 +135,13 @@ jobs: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli php -- -v sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli wp core version + - name: Pause before PhpUnit test (dbg mode) + run: | + while [ ! -f /tmp/resume ]; do + echo "Waiting for wp-env to be ready..." + sleep 60 + done + - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} run: sudo -u wpuser env "PATH=$PATH" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} From c5c2ca6eb2747b7fddcc0b286ce3222e2536bfe1 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 13:32:37 +0530 Subject: [PATCH 06/38] disabled spcific section to be able to check the workflow Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17edbc4..5987f20 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,14 +29,22 @@ jobs: contents: read pull-requests: read outputs: - php: ${{ steps.filter.outputs.php }} - phpcs: ${{ steps.filter.outputs.phpcs }} - phpstan: ${{ steps.filter.outputs.phpstan }} - phpunit: ${{ steps.filter.outputs.phpunit }} - js: ${{ steps.filter.outputs.js }} - css: ${{ steps.filter.outputs.css }} - e2e: ${{ steps.filter.outputs.e2e }} - jest: ${{ steps.filter.outputs.jest }} + php: "false" + phpcs: "false" + phpstan: "false" + phpunit: "true" + js: "false" + css: "false" + e2e: "false" + jest: "false" + # php: ${{ steps.filter.outputs.php }} + # phpcs: ${{ steps.filter.outputs.phpcs }} + # phpstan: ${{ steps.filter.outputs.phpstan }} + # phpunit: ${{ steps.filter.outputs.phpunit }} + # js: ${{ steps.filter.outputs.js }} + # css: ${{ steps.filter.outputs.css }} + # e2e: ${{ steps.filter.outputs.e2e }} + # jest: ${{ steps.filter.outputs.jest }} steps: - name: Install system dependencies From 7b20fa0421b9f01fa5d3082f0ab154fd3a71e7f4 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 15:43:48 +0530 Subject: [PATCH 07/38] ci: set WP_ENV_HOME for isolated wp-env data Ensure wp-env uses a dedicated /tmp/wp-env directory for all jobs by setting WP_ENV_HOME and mounting it in the container. This prevents permission issues and data conflicts in CI. Updates all workflow steps to use the new environment variable. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 11 ++++++---- .github/workflows/reusable-e2e.yml | 13 +++++++----- .github/workflows/reusable-phpunit.yml | 29 +++++++++++--------------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index d82152a..22e2a4f 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -15,13 +15,14 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root -v /var/run/docker.sock:/var/run/docker.sock + options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env permissions: contents: read env: WP_ENV_PORT: 8889 WP_ENV_TESTS_PORT: 8891 + WP_ENV_HOME: /tmp/wp-env steps: - name: Install system dependencies @@ -40,6 +41,8 @@ jobs: SOCK_GID=$(stat -c '%g' /var/run/docker.sock) groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser + mkdir -p /tmp/wp-env + chown -R wpuser:wpuser /tmp/wp-env - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -96,10 +99,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update - name: Generate Translation files - run: sudo -u wpuser env "PATH=$PATH" npm run i18n:make-pot + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -113,4 +116,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env destroy -- --force \ No newline at end of file diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 0d6c107..6757f00 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -17,13 +17,14 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root -v /var/run/docker.sock:/var/run/docker.sock + options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env timeout-minutes: 20 env: WP_ENV_PORT: 8889 WP_ENV_TESTS_PORT: 8891 + WP_ENV_HOME: /tmp/wp-env steps: - name: Install system dependencies @@ -42,6 +43,8 @@ jobs: SOCK_GID=$(stat -c '%g' /var/run/docker.sock) groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser + mkdir -p /tmp/wp-env + chown -R wpuser:wpuser /tmp/wp-env - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -96,14 +99,14 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" npm run test:e2e + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -116,4 +119,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force \ No newline at end of file diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index f7626bf..6a24e5d 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -32,13 +32,14 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root -v /var/run/docker.sock:/var/run/docker.sock - # timeout-minutes: 20 + options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env + timeout-minutes: 20 env: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} WP_ENV_PORT: 8889 WP_ENV_TESTS_PORT: 8891 + WP_ENV_HOME: /tmp/wp-env steps: - name: Install system dependencies @@ -57,6 +58,7 @@ jobs: SOCK_GID=$(stat -c '%g' /var/run/docker.sock) groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser + chown -R wpuser:wpuser /tmp/wp-env - name: Configure environment variables run: | @@ -120,30 +122,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -u wpuser env "PATH=$PATH" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -u wpuser env "PATH=$PATH" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli php -- -v - sudo -u wpuser env "PATH=$PATH" npm run wp-env:test -- run tests-cli wp core version - - - name: Pause before PhpUnit test (dbg mode) - run: | - while [ ! -f /tmp/resume ]; do - echo "Waiting for wp-env to be ready..." - sleep 60 - done + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli php -- -v + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -u wpuser env "PATH=$PATH" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -164,4 +159,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" npm run wp-env:test destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force From 9d1939f68db937774189051388f89f907239eebb Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:10:18 +0530 Subject: [PATCH 08/38] ci(github): increase timeouts and fix safe.directory - Increase `timeout-minutes` for build, e2e, and phpunit workflows to 30 minutes for more reliable CI runs. - Set `timeout_minutes` to 15 for Docker environment startup steps. - Add `git config --global --add safe.directory '/tmp/wp-env/*'` to address Git safe directory issues in Docker. - Run E2E tests with `--debug` for better diagnostics. - No functional changes to plugin code. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 8 ++++++-- .github/workflows/reusable-e2e.yml | 12 +++++++----- .github/workflows/reusable-phpunit.yml | 7 +++++-- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 22e2a4f..5320387 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -24,6 +24,8 @@ jobs: WP_ENV_TESTS_PORT: 8891 WP_ENV_HOME: /tmp/wp-env + timeout-minutes: 30 + steps: - name: Install system dependencies run: | @@ -99,7 +101,9 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update + command: | + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update - name: Generate Translation files run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot @@ -116,4 +120,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env destroy -- --force \ No newline at end of file + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 6757f00..001cca0 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -19,7 +19,7 @@ jobs: image: ubuntu:24.04 options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env - timeout-minutes: 20 + timeout-minutes: 30 env: WP_ENV_PORT: 8889 @@ -97,16 +97,18 @@ jobs: - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: - timeout_minutes: 10 + timeout_minutes: 15 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + command: | + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:e2e + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -119,4 +121,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force \ No newline at end of file + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 6a24e5d..7a10be3 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -33,7 +33,9 @@ jobs: container: image: ubuntu:24.04 options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env - timeout-minutes: 20 + + timeout-minutes: 30 + env: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} @@ -118,9 +120,10 @@ jobs: - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: - timeout_minutes: 10 + timeout_minutes: 15 max_attempts: 3 command: | + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' if [ "${{ inputs.coverage }}" == "true" ]; then sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else From 2686cfd8fb549caa9850df6408722b658d2a3ee2 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 16:42:15 +0530 Subject: [PATCH 09/38] feat(ci): use dynamic outputs for job filtering Update CI workflow to use step outputs for job filtering instead of hardcoded values. This enables more flexible and accurate job execution based on file changes. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5987f20..17edbc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,22 +29,14 @@ jobs: contents: read pull-requests: read outputs: - php: "false" - phpcs: "false" - phpstan: "false" - phpunit: "true" - js: "false" - css: "false" - e2e: "false" - jest: "false" - # php: ${{ steps.filter.outputs.php }} - # phpcs: ${{ steps.filter.outputs.phpcs }} - # phpstan: ${{ steps.filter.outputs.phpstan }} - # phpunit: ${{ steps.filter.outputs.phpunit }} - # js: ${{ steps.filter.outputs.js }} - # css: ${{ steps.filter.outputs.css }} - # e2e: ${{ steps.filter.outputs.e2e }} - # jest: ${{ steps.filter.outputs.jest }} + php: ${{ steps.filter.outputs.php }} + phpcs: ${{ steps.filter.outputs.phpcs }} + phpstan: ${{ steps.filter.outputs.phpstan }} + phpunit: ${{ steps.filter.outputs.phpunit }} + js: ${{ steps.filter.outputs.js }} + css: ${{ steps.filter.outputs.css }} + e2e: ${{ steps.filter.outputs.e2e }} + jest: ${{ steps.filter.outputs.jest }} steps: - name: Install system dependencies From 572203c5440aed4ce60da915f110c4e26f54663e Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Tue, 17 Mar 2026 18:22:01 +0530 Subject: [PATCH 10/38] ci: fix permission denied errors for test artifacts When running in the Docker-out-of-Docker CI setup, the actions/checkout step creates the workspace files as the `root` user. However, wp-env dynamically configures its internal test containers to run as `wpuser` (UID 1001) to match the host user executing `wp-env start`. This caused a permission collision where the test runner (running as UID 1001) could not write test artifacts (like .phpunit.result.cache and code coverage XML/HTML reports) back to the workspace directory owned by root. This adds a step to `chown -R wpuser:wpuser .` across the build, e2e, and phpunit workflows immediately before starting wp-env. This ensures the containerized test runner has the necessary write privileges to generate and upload coverage reports successfully. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 3 +++ .github/workflows/reusable-e2e.yml | 3 +++ .github/workflows/reusable-phpunit.yml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 5320387..3978c24 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -96,6 +96,9 @@ jobs: cat .wp-env.json + - name: Fix workspace permissions + run: chown -R wpuser:wpuser . + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 001cca0..e8afc75 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -94,6 +94,9 @@ jobs: cat .wp-env.test.json + - name: Fix workspace permissions + run: chown -R wpuser:wpuser . + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 7a10be3..0a6d6c2 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -117,6 +117,9 @@ jobs: cat .wp-env.test.json + - name: Fix workspace permissions + run: chown -R wpuser:wpuser . + - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: From ac888b5ae622e22757824c363f346777b3d8e984 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:24:01 +0530 Subject: [PATCH 11/38] dbg: e2e test suite Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 31 +++++++++++++++++++----------- .github/workflows/reusable-e2e.yml | 12 ++++++++++-- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 17edbc4..b856739 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,15 +29,23 @@ jobs: contents: read pull-requests: read outputs: - php: ${{ steps.filter.outputs.php }} - phpcs: ${{ steps.filter.outputs.phpcs }} - phpstan: ${{ steps.filter.outputs.phpstan }} - phpunit: ${{ steps.filter.outputs.phpunit }} - js: ${{ steps.filter.outputs.js }} - css: ${{ steps.filter.outputs.css }} - e2e: ${{ steps.filter.outputs.e2e }} - jest: ${{ steps.filter.outputs.jest }} - + php: "false" + phpcs: "false" + phpstan: "false" + phpunit: "false" + js: "false" + css: "false" + e2e: "true" + jest: "false" + + # php: ${{ steps.filter.outputs.php }} + # phpcs: ${{ steps.filter.outputs.phpcs }} + # phpstan: ${{ steps.filter.outputs.phpstan }} + # phpunit: ${{ steps.filter.outputs.phpunit }} + # js: ${{ steps.filter.outputs.js }} + # css: ${{ steps.filter.outputs.css }} + # e2e: ${{ steps.filter.outputs.e2e }} + # jest: ${{ steps.filter.outputs.jest }} steps: - name: Install system dependencies run: | @@ -163,8 +171,9 @@ jobs: e2e: name: E2E Tests - needs: [detect, phpunit] - if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') + # TODO(@dipankardas011): please remove this comment + # needs: [detect, phpunit] + # if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') uses: ./.github/workflows/reusable-e2e.yml permissions: contents: read diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index e8afc75..d1fb0a9 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -17,7 +17,7 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env + options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache timeout-minutes: 30 @@ -25,6 +25,7 @@ jobs: WP_ENV_PORT: 8889 WP_ENV_TESTS_PORT: 8891 WP_ENV_HOME: /tmp/wp-env + PLAYWRIGHT_BROWSERS_PATH: /tmp/playwright-cache steps: - name: Install system dependencies @@ -44,7 +45,9 @@ jobs: groupmod -g $SOCK_GID -o docker usermod -aG docker wpuser mkdir -p /tmp/wp-env + mkdir -p /tmp/playwright-cache chown -R wpuser:wpuser /tmp/wp-env + chown -R wpuser:wpuser /tmp/playwright-cache - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -110,8 +113,13 @@ jobs: run: | sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + - name: Install Playwright dependencies + run: | + npx playwright install-deps + sudo -u wpuser env "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install + - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From 681607d9fb187e8bee1d4592bd6b7d8970264f44 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 12:43:06 +0530 Subject: [PATCH 12/38] test(e2e): path for the npx Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index d1fb0a9..44484cd 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -116,7 +116,7 @@ jobs: - name: Install Playwright dependencies run: | npx playwright install-deps - sudo -u wpuser env "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug From 58522b212dc61b53fe76a465b3bc174d83492a5e Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:16:12 +0530 Subject: [PATCH 13/38] ci(e2e): giving it the wp-env test one Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 44484cd..4d7f6d8 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -111,7 +111,7 @@ jobs: - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | @@ -119,7 +119,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" "WP_ENV_CONFIG_PATH=.wp-env.test.json" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From aa57089a3d8e5738df00344b86905f5cfcd154e6 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 13:48:21 +0530 Subject: [PATCH 14/38] ci(e2e): disable Playwright webServer and clean env usage Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 2 +- playwright.config.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 4d7f6d8..ea6cbd3 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -119,7 +119,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" "WP_ENV_CONFIG_PATH=.wp-env.test.json" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 diff --git a/playwright.config.ts b/playwright.config.ts index 6023d14..fa7c416 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -22,6 +22,10 @@ const config = defineConfig( { ...baseConfig, testDir: './tests/e2e', outputDir: './tests/_output/e2e', + + // Disable Playwright's automatic webServer orchestration to prevent port + // conflicts, as the CI workflow/local scripts manually manage the wp-env lifecycle. + webServer: undefined, } ); export default config; From 1363a7789331032192c5edbb3fe7ef5e4fa1d65b Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 14:11:27 +0530 Subject: [PATCH 15/38] feat(ci): set WP_BASE_URL for E2E tests in workflow Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index ea6cbd3..5f378e5 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -119,7 +119,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" "WP_BASE_URL=http://127.0.0.1:8889" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From 32071491af36e34e4ac545bc3c1387880db32b27 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 15:49:25 +0530 Subject: [PATCH 16/38] ci(e2e): support host.docker.internal in e2e workflow Add --add-host=host.docker.internal:host-gateway to container options in the reusable-e2e.yml workflow. Update WP_BASE_URL to use host.docker.internal for E2E tests, enabling proper connectivity between Playwright and the WordPress instance when running in Docker. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 5f378e5..5a987e7 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -17,7 +17,7 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache + options: --user root --add-host=host.docker.internal:host-gateway -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache timeout-minutes: 30 @@ -119,7 +119,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" "WP_BASE_URL=http://127.0.0.1:8889" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" "WP_BASE_URL=http://host.docker.internal:8889" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From 38862365f87685e3ace3f8ce727927b906948987 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 16:35:21 +0530 Subject: [PATCH 17/38] feat(ci): improve Playwright network reliability in e2e workflow Use --network=host for the CI container to ensure Playwright shares the host Docker daemon's network. This prevents "ECONNREFUSED" errors when WordPress issues 302 redirects to "localhost", avoiding loopback traps inside the CI container. Also remove WP_BASE_URL env from test command. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 5a987e7..14e6e34 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -17,7 +17,11 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - options: --user root --add-host=host.docker.internal:host-gateway -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache + # We use --network=host to ensure Playwright (running inside this CI container) + # shares the exact same network as the host Docker daemon. This prevents + # "ECONNREFUSED" errors when WordPress issues 302 redirects back to "localhost", + # which would otherwise trap Playwright inside the CI container's loopback. + options: --user root --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache timeout-minutes: 30 @@ -119,7 +123,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" "WP_BASE_URL=http://host.docker.internal:8889" npm run test:e2e -- --debug + run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From d9fc1dea8493a67ddf37cecb68518a12572f6d82 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 18:22:28 +0530 Subject: [PATCH 18/38] feat(ci): enhance E2E reliability with socat proxy Switch CI container from --network=host to --add-host and socat proxy for localhost:8889. This ensures Playwright and WordPress agree on "localhost" and prevents network isolation issues. Adds socat to dependencies and updates E2E test step to forward traffic, improving test stability. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 14e6e34..8772806 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -17,11 +17,9 @@ jobs: runs-on: [public-repo] container: image: ubuntu:24.04 - # We use --network=host to ensure Playwright (running inside this CI container) - # shares the exact same network as the host Docker daemon. This prevents - # "ECONNREFUSED" errors when WordPress issues 302 redirects back to "localhost", - # which would otherwise trap Playwright inside the CI container's loopback. - options: --user root --network=host -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache + # We use --add-host to get the host IP, and we will use socat to forward + # localhost:8889 to the host so Playwright and WordPress agree on "localhost". + options: --user root --add-host=host.docker.internal:host-gateway -v /var/run/docker.sock:/var/run/docker.sock -v /tmp/wp-env:/tmp/wp-env -v /tmp/playwright-cache:/tmp/playwright-cache timeout-minutes: 30 @@ -35,7 +33,7 @@ jobs: - name: Install system dependencies run: | apt-get update - apt-get install -y git curl sudo unzip jq + apt-get install -y git curl sudo unzip jq socat - name: setup Docker run: | @@ -123,7 +121,13 @@ jobs: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests - run: sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug + run: | + # Forward localhost traffic from the CI container to the Host machine + # where the WordPress Docker container is actually listening. + # This ensures Playwright and WordPress both agree the domain is "localhost:8889". + socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & + + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 From 1e4d74ee9049de8abb48e4440d7d423d751d9e95 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 18:47:06 +0530 Subject: [PATCH 19/38] feat(test): enable headless mode in Playwright config Set Playwright to run in headless mode by default for more consistent and reliable test execution in CI and local environments. This avoids issues with UI rendering and ensures tests do not require a display server. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- playwright.config.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/playwright.config.ts b/playwright.config.ts index fa7c416..2a62f39 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -26,6 +26,9 @@ const config = defineConfig( { // Disable Playwright's automatic webServer orchestration to prevent port // conflicts, as the CI workflow/local scripts manually manage the wp-env lifecycle. webServer: undefined, + use: { + headless: true, + }, } ); export default config; From ff4a7a04b558ef38af82c691287a87e41130f061 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 18:57:52 +0530 Subject: [PATCH 20/38] chore(e2e): remove debug flag and extend base config Removed the --debug flag from the E2E test command in the CI workflow to ensure tests run in standard mode. Updated Playwright config to spread baseConfig.use for better configuration inheritance. These changes improve consistency and maintainability of E2E test execution. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-e2e.yml | 2 +- playwright.config.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 8772806..fcabdaa 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -127,7 +127,7 @@ jobs: # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e -- --debug + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 diff --git a/playwright.config.ts b/playwright.config.ts index 2a62f39..71f16ec 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -27,6 +27,7 @@ const config = defineConfig( { // conflicts, as the CI workflow/local scripts manually manage the wp-env lifecycle. webServer: undefined, use: { + ...baseConfig.use, headless: true, }, } ); From b457253f714813c06c91c5d332b902316675ade0 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Wed, 18 Mar 2026 19:23:56 +0530 Subject: [PATCH 21/38] feat(ci): enable dynamic outputs and e2e job triggers Updated CI workflow to use dynamic outputs from filter steps instead of hardcoded values. Enabled e2e job to trigger based on detection results and phpunit status. Removed outdated comments for clarity. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b856739..047b787 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,23 +29,14 @@ jobs: contents: read pull-requests: read outputs: - php: "false" - phpcs: "false" - phpstan: "false" - phpunit: "false" - js: "false" - css: "false" - e2e: "true" - jest: "false" - - # php: ${{ steps.filter.outputs.php }} - # phpcs: ${{ steps.filter.outputs.phpcs }} - # phpstan: ${{ steps.filter.outputs.phpstan }} - # phpunit: ${{ steps.filter.outputs.phpunit }} - # js: ${{ steps.filter.outputs.js }} - # css: ${{ steps.filter.outputs.css }} - # e2e: ${{ steps.filter.outputs.e2e }} - # jest: ${{ steps.filter.outputs.jest }} + php: ${{ steps.filter.outputs.php }} + phpcs: ${{ steps.filter.outputs.phpcs }} + phpstan: ${{ steps.filter.outputs.phpstan }} + phpunit: ${{ steps.filter.outputs.phpunit }} + js: ${{ steps.filter.outputs.js }} + css: ${{ steps.filter.outputs.css }} + e2e: ${{ steps.filter.outputs.e2e }} + jest: ${{ steps.filter.outputs.jest }} steps: - name: Install system dependencies run: | @@ -171,9 +162,8 @@ jobs: e2e: name: E2E Tests - # TODO(@dipankardas011): please remove this comment - # needs: [detect, phpunit] - # if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') + needs: [detect, phpunit] + if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') uses: ./.github/workflows/reusable-e2e.yml permissions: contents: read From 2830f5275b8277753db6dcabcec4d9612ef9dae2 Mon Sep 17 00:00:00 2001 From: Dipankar Das Date: Wed, 18 Mar 2026 19:31:56 +0530 Subject: [PATCH 22/38] Apply suggestion from @dipankardas011 --- .github/workflows/reusable-wp-playground-pr-preview.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index 270166b..247ac11 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -43,8 +43,6 @@ jobs: apt-get update apt-get install -y git curl - # - name: Configure Git for Safe Directory - # run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - name: Extract PR metadata and artifact info id: pr-metadata From 790da09367bda94e001560c8fc478f30519e32fe Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 13:09:18 +0530 Subject: [PATCH 23/38] ci: improve CI blueprint and Playwright config - Switch blueprint JSON mutation from Node.js to jq in the workflow, simplifying dependencies and improving readability. - Add jq to system dependencies in the workflow. - Refactor Playwright config to disable webServer orchestration by destructuring base config, preventing port conflicts and aligning with manual wp-env lifecycle management. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .../reusable-wp-playground-pr-preview.yml | 24 ++++++------------- playwright.config.ts | 12 +++++----- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index 247ac11..debbb79 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -41,7 +41,7 @@ jobs: - name: Install system dependencies run: | apt-get update - apt-get install -y git curl + apt-get install -y git curl jq - name: Extract PR metadata and artifact info @@ -104,22 +104,12 @@ jobs: - name: Generate Playground blueprint JSON id: blueprint run: | - node - <<'NODE' >> "$GITHUB_OUTPUT" - const fs = require('fs'); - const url = process.env.ARTIFACT_URL; - if (!url) { - throw new Error('ARTIFACT_URL is required'); - } - - // Load the base blueprint and update the plugin URL - const blueprint = JSON.parse(fs.readFileSync('blueprint.json', 'utf8')); - const installStep = blueprint.steps.find(s => s.step === 'installPlugin'); - if (installStep) { - installStep.pluginData.url = url; - } - - console.log(`blueprint=${JSON.stringify(blueprint)}`); - NODE + if [ -z "$ARTIFACT_URL" ]; then + echo "::error::ARTIFACT_URL is required" + exit 1 + fi + BLUEPRINT=$(jq --arg url "$ARTIFACT_URL" '(.steps[] | select(.step == "installPlugin") | .pluginData.url) = $url' blueprint.json) + echo "blueprint=$(echo $BLUEPRINT | jq -c .)" >> "$GITHUB_OUTPUT" env: ARTIFACT_URL: ${{ steps.expose.outputs.artifact-url }} diff --git a/playwright.config.ts b/playwright.config.ts index 71f16ec..89cb960 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -18,16 +18,16 @@ process.env[ 'STORAGE_STATE_PATH' ] = path.join( const baseConfig = require( '@wordpress/scripts/config/playwright.config.js' ) as PlaywrightTestConfig; // eslint-disable-line @typescript-eslint/no-var-requires +// Disable Playwright's automatic webServer orchestration to prevent port +// conflicts, as the CI workflow/local scripts manually manage the wp-env lifecycle. +const { webServer, ...baseConfigWithoutWebServer } = baseConfig; + const config = defineConfig( { - ...baseConfig, + ...baseConfigWithoutWebServer, testDir: './tests/e2e', outputDir: './tests/_output/e2e', - - // Disable Playwright's automatic webServer orchestration to prevent port - // conflicts, as the CI workflow/local scripts manually manage the wp-env lifecycle. - webServer: undefined, use: { - ...baseConfig.use, + ...baseConfigWithoutWebServer.use, headless: true, }, } ); From 08be4c7f13dc8baff3fa4e099347af06804c2f38 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 16:23:52 +0530 Subject: [PATCH 24/38] ci: update workflow dependencies and permissions Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 8 +++----- .github/workflows/reusable-build.yml | 8 ++++---- .github/workflows/reusable-e2e.yml | 12 ++++++------ .github/workflows/reusable-phpunit.yml | 5 +++-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 047b787..fe7b08c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -139,7 +139,7 @@ jobs: phpunit: name: PHPUnit (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) - needs: detect + needs: [detect, build-plugin-zip] if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpunit == 'true' uses: ./.github/workflows/reusable-phpunit.yml permissions: @@ -162,8 +162,8 @@ jobs: e2e: name: E2E Tests - needs: [detect, phpunit] - if: needs.detect.result == 'success' && (needs.phpunit.result == 'success' || needs.phpunit.result == 'skipped') && (needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true') + needs: phpunit + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' uses: ./.github/workflows/reusable-e2e.yml permissions: contents: read @@ -172,8 +172,6 @@ jobs: build-plugin-zip: name: Build Plugin Zip - needs: [e2e] - if: needs.e2e.result == 'success' || needs.e2e.result == 'skipped' permissions: contents: read uses: ./.github/workflows/reusable-build.yml diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 3978c24..1ea0ebd 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -97,16 +97,16 @@ jobs: cat .wp-env.json - name: Fix workspace permissions - run: chown -R wpuser:wpuser . + run: | + chown -R wpuser:wpuser . + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: timeout_minutes: 10 max_attempts: 3 - command: | - sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update - name: Generate Translation files run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index fcabdaa..320c05f 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -100,16 +100,16 @@ jobs: cat .wp-env.test.json - name: Fix workspace permissions - run: chown -R wpuser:wpuser . + run: | + chown -R wpuser:wpuser . + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 with: timeout_minutes: 15 max_attempts: 3 - command: | - sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | @@ -122,11 +122,11 @@ jobs: - name: Run E2E tests run: | - # Forward localhost traffic from the CI container to the Host machine + # Forward localhost traffic from the CI container to the Host machine # where the WordPress Docker container is actually listening. # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e - name: Upload E2E test results as artifact diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 0a6d6c2..920222e 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -118,7 +118,9 @@ jobs: cat .wp-env.test.json - name: Fix workspace permissions - run: chown -R wpuser:wpuser . + run: | + chown -R wpuser:wpuser . + sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' - name: Start the Docker testing environment uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 @@ -126,7 +128,6 @@ jobs: timeout_minutes: 15 max_attempts: 3 command: | - sudo -u wpuser git config --global --add safe.directory '/tmp/wp-env/*' if [ "${{ inputs.coverage }}" == "true" ]; then sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else From 752952b4ffc693ce2e9b0d1d5b635d9697d8de13 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 16:51:49 +0530 Subject: [PATCH 25/38] ci(playground): add GitHub CLI install to PR preview workflow Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-wp-playground-pr-preview.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index debbb79..627ea10 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -41,8 +41,11 @@ jobs: - name: Install system dependencies run: | apt-get update - apt-get install -y git curl jq - + apt-get install -y git curl jq gpg + curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null + apt-get update + apt install -y gh - name: Extract PR metadata and artifact info id: pr-metadata From 30511eca6ff2f69f88f8aabf91d5f91d9c59e056 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 17:56:41 +0530 Subject: [PATCH 26/38] ci: simplify workflows and update test commands - Use `ubuntu-latest` instead of custom container in CI workflow - Remove unnecessary system dependency and git safe directory steps - Use `sudo -E -u wpuser` for environment consistency in reusable workflows - Remove explicit port settings from `.wp-env.test.json` - Update `test:php` script to use `cli` instead of `tests-cli` - Improve workflow maintainability and reduce complexity Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/ci.yml | 12 +----------- .github/workflows/reusable-build.yml | 6 +++--- .github/workflows/reusable-e2e.yml | 10 +++++----- .github/workflows/reusable-phpunit.yml | 16 ++++++++-------- .wp-env.test.json | 2 -- package.json | 2 +- 6 files changed, 18 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fe7b08c..84c0bcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,9 +21,7 @@ permissions: jobs: detect: name: Detect Changes - runs-on: [public-repo] - container: - image: ubuntu:24.04 + runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: contents: read @@ -38,17 +36,9 @@ jobs: e2e: ${{ steps.filter.outputs.e2e }} jest: ${{ steps.filter.outputs.jest }} steps: - - name: Install system dependencies - run: | - apt-get update - apt-get install -y git - - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - - name: Configure Git for Safe Directory - run: git config --global --add safe.directory "${GITHUB_WORKSPACE}" - - name: Detect file changes uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 id: filter diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 1ea0ebd..052b2a4 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -106,10 +106,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update + command: sudo -E -u wpuser npm run wp-env start -- --update - name: Generate Translation files - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot + run: sudo -E -u wpuser npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -123,4 +123,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env destroy -- --force + run: sudo -E -u wpuser npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 320c05f..3d76fdc 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -109,16 +109,16 @@ jobs: with: timeout_minutes: 15 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + command: sudo -E -u wpuser npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | npx playwright install-deps - sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install + sudo -E -u wpuser npx playwright install - name: Run E2E tests run: | @@ -127,7 +127,7 @@ jobs: # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e + sudo -E -u wpuser npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -140,4 +140,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force + run: sudo -E -u wpuser npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 920222e..8c58e95 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -129,23 +129,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -E -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + sudo -E -u wpuser npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli php -- -v - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli wp core version + sudo -E -u wpuser npm run wp-env:test -- run tests-cli php -- -v + sudo -E -u wpuser npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -E -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -166,4 +166,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force + run: sudo -E -u wpuser npm run wp-env:test destroy -- --force diff --git a/.wp-env.test.json b/.wp-env.test.json index 6297e6e..c986167 100644 --- a/.wp-env.test.json +++ b/.wp-env.test.json @@ -1,8 +1,6 @@ { "$schema": "https://schemas.wp.org/trunk/wp-env.json", "core": null, - "port": 8889, - "testsPort": 8891, "testsEnvironment": true, "plugins": [ "." ], "config": { diff --git a/package.json b/package.json index 6411f1b..65e3422 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "test:js": "wp-scripts test-unit-js", "test:js:watch": "wp-scripts test-unit-js --watch", "test:js:coverage": "wp-scripts test-unit-js --coverage", - "test:php": "npm run wp-env:test -- run tests-cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ vendor/bin/phpunit -c phpunit.xml.dist", + "test:php": "npm run wp-env:test -- run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/ vendor/bin/phpunit -c phpunit.xml.dist", "wp-env": "wp-env", "wp-env:cli": "wp-env run cli --env-cwd=wp-content/plugins/$(basename \"$(pwd)\")/", "wp-env:test": "wp-env --config=.wp-env.test.json" From cafed50944a4d1e9586fce45160223dea06200e8 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 18:13:56 +0530 Subject: [PATCH 27/38] ci(github): fix PATH for sudo -u wpuser npm commands Ensure PATH is preserved when running npm and npx commands as wpuser via sudo in GitHub Actions workflows. This prevents issues where npm, npx, or node may not be found due to a restricted environment PATH. Updates all relevant commands in reusable-build, reusable-e2e, and reusable-phpunit workflows. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 6 +++--- .github/workflows/reusable-e2e.yml | 10 +++++----- .github/workflows/reusable-phpunit.yml | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 052b2a4..29f35c2 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -106,10 +106,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -E -u wpuser npm run wp-env start -- --update + command: sudo -E PATH=$PATH -u wpuser npm run wp-env start -- --update - name: Generate Translation files - run: sudo -E -u wpuser npm run i18n:make-pot + run: sudo -E PATH=$PATH -u wpuser npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -123,4 +123,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env destroy -- --force + run: sudo -E PATH=$PATH -u wpuser npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 3d76fdc..c73625c 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -109,16 +109,16 @@ jobs: with: timeout_minutes: 15 max_attempts: 3 - command: sudo -E -u wpuser npm run wp-env:test start -- --update + command: sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E PATH=$PATH -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | npx playwright install-deps - sudo -E -u wpuser npx playwright install + sudo -E PATH=$PATH -u wpuser npx playwright install - name: Run E2E tests run: | @@ -127,7 +127,7 @@ jobs: # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - sudo -E -u wpuser npm run test:e2e + sudo -E PATH=$PATH -u wpuser npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -140,4 +140,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env:test destroy -- --force + run: sudo -E PATH=$PATH -u wpuser npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 8c58e95..bde142f 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -129,23 +129,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -E -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -E -u wpuser npm run wp-env:test start -- --update + sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -E -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -E PATH=$PATH -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E PATH=$PATH -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -E -u wpuser npm run wp-env:test -- run tests-cli php -- -v - sudo -E -u wpuser npm run wp-env:test -- run tests-cli wp core version + sudo -E PATH=$PATH -u wpuser npm run wp-env:test -- run tests-cli php -- -v + sudo -E PATH=$PATH -u wpuser npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -E -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -E PATH=$PATH -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -166,4 +166,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env:test destroy -- --force + run: sudo -E PATH=$PATH -u wpuser npm run wp-env:test destroy -- --force From 8117a4b2a1474ce2c29bbda5a2cdd34d52fb6325 Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 18:40:26 +0530 Subject: [PATCH 28/38] Revert "ci(github): fix PATH for sudo -u wpuser npm commands" This reverts commit cafed50944a4d1e9586fce45160223dea06200e8. --- .github/workflows/reusable-build.yml | 6 +++--- .github/workflows/reusable-e2e.yml | 10 +++++----- .github/workflows/reusable-phpunit.yml | 16 ++++++++-------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 29f35c2..052b2a4 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -106,10 +106,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -E PATH=$PATH -u wpuser npm run wp-env start -- --update + command: sudo -E -u wpuser npm run wp-env start -- --update - name: Generate Translation files - run: sudo -E PATH=$PATH -u wpuser npm run i18n:make-pot + run: sudo -E -u wpuser npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -123,4 +123,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E PATH=$PATH -u wpuser npm run wp-env destroy -- --force + run: sudo -E -u wpuser npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index c73625c..3d76fdc 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -109,16 +109,16 @@ jobs: with: timeout_minutes: 15 max_attempts: 3 - command: sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --update + command: sudo -E -u wpuser npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -E PATH=$PATH -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | npx playwright install-deps - sudo -E PATH=$PATH -u wpuser npx playwright install + sudo -E -u wpuser npx playwright install - name: Run E2E tests run: | @@ -127,7 +127,7 @@ jobs: # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - sudo -E PATH=$PATH -u wpuser npm run test:e2e + sudo -E -u wpuser npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -140,4 +140,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E PATH=$PATH -u wpuser npm run wp-env:test destroy -- --force + run: sudo -E -u wpuser npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index bde142f..8c58e95 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -129,23 +129,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -E -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -E PATH=$PATH -u wpuser npm run wp-env:test start -- --update + sudo -E -u wpuser npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -E PATH=$PATH -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -E PATH=$PATH -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -E -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -E PATH=$PATH -u wpuser npm run wp-env:test -- run tests-cli php -- -v - sudo -E PATH=$PATH -u wpuser npm run wp-env:test -- run tests-cli wp core version + sudo -E -u wpuser npm run wp-env:test -- run tests-cli php -- -v + sudo -E -u wpuser npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -E PATH=$PATH -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -E -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -166,4 +166,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E PATH=$PATH -u wpuser npm run wp-env:test destroy -- --force + run: sudo -E -u wpuser npm run wp-env:test destroy -- --force From c7e7ecf5cf89aa81bf4d74aab5191770fce80f6e Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 18:43:56 +0530 Subject: [PATCH 29/38] ci(github): add npm to PATH for wpuser in workflows Ensure npm is available in PATH for the wpuser by updating .bashrc in build, e2e, and phpunit reusable workflows. This helps prevent issues with npm commands not being found during CI runs. Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 3 +++ .github/workflows/reusable-e2e.yml | 3 +++ .github/workflows/reusable-phpunit.yml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 052b2a4..b1efc8e 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -71,6 +71,9 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' + - name: Add npm to PATH for wpuser + run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc + - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 3d76fdc..b5393c4 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -74,6 +74,9 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' + - name: Add npm to PATH for wpuser + run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc + - name: Install npm dependencies run: npm ci diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 8c58e95..aa8312b 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -90,6 +90,9 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' + - name: Add npm to PATH for wpuser + run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc + - name: Install npm dependencies run: npm ci From a244705a19b7c60ca27fc1c91974a8cddc6b323f Mon Sep 17 00:00:00 2001 From: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> Date: Thu, 19 Mar 2026 19:07:54 +0530 Subject: [PATCH 30/38] reverted the sudo -E to bring the system back to stability Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com> --- .github/workflows/reusable-build.yml | 9 +++------ .github/workflows/reusable-e2e.yml | 13 +++++-------- .github/workflows/reusable-phpunit.yml | 19 ++++++++----------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index b1efc8e..1ea0ebd 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -71,9 +71,6 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - - name: Add npm to PATH for wpuser - run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc - - name: Install npm dependencies run: npm ci @@ -109,10 +106,10 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -E -u wpuser npm run wp-env start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update - name: Generate Translation files - run: sudo -E -u wpuser npm run i18n:make-pot + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot - name: Create plugin zip run: npm run plugin-zip @@ -126,4 +123,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env destroy -- --force diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index b5393c4..320c05f 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -74,9 +74,6 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - - name: Add npm to PATH for wpuser - run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc - - name: Install npm dependencies run: npm ci @@ -112,16 +109,16 @@ jobs: with: timeout_minutes: 15 max_attempts: 3 - command: sudo -E -u wpuser npm run wp-env:test start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | npx playwright install-deps - sudo -E -u wpuser npx playwright install + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npx playwright install - name: Run E2E tests run: | @@ -130,7 +127,7 @@ jobs: # This ensures Playwright and WordPress both agree the domain is "localhost:8889". socat TCP4-LISTEN:8889,fork,bind=127.0.0.1 TCP4:host.docker.internal:8889 & - sudo -E -u wpuser npm run test:e2e + sudo -u wpuser env "PATH=$PATH" "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_BROWSERS_PATH" npm run test:e2e - name: Upload E2E test results as artifact uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 @@ -143,4 +140,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env:test destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index aa8312b..46793db 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -90,9 +90,6 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - - name: Add npm to PATH for wpuser - run: echo "export PATH=${PATH}" >> /home/wpuser/.bashrc - - name: Install npm dependencies run: npm ci @@ -132,23 +129,23 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -E -u wpuser npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -E -u wpuser npm run wp-env:test start -- --update + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update fi - name: Activate plugin run: | - sudo -E -u wpuser npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -E -u wpuser npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d - name: Log versions run: | - sudo -E -u wpuser npm run wp-env:test -- run tests-cli php -- -v - sudo -E -u wpuser npm run wp-env:test -- run tests-cli wp core version + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli php -- -v + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} - run: sudo -E -u wpuser npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} - name: Upload code coverage report if: ${{ inputs.coverage }} @@ -169,4 +166,4 @@ jobs: - name: Stop the Docker testing environment if: always() - run: sudo -E -u wpuser npm run wp-env:test destroy -- --force + run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test destroy -- --force From cef424a89df56b50cd90fddccff53882cf461aea Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Thu, 19 Mar 2026 22:06:19 +0200 Subject: [PATCH 31/38] ci: restore public workflows --- .github/workflows/ci.yml | 18 +- .github/workflows/release-public.yml | 58 ++++++ .github/workflows/reusable-build-public.yml | 66 +++++++ .github/workflows/reusable-e2e-public.yml | 64 +++++++ .github/workflows/reusable-jest-public.yml | 55 ++++++ .../workflows/reusable-lint-css-js-public.yml | 54 ++++++ .github/workflows/reusable-phpcs-public.yml | 53 ++++++ .github/workflows/reusable-phpstan-public.yml | 56 ++++++ .github/workflows/reusable-phpunit-public.yml | 105 +++++++++++ ...usable-wp-playground-pr-preview-public.yml | 123 +++++++++++++ .github/workflows/test-public-workflows.yml | 174 ++++++++++++++++++ 11 files changed, 825 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release-public.yml create mode 100644 .github/workflows/reusable-build-public.yml create mode 100644 .github/workflows/reusable-e2e-public.yml create mode 100644 .github/workflows/reusable-jest-public.yml create mode 100644 .github/workflows/reusable-lint-css-js-public.yml create mode 100644 .github/workflows/reusable-phpcs-public.yml create mode 100644 .github/workflows/reusable-phpstan-public.yml create mode 100644 .github/workflows/reusable-phpunit-public.yml create mode 100644 .github/workflows/reusable-wp-playground-pr-preview-public.yml create mode 100644 .github/workflows/test-public-workflows.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06b867e..85fe1c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ permissions: jobs: detect: name: Detect Changes + # Use `ubuntu-24.04` on public repositories. runs-on: ubuntu-latest if: github.event_name != 'pull_request' || github.event.pull_request.draft == false permissions: @@ -35,9 +36,13 @@ jobs: css: ${{ steps.filter.outputs.css }} e2e: ${{ steps.filter.outputs.e2e }} jest: ${{ steps.filter.outputs.jest }} + steps: - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + # Comment this out on private repositories to allow sharing of credentials with subsequent jobs. + # with: + # persist-credentials: false - name: Detect file changes uses: dorny/paths-filter@9d7afb8d214ad99e78fbd4247752c4caed2b6e4c # v4.0.0 @@ -74,9 +79,10 @@ jobs: - '**.css' - '**.scss' - '.stylelintignore' - - '.stylelintrc*' + - '.stylelint.config.js*' e2e: - 'tests/e2e/**/*' + - 'playwright.config.ts' - '.github/workflows/reusable-e2e.yml' jest: - 'tests/js/**/*' @@ -94,6 +100,7 @@ jobs: needs: detect if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpcs == 'true' uses: ./.github/workflows/reusable-phpcs.yml + # uses: ./.github/workflows/reusable-phpcs-public.yml permissions: contents: read with: @@ -104,6 +111,7 @@ jobs: needs: detect if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpstan == 'true' uses: ./.github/workflows/reusable-phpstan.yml + # uses: ./.github/workflows/reusable-phpstan-public.yml permissions: contents: read with: @@ -114,6 +122,7 @@ jobs: needs: detect if: needs.detect.outputs.css == 'true' || needs.detect.outputs.js == 'true' uses: ./.github/workflows/reusable-lint-css-js.yml + # uses: ./.github/workflows/reusable-lint-css-js-public.yml permissions: contents: read @@ -122,6 +131,7 @@ jobs: needs: detect if: needs.detect.outputs.js == 'true' || needs.detect.outputs.jest == 'true' uses: ./.github/workflows/reusable-jest.yml + # uses: ./.github/workflows/reusable-jest-public.yml permissions: contents: read with: @@ -132,10 +142,12 @@ jobs: needs: [detect, build-plugin-zip] if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpunit == 'true' uses: ./.github/workflows/reusable-phpunit.yml + # uses: ./.github/workflows/reusable-phpunit-public.yml permissions: contents: read strategy: fail-fast: false + # Uncomment this on private runners, which can't run multiple wp-env instances in parallel. max-parallel: 1 matrix: php: ['8.4', '8.3', '8.2'] @@ -152,9 +164,11 @@ jobs: e2e: name: E2E Tests + # needs: detect needs: phpunit if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' uses: ./.github/workflows/reusable-e2e.yml + # uses: ./.github/workflows/reusable-e2e-public.yml permissions: contents: read with: @@ -165,6 +179,7 @@ jobs: permissions: contents: read uses: ./.github/workflows/reusable-build.yml + # uses: ./.github/workflows/reusable-build-public.yml with: php-version: '8.2' artifact-name: plugin-skeleton-d-pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} @@ -175,6 +190,7 @@ jobs: needs: build-plugin-zip if: github.event_name == 'pull_request' uses: ./.github/workflows/reusable-wp-playground-pr-preview.yml + # uses: ./.github/workflows/reusable-wp-playground-pr-preview-public.yml permissions: actions: read contents: write diff --git a/.github/workflows/release-public.yml b/.github/workflows/release-public.yml new file mode 100644 index 0000000..ec49e04 --- /dev/null +++ b/.github/workflows/release-public.yml @@ -0,0 +1,58 @@ +name: Release + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: write + issues: write + pull-requests: write + +jobs: + release-please: + name: Release Please + runs-on: ubuntu-24.04 + outputs: + release_created: ${{ steps.release.outputs.release_created }} + tag_name: ${{ steps.release.outputs.tag_name }} + steps: + - name: Prepare release + id: release + uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 + with: + token: ${{ secrets.GITHUB_TOKEN }} + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + + build: + permissions: + contents: read + needs: release-please + if: ${{ needs.release-please.outputs.release_created }} + uses: ./.github/workflows/reusable-build.yml + with: + php-version: '8.2' + artifact-name: plugin-skeleton-d + secrets: inherit + + upload: + name: Upload release asset + needs: [release-please, build] + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: write + steps: + - name: Download artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: plugin-skeleton-d + path: . + + - name: Upload release asset + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh release upload ${{ needs.release-please.outputs.tag_name }} plugin-skeleton-d.zip --clobber diff --git a/.github/workflows/reusable-build-public.yml b/.github/workflows/reusable-build-public.yml new file mode 100644 index 0000000..012c136 --- /dev/null +++ b/.github/workflows/reusable-build-public.yml @@ -0,0 +1,66 @@ +name: Reusable Build + +on: + workflow_call: + inputs: + php-version: + required: true + type: string + artifact-name: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Set up PHP + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 + with: + php-version: ${{ inputs.php-version }} + coverage: none + + - name: Install Composer dependencies + uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3.2.0 + with: + composer-options: '--no-dev --optimize-autoloader' + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Build plugin for release + run: npm run build:prod + + - name: Start the Docker testing environment + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + timeout_minutes: 10 + max_attempts: 3 + command: npm run wp-env start + + - name: Generate Translation files + run: npm run i18n:make-pot + + - name: Create plugin zip + run: npm run plugin-zip + + - name: Upload plugin zip artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: ${{ inputs.artifact-name }} + path: plugin-skeleton-d.zip + if-no-files-found: error diff --git a/.github/workflows/reusable-e2e-public.yml b/.github/workflows/reusable-e2e-public.yml new file mode 100644 index 0000000..e5dce7d --- /dev/null +++ b/.github/workflows/reusable-e2e-public.yml @@ -0,0 +1,64 @@ +name: Run E2E Tests + +on: + workflow_call: + inputs: + php-version: + description: 'PHP version to use' + required: true + type: string + +permissions: {} + +jobs: + e2e: + name: Playwright E2E Tests + runs-on: ubuntu-24.04 + timeout-minutes: 20 + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Set up PHP + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 + with: + php-version: ${{ inputs.php-version }} + coverage: none + + - name: Install Composer dependencies + uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3.2.0 + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Build development assets + run: npm run build:dev + + - name: Start the Docker testing environment + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + timeout_minutes: 10 + max_attempts: 3 + command: WP_ENV_PORT=8889 WP_ENV_TESTS_PORT=8891 npm run wp-env:test start + + - name: Run E2E tests + run: npm run test:e2e + + - name: Upload E2E test results as artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + if: always() + with: + name: playwright-report + path: tests/_output + retention-days: 2 + if-no-files-found: ignore diff --git a/.github/workflows/reusable-jest-public.yml b/.github/workflows/reusable-jest-public.yml new file mode 100644 index 0000000..719dc08 --- /dev/null +++ b/.github/workflows/reusable-jest-public.yml @@ -0,0 +1,55 @@ +name: Run Jest Tests + +on: + workflow_call: + inputs: + coverage: + description: 'Enable code coverage' + required: false + type: boolean + default: true + +permissions: {} + +jobs: + jest: + name: Jest Unit Tests${{ inputs.coverage && ' with coverage' || '' }} + runs-on: ubuntu-24.04 + timeout-minutes: 10 + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Run Jest tests${{ inputs.coverage && ' with coverage' || '' }} + run: npm run test:js${{ inputs.coverage && ':coverage' || '' }} + + - name: Upload code coverage report to Codecov + if: ${{ inputs.coverage }} + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: tests/_output/js-coverage/lcov.info + flags: jest + fail_ci_if_error: false + + - name: Upload HTML coverage report as artifact + if: ${{ inputs.coverage }} + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: jest-code-coverage + path: tests/_output/js-coverage/lcov-report + retention-days: 7 + if-no-files-found: ignore diff --git a/.github/workflows/reusable-lint-css-js-public.yml b/.github/workflows/reusable-lint-css-js-public.yml new file mode 100644 index 0000000..c855250 --- /dev/null +++ b/.github/workflows/reusable-lint-css-js-public.yml @@ -0,0 +1,54 @@ +name: Run JS Lint + +on: + workflow_call: + +permissions: {} + +jobs: + lint-js: + name: JS Lint & TypeScript + runs-on: ubuntu-24.04 + timeout-minutes: 20 + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Run ESLint + id: eslint + continue-on-error: true + run: npm run lint:js + + - name: Run TypeScript check + id: typescript + continue-on-error: true + run: npm run lint:js:types + + - name: Run Stylelint + id: stylelint + continue-on-error: true + run: npm run lint:css + + - name: Run Prettier check + id: prettier + continue-on-error: true + run: npm run format -- --check + + - name: Check for errors + if: ${{ steps.eslint.outcome == 'failure' || steps.typescript.outcome == 'failure' || steps.prettier.outcome == 'failure' || steps.stylelint.outcome == 'failure' }} + run: | + echo "One or more checks failed. See logs above for details." + exit 1 diff --git a/.github/workflows/reusable-phpcs-public.yml b/.github/workflows/reusable-phpcs-public.yml new file mode 100644 index 0000000..dbfec74 --- /dev/null +++ b/.github/workflows/reusable-phpcs-public.yml @@ -0,0 +1,53 @@ +name: Run PHPCS + +on: + workflow_call: + inputs: + php-version: + description: 'PHP version to use' + required: true + type: string + +permissions: {} + +jobs: + phpcs: + name: PHPCS Coding Standards + runs-on: ubuntu-24.04 + timeout-minutes: 20 + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Set up PHP + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 + with: + php-version: ${{ inputs.php-version }} + coverage: none + tools: cs2pr + + # This date is used to ensure that the PHPCS cache is cleared at least once every week. + - name: "Get last Monday's date" + id: get-date + run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" + + - name: Cache PHPCS scan cache + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + with: + path: tests/_output/phpcs-cache.json + key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', '.phpcs.xml.dist') }} + + - name: Install Composer dependencies + uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3.2.0 + + - name: Run PHPCS + id: phpcs + run: composer lint -- --report-full --report-checkstyle=./tests/_output/phpcs-report.xml + + - name: Show PHPCS results in PR + if: ${{ always() && steps.phpcs.outcome == 'failure' }} + run: cs2pr ./tests/_output/phpcs-report.xml diff --git a/.github/workflows/reusable-phpstan-public.yml b/.github/workflows/reusable-phpstan-public.yml new file mode 100644 index 0000000..d815852 --- /dev/null +++ b/.github/workflows/reusable-phpstan-public.yml @@ -0,0 +1,56 @@ +name: Run PHPStan + +on: + workflow_call: + inputs: + php-version: + description: 'PHP version to use' + required: true + type: string + +permissions: {} + +jobs: + phpstan: + name: PHPStan Static Analysis + runs-on: ubuntu-24.04 + timeout-minutes: 20 + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Set up PHP + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 + with: + php-version: ${{ inputs.php-version }} + coverage: none + tools: cs2pr + + # This date is used to ensure that the PHPStan cache is cleared at least once every week. + - name: "Get last Monday's date" + id: get-date + run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> "$GITHUB_OUTPUT" + + - name: Cache PHPStan scan cache + uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + with: + path: tests/_output + key: phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }} + + - name: Install Composer dependencies + uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3.2.0 + + - name: Run PHPStan + id: phpstan + run: composer run-script phpstan -- --memory-limit=1G --error-format=checkstyle | cs2pr + + - name: Save result cache + uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + if: ${{ !cancelled() }} + with: + path: tests/_output + key: phpstan-result-cache-${{ runner.os }}-date-${{ steps.get-date.outputs.date }} diff --git a/.github/workflows/reusable-phpunit-public.yml b/.github/workflows/reusable-phpunit-public.yml new file mode 100644 index 0000000..2a990ba --- /dev/null +++ b/.github/workflows/reusable-phpunit-public.yml @@ -0,0 +1,105 @@ +name: Run PHPUnit Tests + +on: + workflow_call: + inputs: + php-version: + description: 'PHP version to use' + required: true + type: string + wp-version: + description: 'WordPress version (latest, trunk, or X.Y)' + required: false + type: string + default: 'latest' + coverage: + description: 'Enable code coverage' + required: false + type: boolean + default: false + multisite: + description: 'Run multisite tests' + required: false + type: boolean + default: false + +permissions: {} + +jobs: + phpunit: + name: PHPUnit (PHP ${{ inputs.php-version }}, WP ${{ inputs.wp-version }})${{ inputs.coverage && ' with coverage' || '' }}${{ inputs.multisite && ' multisite' || '' }} + runs-on: ubuntu-24.04 + timeout-minutes: 20 + env: + WP_ENV_PHP_VERSION: ${{ inputs.php-version }} + WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} + + steps: + - name: Configure environment variables + run: | + echo "PHP_FPM_UID=$(id -u)" >> "$GITHUB_ENV" + echo "PHP_FPM_GID=$(id -g)" >> "$GITHUB_ENV" + + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + show-progress: ${{ runner.debug == '1' && 'true' || 'false' }} + persist-credentials: false + + - name: Set up PHP + uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.36.0 + with: + php-version: ${{ inputs.php-version }} + coverage: ${{ inputs.coverage && 'xdebug' || 'none' }} + + - name: Install Composer dependencies + uses: ramsey/composer-install@a35c6ebd3d08125aaf8852dff361e686a1a67947 # v3.2.0 + + - name: Setup Node.js + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install npm dependencies + run: npm ci + + - name: Build development assets + run: npm run build:dev + + - name: Start the Docker testing environment + uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 + with: + timeout_minutes: 10 + max_attempts: 3 + command: | + if [ "${{ inputs.coverage }}" == "true" ]; then + npm run wp-env:test start -- --xdebug=coverage + else + npm run wp-env:test start + fi + + - name: Log versions + run: | + npm run wp-env:test -- run cli php -- -v + npm run wp-env:test -- run cli wp core version + + - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} + run: npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }} + + - name: Upload code coverage report + if: ${{ inputs.coverage }} + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: tests/_output/php-coverage.xml + flags: unit + fail_ci_if_error: false + + - name: Upload HTML coverage report as artifact + if: ${{ inputs.coverage }} + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: wp-code-coverage-${{ inputs.php-version }}-${{ inputs.wp-version }} + path: tests/_output/html + overwrite: true diff --git a/.github/workflows/reusable-wp-playground-pr-preview-public.yml b/.github/workflows/reusable-wp-playground-pr-preview-public.yml new file mode 100644 index 0000000..e25a1b1 --- /dev/null +++ b/.github/workflows/reusable-wp-playground-pr-preview-public.yml @@ -0,0 +1,123 @@ +name: Run WordPress Playground PR Preview + +on: + workflow_call: + inputs: + run-id: + description: 'The workflow run ID to download artifacts from' + required: true + type: string + artifact-prefix: + description: 'Prefix for the artifact name (e.g., plugin-skeleton-d-pr)' + required: false + type: string + default: 'plugin-skeleton-d-pr' + artifact-filename: + description: 'Filename of the zip inside the artifact' + required: false + type: string + default: 'plugin-skeleton-d.zip' + artifacts-to-keep: + description: 'Number of artifacts to keep per PR' + required: false + type: string + default: '2' + +permissions: {} + +jobs: + playground-preview: + name: Post Playground Preview + runs-on: ubuntu-24.04 + permissions: + actions: read + contents: write + pull-requests: write + + steps: + - name: Extract PR metadata and artifact info + id: pr-metadata + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + with: + script: | + const prefix = '${{ inputs.artifact-prefix }}'; + + const run = await github.rest.actions.getWorkflowRun({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ inputs.run-id }}, + }); + + const pulls = run.data.pull_requests; + if (!pulls || pulls.length === 0) { + core.setFailed('No pull request found in workflow_run'); + return; + } + const prNumber = pulls[0].number; + const commitSha = run.data.head_sha; + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ inputs.run-id }}, + }); + + const artifact = artifacts.data.artifacts.find(a => + a.name.startsWith(prefix) + ); + + if (!artifact) { + core.setFailed(`Could not find artifact with prefix: ${prefix}`); + return; + } + + core.setOutput('pr-number', prNumber.toString()); + core.setOutput('commit-sha', commitSha); + core.setOutput('artifact-name', artifact.name); + + - name: Expose built artifact on public URL + id: expose + uses: WordPress/action-wp-playground-pr-preview/.github/actions/expose-artifact-on-public-url@c8607529dac8d2bf9a1e8493865fc97cd1c3c87b # v2 + with: + artifact-name: ${{ steps.pr-metadata.outputs.artifact-name }} + artifact-filename: ${{ inputs.artifact-filename }} + pr-number: ${{ steps.pr-metadata.outputs.pr-number }} + commit-sha: ${{ steps.pr-metadata.outputs.commit-sha }} + artifact-source-run-id: ${{ inputs.run-id }} + artifacts-to-keep: ${{ inputs.artifacts-to-keep }} + + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + sparse-checkout: blueprint.json + sparse-checkout-cone-mode: false + + - name: Generate Playground blueprint JSON + id: blueprint + run: | + node - <<'NODE' >> "$GITHUB_OUTPUT" + const fs = require('fs'); + const url = process.env.ARTIFACT_URL; + if (!url) { + throw new Error('ARTIFACT_URL is required'); + } + + // Load the base blueprint and update the plugin URL + const blueprint = JSON.parse(fs.readFileSync('blueprint.json', 'utf8')); + const installStep = blueprint.steps.find(s => s.step === 'installPlugin'); + if (installStep) { + installStep.pluginData.url = url; + } + + console.log(`blueprint=${JSON.stringify(blueprint)}`); + NODE + env: + ARTIFACT_URL: ${{ steps.expose.outputs.artifact-url }} + + - name: Post Playground preview button + uses: WordPress/action-wp-playground-pr-preview@c8607529dac8d2bf9a1e8493865fc97cd1c3c87b # v2 + with: + mode: append-to-description + blueprint: ${{ steps.blueprint.outputs.blueprint }} + pr-number: ${{ steps.pr-metadata.outputs.pr-number }} + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml new file mode 100644 index 0000000..2570801 --- /dev/null +++ b/.github/workflows/test-public-workflows.yml @@ -0,0 +1,174 @@ +# These are used by the repository to test the GitHub workflows for the repository. +# Projects using the skeleton should remove this file, and updated the `ci.yml` workflow +name: CI (Public Workflows) + +on: + push: + branches: + - main + pull_request: + branches: + - main + - release/** + types: [opened, synchronize, reopened, ready_for_review] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + detect: + name: Detect Changes + runs-on: ubuntu-24.04 + if: github.event_name != 'pull_request' || github.event.pull_request.draft == false + permissions: + contents: read + pull-requests: read + outputs: + php: ${{ steps.filter.outputs.php }} + phpcs: ${{ steps.filter.outputs.phpcs }} + phpstan: ${{ steps.filter.outputs.phpstan }} + phpunit: ${{ steps.filter.outputs.phpunit }} + js: ${{ steps.filter.outputs.js }} + css: ${{ steps.filter.outputs.css }} + e2e: ${{ steps.filter.outputs.e2e }} + jest: ${{ steps.filter.outputs.jest }} + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Detect file changes + uses: dorny/paths-filter@9d7afb8d214ad99e78fbd4247752c4caed2b6e4c # v4.0.0 + id: filter + with: + filters: | + php: + - 'composer.*' + phpcs: + - '.phpcs.xml.dist' + - '.github/workflows/reusable-phpcs-public.yml' + phpstan: + - 'phpstan.neon.dist' + - '.github/workflows/reusable-phpstan-public.yml' + phpunit: + - 'phpunit.xml.dist' + - '.github/workflows/reusable-phpunit-public.yml' + - 'package*.json' + js: + - '.eslintrc.js' + - '.nvmrc' + - '.prettierrc.js' + - 'package*.json' + - '.eslintrc*' + - 'tsconfig*.json' + css: + - '.stylelintignore' + - '.stylelint.config.js*' + e2e: + - 'playwright.config.ts' + - '.github/workflows/reusable-e2e-public.yml' + jest: + - 'jest.config.js' + - '.github/workflows/reusable-jest-public.yml' + - 'package*.json' + + phpcs: + name: PHPCS + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpcs == 'true' + uses: ./.github/workflows/reusable-phpcs-public.yml + permissions: + contents: read + with: + php-version: '8.2' + + phpstan: + name: PHPStan + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpstan == 'true' + uses: ./.github/workflows/reusable-phpstan-public.yml + permissions: + contents: read + with: + php-version: '8.2' + + lint-css-js: + name: CSS/JS Lint + needs: detect + if: needs.detect.outputs.css == 'true' || needs.detect.outputs.js == 'true' + uses: ./.github/workflows/reusable-lint-css-js.yml + permissions: + contents: read + + jest: + name: Jest Unit Tests + needs: detect + if: needs.detect.outputs.js == 'true' || needs.detect.outputs.jest == 'true' + uses: ./.github/workflows/reusable-jest.yml + permissions: + contents: read + with: + coverage: true + + phpunit: + name: PHPUnit (PHP ${{ matrix.php }}, WP ${{ matrix.wp }}) + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.phpunit == 'true' + uses: ./.github/workflows/reusable-phpunit.yml + permissions: + contents: read + strategy: + fail-fast: false + matrix: + php: ['8.4'] + wp: ['latest'] + include: + - php: '8.4' + wp: 'latest' + coverage: true + with: + php-version: ${{ matrix.php }} + wp-version: ${{ matrix.wp }} + coverage: ${{ matrix.coverage == true }} + secrets: inherit + + e2e: + name: E2E Tests + needs: detect + if: needs.detect.outputs.php == 'true' || needs.detect.outputs.e2e == 'true' || needs.detect.outputs.js == 'true' || needs.detect.outputs.css == 'true' + uses: ./.github/workflows/reusable-e2e-public.yml + permissions: + contents: read + with: + php-version: '8.2' + + build-plugin-zip: + name: Build Plugin Zip + permissions: + contents: read + uses: ./.github/workflows/reusable-build-public.yml + with: + php-version: '8.2' + artifact-name: plugin-skeleton-d-pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} + secrets: inherit + + playground-preview: + name: Playground Preview + needs: build-plugin-zip + if: github.event_name == 'pull_request' + uses: ./.github/workflows/reusable-wp-playground-pr-preview-public.yml + permissions: + actions: read + contents: write + pull-requests: write + with: + run-id: ${{ github.run_id }}-public + artifact-prefix: 'plugin-skeleton-d-pr-public' + artifact-filename: 'plugin-skeleton-d.zip' From ae8ebf8094b21399cf4739d5f8395c361c85ba67 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Thu, 19 Mar 2026 23:11:29 +0200 Subject: [PATCH 32/38] ci: Remove unnecessary release-public.yml --- .github/workflows/release-public.yml | 58 ---------------------------- 1 file changed, 58 deletions(-) delete mode 100644 .github/workflows/release-public.yml diff --git a/.github/workflows/release-public.yml b/.github/workflows/release-public.yml deleted file mode 100644 index ec49e04..0000000 --- a/.github/workflows/release-public.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Release - -on: - push: - branches: - - main - workflow_dispatch: - -permissions: - contents: write - issues: write - pull-requests: write - -jobs: - release-please: - name: Release Please - runs-on: ubuntu-24.04 - outputs: - release_created: ${{ steps.release.outputs.release_created }} - tag_name: ${{ steps.release.outputs.tag_name }} - steps: - - name: Prepare release - id: release - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 - with: - token: ${{ secrets.GITHUB_TOKEN }} - config-file: release-please-config.json - manifest-file: .release-please-manifest.json - - build: - permissions: - contents: read - needs: release-please - if: ${{ needs.release-please.outputs.release_created }} - uses: ./.github/workflows/reusable-build.yml - with: - php-version: '8.2' - artifact-name: plugin-skeleton-d - secrets: inherit - - upload: - name: Upload release asset - needs: [release-please, build] - runs-on: ubuntu-24.04 - timeout-minutes: 10 - permissions: - contents: write - steps: - - name: Download artifact - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 - with: - name: plugin-skeleton-d - path: . - - - name: Upload release asset - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh release upload ${{ needs.release-please.outputs.tag_name }} plugin-skeleton-d.zip --clobber From 4ba109a2a3478716f7ce76eb86e27d8899a4c3e8 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Thu, 19 Mar 2026 23:29:32 +0200 Subject: [PATCH 33/38] ci: docs and cleanup --- .github/workflows/README.md | 40 +++++++++---------- ...usable-wp-playground-pr-preview-public.yml | 4 +- .../reusable-wp-playground-pr-preview.yml | 4 +- .github/workflows/test-public-workflows.yml | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/README.md b/.github/workflows/README.md index 950486c..38cdfa3 100644 --- a/.github/workflows/README.md +++ b/.github/workflows/README.md @@ -6,26 +6,28 @@ Workflows are defined to be reusable and modular. Main CI pipeline used to validate code. Based on file changes it calls the following reusable workflows: -| Reusable Workflow | What | -| --------------------------------------- | ----------------------------------------- | -| `reusable-phpcs.yml` | PHPCS linting | -| `reusable-phpstan.yml` | PHPStan static analysis | -| `reusable-phpunit.yml` | PHPUnit tests | -| `reusable-lint-css-js.yml` | ESlint, Stylelint, Prettier, tsc linting | -| `reusable-jest.yml` | Jest tests | -| `reusable-e2e.yml` | Playwright end-to-end tests | -| `reusable-build.yml` | Creates a build zip (used by playground) | -| `reusable-wp-playground-pr-preview.yml` | PR preview environment with wp-playground | - -### `copilot-setup-steps.yml` +| Reusable Workflow | What | +| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | +| [`reusable-phpcs.yml`](.reusable-phpcs.yml)
[`reusable-phpcs-public.yml`](.reusable-phpcs-public.yml) | PHPCS linting | +| [`reusable-phpstan.yml`](.reusable-phpstan.yml)
[`reusable-phpstan-public.yml`](.reusable-phpstan-public.yml) | PHPStan static analysis | +| [`reusable-phpunit.yml`](.reusable-phpunit.yml)
[`reusable-phpunit-public.yml`](.reusable-phpunit-public.yml) | PHPUnit tests | +| [`reusable-lint-css-js.yml`](.reusable-lint-css-js.yml)
[`reusable-lint-css-js-public.yml`](.reusable-lint-css-js-public.yml) | ESlint, Stylelint, Prettier, tsc linting | +| [`reusable-jest.yml`](.reusable-jest.yml)
[`reusable-jest-public.yml`](.reusable-jest-public.yml) | Jest tests | +| [`reusable-e2e.yml`](.reusable-e2e.yml)
[`reusable-e2e-public.yml`](.reusable-e2e-public.yml) | Playwright end-to-end tests | +| [`reusable-build.yml`](.reusable-build.yml)
[`reusable-build-public.yml`](.reusable-build-public.yml) | Creates a build zip (used by playground) | +| [`reusable-wp-playground-pr-preview.yml`](.reusable-wp-playground-pr-preview.yml)
[`reusable-wp-playground-pr-preview-public.yml`](.reusable-wp-playground-pr-preview-public.yml) | PR preview environment with wp-playground | + +Reusable workflows have a `-public` variant which is used for public GitHub runners. The non-public variants are used for rtCamp's private runners. Ensure that `ci.yml` points to the correct workflows you need, and delete the others. + +### [`copilot-setup-steps.yml`](copilot-setup-steps.yml) Sets up dev environment for GitHub Copilot coding agent. -### `pr-title.yml` +### [`pr-title.yml`](pr-title.yml) Triggers on PRs. Validates [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) format, required for release-please automation. -### `release.yml` +### [`release.yml`](release.yml) Triggers on push to `main`. Uses [release-please](https://github.com/googleapis/release-please) to automate releases based on conventional commits. @@ -38,9 +40,9 @@ When a release is created, it builds the plugin via `reusable-build.yml` and upl ### Secrets -| Secret | Required By | Notes | -| --------------- | ------------------------------------------- | ---------------------------------------------------- | -| `CODECOV_TOKEN` | `reusable-phpunit.yml`, `reusable-jest.yml` | Optional — coverage uploads fail silently without it | +| Secret | Required By | Notes | +| --------------- | -------------------------------------------------------------- | ---------------------------------------------------- | +| `CODECOV_TOKEN` | `reusable-phpunit-public.yml`
`reusable-jest-public.yml` | Optional — coverage uploads fail silently without it | ### PR Previews @@ -72,7 +74,3 @@ act workflow_dispatch \ -s GITHUB_TOKEN=your_github_token_here \ -P ubuntu-24.04=catthehacker/ubuntu:act-latest ``` - -## Private Runners - -@todo diff --git a/.github/workflows/reusable-wp-playground-pr-preview-public.yml b/.github/workflows/reusable-wp-playground-pr-preview-public.yml index e25a1b1..45e87bf 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview-public.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview-public.yml @@ -45,7 +45,7 @@ jobs: const run = await github.rest.actions.getWorkflowRun({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, + run_id: '${{ inputs.run-id }}', }); const pulls = run.data.pull_requests; @@ -59,7 +59,7 @@ jobs: const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, + run_id: '${{ inputs.run-id }}', }); const artifact = artifacts.data.artifacts.find(a => diff --git a/.github/workflows/reusable-wp-playground-pr-preview.yml b/.github/workflows/reusable-wp-playground-pr-preview.yml index 627ea10..c96e93e 100644 --- a/.github/workflows/reusable-wp-playground-pr-preview.yml +++ b/.github/workflows/reusable-wp-playground-pr-preview.yml @@ -57,7 +57,7 @@ jobs: const run = await github.rest.actions.getWorkflowRun({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, + run_id: '${{ inputs.run-id }}', }); const pulls = run.data.pull_requests; @@ -71,7 +71,7 @@ jobs: const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ owner: context.repo.owner, repo: context.repo.repo, - run_id: ${{ inputs.run-id }}, + run_id: '${{ inputs.run-id }}', }); const artifact = artifacts.data.artifacts.find(a => diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml index 2570801..0a1021f 100644 --- a/.github/workflows/test-public-workflows.yml +++ b/.github/workflows/test-public-workflows.yml @@ -156,7 +156,7 @@ jobs: uses: ./.github/workflows/reusable-build-public.yml with: php-version: '8.2' - artifact-name: plugin-skeleton-d-pr${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} + artifact-name: plugin-skeleton-d-pr-public${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} secrets: inherit playground-preview: From b33e5231cf52a48686e65c95ffea7f2b2d904a72 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Thu, 19 Mar 2026 23:37:54 +0200 Subject: [PATCH 34/38] ci: Fix run id --- .github/workflows/test-public-workflows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml index 0a1021f..76422b8 100644 --- a/.github/workflows/test-public-workflows.yml +++ b/.github/workflows/test-public-workflows.yml @@ -169,6 +169,6 @@ jobs: contents: write pull-requests: write with: - run-id: ${{ github.run_id }}-public + run-id: ${{ github.run_id }} artifact-prefix: 'plugin-skeleton-d-pr-public' artifact-filename: 'plugin-skeleton-d.zip' From c2a226fc7e0736bb8faaad2074e0e4df2d531b3d Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Thu, 19 Mar 2026 23:48:25 +0200 Subject: [PATCH 35/38] ci: trigger on workflow changes --- .github/workflows/ci.yml | 25 +++++++++++++++------ .github/workflows/test-public-workflows.yml | 17 +++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85fe1c2..9fe83f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,17 +53,24 @@ jobs: - '**.php' - 'composer.*' phpcs: - - '.phpcs.xml.dist' + - '.github/workflows/ci.yml' - '.github/workflows/reusable-phpcs.yml' + - '.phpcs.xml.dist' phpstan: - - 'phpstan.neon.dist' + - '.github/workflows/ci.yml' - '.github/workflows/reusable-phpstan.yml' + - 'phpstan.neon.dist' phpunit: + - '.github/workflows/ci.yml' + - '.github/workflows/reusable-phpunit.yml' - 'tests/**/*.php' - 'phpunit.xml.dist' - - '.github/workflows/reusable-phpunit.yml' - 'package*.json' + - '.wp-env.test.json' js: + - '.github/workflows/ci.yml' + - '.github/workflows/reusable-lint-css-js.yml' + - '.nvmrc' - '**.cjs' - '**.js' - '**.jsx' @@ -73,18 +80,22 @@ jobs: - '**.ts' - '**.tsx' - 'package*.json' - - '.eslintrc*' - 'tsconfig*.json' css: - '**.css' - '**.scss' + - '.editorconfig' + - '.browserslistrc' - '.stylelintignore' - - '.stylelint.config.js*' + - '.stylelint.config.js' e2e: + - '.github/workflows/ci.yml' + - '.github/workflows/reusable-e2e.yml' - 'tests/e2e/**/*' - 'playwright.config.ts' - - '.github/workflows/reusable-e2e.yml' jest: + - '.github/workflows/ci.yml' + - '.github/workflows/reusable-jest.yml' - 'tests/js/**/*' - 'src/**/__tests__/**/*' - 'src/**/*.test.ts' @@ -92,8 +103,8 @@ jobs: - 'src/**/*.spec.ts' - 'src/**/*.spec.tsx' - 'jest.config.js' - - '.github/workflows/reusable-jest.yml' - 'package*.json' + - '.wp-env.test.json' phpcs: name: PHPCS diff --git a/.github/workflows/test-public-workflows.yml b/.github/workflows/test-public-workflows.yml index 76422b8..f6adb4e 100644 --- a/.github/workflows/test-public-workflows.yml +++ b/.github/workflows/test-public-workflows.yml @@ -52,16 +52,21 @@ jobs: php: - 'composer.*' phpcs: - - '.phpcs.xml.dist' - '.github/workflows/reusable-phpcs-public.yml' + - '.github/workflows/test-public-workflows.yml' + - '.phpcs.xml.dist' phpstan: - - 'phpstan.neon.dist' - '.github/workflows/reusable-phpstan-public.yml' + - '.github/workflows/test-public-workflows.yml' + - 'phpstan.neon.dist' phpunit: - - 'phpunit.xml.dist' - '.github/workflows/reusable-phpunit-public.yml' + - '.github/workflows/test-public-workflows.yml' + - 'phpunit.xml.dist' - 'package*.json' js: + - '.github/workflows/reusable-lint-css-js-public.yml' + - '.github/workflows/test-public-workflows.yml' - '.eslintrc.js' - '.nvmrc' - '.prettierrc.js' @@ -72,11 +77,13 @@ jobs: - '.stylelintignore' - '.stylelint.config.js*' e2e: - - 'playwright.config.ts' - '.github/workflows/reusable-e2e-public.yml' + - '.github/workflows/test-public-workflows.yml' + - 'playwright.config.ts' jest: - - 'jest.config.js' - '.github/workflows/reusable-jest-public.yml' + - '.github/workflows/test-public-workflows.yml' + - 'jest.config.js' - 'package*.json' phpcs: From 3e80ff6e9b21dcff8d3bc1e48d245460e646b69e Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Fri, 20 Mar 2026 00:37:38 +0200 Subject: [PATCH 36/38] ci: stop using TESTS_PORT (first pass) --- .github/workflows/reusable-build.yml | 3 +-- .github/workflows/reusable-e2e-public.yml | 2 +- .github/workflows/reusable-e2e.yml | 5 ++--- .github/workflows/reusable-phpunit.yml | 7 +++---- .wp-env.test.json | 3 ++- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index 5a24391..5bf8041 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -21,7 +21,6 @@ jobs: env: WP_ENV_PORT: 8889 - WP_ENV_TESTS_PORT: 8891 WP_ENV_HOME: /tmp/wp-env timeout-minutes: 30 @@ -106,7 +105,7 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env start -- --update - name: Generate Translation files run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run i18n:make-pot diff --git a/.github/workflows/reusable-e2e-public.yml b/.github/workflows/reusable-e2e-public.yml index e5dce7d..1f4637c 100644 --- a/.github/workflows/reusable-e2e-public.yml +++ b/.github/workflows/reusable-e2e-public.yml @@ -49,7 +49,7 @@ jobs: with: timeout_minutes: 10 max_attempts: 3 - command: WP_ENV_PORT=8889 WP_ENV_TESTS_PORT=8891 npm run wp-env:test start + command: npm run wp-env:test start - name: Run E2E tests run: npm run test:e2e diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 320c05f..838ebc4 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -25,7 +25,6 @@ jobs: env: WP_ENV_PORT: 8889 - WP_ENV_TESTS_PORT: 8891 WP_ENV_HOME: /tmp/wp-env PLAYWRIGHT_BROWSERS_PATH: /tmp/playwright-cache @@ -109,11 +108,11 @@ jobs: with: timeout_minutes: 15 max_attempts: 3 - command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update + command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --update - name: Activate plugin run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - name: Install Playwright dependencies run: | diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 46793db..2da04e5 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -40,7 +40,6 @@ jobs: WP_ENV_PHP_VERSION: ${{ inputs.php-version }} WP_ENV_CORE: ${{ inputs.wp-version == 'trunk' && 'WordPress/WordPress' || format('https://wordpress.org/wordpress-{0}.zip', inputs.wp-version) }} WP_ENV_PORT: 8889 - WP_ENV_TESTS_PORT: 8891 WP_ENV_HOME: /tmp/wp-env steps: @@ -129,10 +128,10 @@ jobs: max_attempts: 3 command: | if [ "${{ inputs.coverage }}" == "true" ]; then - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run wp-env:test start -- --update - fi + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --update + fi` - name: Activate plugin run: | diff --git a/.wp-env.test.json b/.wp-env.test.json index c986167..dc3871c 100644 --- a/.wp-env.test.json +++ b/.wp-env.test.json @@ -1,7 +1,8 @@ { "$schema": "https://schemas.wp.org/trunk/wp-env.json", "core": null, - "testsEnvironment": true, + "port": 8889, + "testsEnvironment": false, "plugins": [ "." ], "config": { "FS_METHOD": "direct", From 368222d808cb55ce33f2099b36f58fb136e14376 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Fri, 20 Mar 2026 01:28:51 +0200 Subject: [PATCH 37/38] ci: remove activate plugin step --- .github/workflows/reusable-e2e.yml | 4 ---- .github/workflows/reusable-phpunit.yml | 7 +------ 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/reusable-e2e.yml b/.github/workflows/reusable-e2e.yml index 838ebc4..546a8d5 100644 --- a/.github/workflows/reusable-e2e.yml +++ b/.github/workflows/reusable-e2e.yml @@ -110,10 +110,6 @@ jobs: max_attempts: 3 command: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --update - - name: Activate plugin - run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - - name: Install Playwright dependencies run: | npx playwright install-deps diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index 2da04e5..b680181 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -131,12 +131,7 @@ jobs: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --xdebug=coverage --update --debug else sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" npm run wp-env:test start -- --update - fi` - - - name: Activate plugin - run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run cli -- wp plugin activate plugin-skeleton-d - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test run tests-cli -- wp plugin activate plugin-skeleton-d + fi - name: Log versions run: | From 116073bf9963c3d9430a4ba89b1a35d2e7a59a30 Mon Sep 17 00:00:00 2001 From: Dovid Levine Date: Fri, 20 Mar 2026 02:19:58 +0200 Subject: [PATCH 38/38] ci: more wp-env 11 fixes --- .github/workflows/reusable-phpunit.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-phpunit.yml b/.github/workflows/reusable-phpunit.yml index b680181..1977809 100644 --- a/.github/workflows/reusable-phpunit.yml +++ b/.github/workflows/reusable-phpunit.yml @@ -135,8 +135,8 @@ jobs: - name: Log versions run: | - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli php -- -v - sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run tests-cli wp core version + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run cli php -- -v + sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" npm run wp-env:test -- run cli wp core version - name: Run PHPUnit tests${{ inputs.coverage && ' with coverage report' || '' }} run: sudo -u wpuser env "PATH=$PATH" "WP_ENV_HOME=$WP_ENV_HOME" "WP_ENV_PORT=$WP_ENV_PORT" "WP_ENV_TESTS_PORT=$WP_ENV_TESTS_PORT" npm run test:php ${{ !inputs.coverage && '-- --no-coverage' || '' }}