From e2b8fc75727a39152af6c08fba659ec08441730a Mon Sep 17 00:00:00 2001 From: Paulo Iankoski Date: Wed, 2 Dec 2026 10:08:12 -0300 Subject: [PATCH 1/2] plugin-check: add the memory-limit input for plugins too large for the default WP-CLI memory --- .github/actions/plugin-check-report/README.md | 1 + .github/workflows/plugin-check.yml | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.github/actions/plugin-check-report/README.md b/.github/actions/plugin-check-report/README.md index d9ca456e..67c03d10 100644 --- a/.github/actions/plugin-check-report/README.md +++ b/.github/actions/plugin-check-report/README.md @@ -246,6 +246,7 @@ the check to require in branch protection is `plugin-check / Plugin Check`. | `php-version` | `7.4` | PHP that builds `vendor/`. Use the oldest the plugin supports | | `exclude-checks` | empty | Checks to skip, one per line. Replaces `.plugin-check.json` when it names any. See [Excluding checks](#excluding-checks) | | `cache-paths` | empty | Build caches kept between runs, one path per line, relative to the repository | +| `memory-limit` | empty | WordPress memory limit for the check, e.g. `512M` or `1G`. Empty keeps the WordPress default (256M with WP-CLI 3). A large plugin needs more, or Plugin Check stops with "Allowed memory size exhausted" and an empty results file | | `mode` | `baseline` | `baseline` or `strict`. See [Modes](#modes) | | `submodules` | `false` | Passed to `actions/checkout` | | `head-ref` | empty | Manual runs only: the branch, tag or commit to check. Empty checks the ref the run started on. See [Manual runs](#manual-runs) | diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index 1e83440c..b85d7979 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -104,6 +104,14 @@ on: required: false type: string default: '' + memory-limit: + description: >- + WordPress memory limit for the check, e.g. `512M` or `1G`, or `-1` for none. Empty keeps the + WordPress default (256M with WP-CLI 3). A large plugin needs more: Plugin Check stops with + "Allowed memory size exhausted" and the results file is empty. + required: false + type: string + default: '' mode: description: >- `baseline`: fail only when a rule has more errors than the baseline. `strict`: fail on any @@ -529,6 +537,22 @@ jobs: done cat "$RUNNER_TEMP/docker-pull.log" 2>/dev/null || true + # The action writes its own .wp-env.json in the workspace root, so a repository cannot add a + # setting to it. wp-env merges .wp-env.override.json from the same folder over that file, and + # the action does not touch it. WP_MAX_MEMORY_LIMIT is the limit WordPress applies to WP-CLI + # commands that load the admin side, which WP-CLI 3 does. The value is checked first, so only a + # size reaches the JSON. + - name: Set the memory limit + if: ${{ inputs.memory-limit != '' }} + env: + MEMORY_LIMIT: ${{ inputs.memory-limit }} + run: | + if ! [[ "$MEMORY_LIMIT" =~ ^(-1|[0-9]+[KMG])$ ]]; then + echo "::error title=Plugin Check::memory-limit must be a size such as 512M or 1G, or -1: $MEMORY_LIMIT" + exit 1 + fi + echo "{\"config\": {\"WP_MAX_MEMORY_LIMIT\": \"$MEMORY_LIMIT\"}}" > .wp-env.override.json + # Fails on any error, which is expected while a plugin still has known problems: the report # job decides pass or fail from the counts. The action writes its results to # $RUNNER_TEMP/plugin-check-results.txt and uploads them as the plugin-check-results From 0d50205df9d3ee4767506fe7fda9799a0e6ba2ba Mon Sep 17 00:00:00 2001 From: Paulo Iankoski Date: Wed, 2 Dec 2026 10:39:02 -0300 Subject: [PATCH 2/2] plugin-check: remove an earlier run's memory override when memory-limit is empty --- .github/workflows/plugin-check.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin-check.yml b/.github/workflows/plugin-check.yml index b85d7979..3a56de47 100644 --- a/.github/workflows/plugin-check.yml +++ b/.github/workflows/plugin-check.yml @@ -541,12 +541,16 @@ jobs: # setting to it. wp-env merges .wp-env.override.json from the same folder over that file, and # the action does not touch it. WP_MAX_MEMORY_LIMIT is the limit WordPress applies to WP-CLI # commands that load the admin side, which WP-CLI 3 does. The value is checked first, so only a - # size reaches the JSON. + # size reaches the JSON. The step always runs: with no input it removes the file, so a runner + # that keeps its workspace between runs does not carry an earlier run's limit over. - name: Set the memory limit - if: ${{ inputs.memory-limit != '' }} env: MEMORY_LIMIT: ${{ inputs.memory-limit }} run: | + if [ -z "$MEMORY_LIMIT" ]; then + rm -f .wp-env.override.json + exit 0 + fi if ! [[ "$MEMORY_LIMIT" =~ ^(-1|[0-9]+[KMG])$ ]]; then echo "::error title=Plugin Check::memory-limit must be a size such as 512M or 1G, or -1: $MEMORY_LIMIT" exit 1