Skip to content

[SOFT-4410] Add wp-test-matrix: the newest WordPress releases for a test matrix - #42

Open
sdokus wants to merge 2 commits into
mainfrom
soft-4410-wp-version-matrix
Open

sdokus wants to merge 2 commits into
mainfrom
soft-4410-wp-version-matrix

Conversation

@sdokus

@sdokus sdokus commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Related

Part of SOFT-4410, under SOFT-4409. Also part of SOFT-4411, SOFT-4412, SOFT-4413, SOFT-4414 and SOFT-4415.

Summary

Adds wp-test-matrix, an action that lists the newest WordPress X.Y releases, each at its latest patch, as a JSON array for a test workflow's strategy.matrix. With the default count of 3 that is ["7.1.5","7.0.9","6.9.12"] today. Each version goes to setup-slic's existing wp-version input, so the suites run once per release.

Why

Plugin test workflows usually pin one WordPress version (wp core update --force --version=6.8), so a break in a new WordPress release shows up in support before it shows up in CI. Testing against the latest few releases catches it first. The version lookup is the same for every plugin, so it lives here for any brand to use.

Change

  • wp-test-matrix: asks api.wordpress.org/core/version-check/1.7/, keeps the highest patch of each X.Y, skips betas and RCs, and returns the newest count releases. It runs on github-script like the other toolbox actions, so there's nothing to build.
  • How it behaves:
    • It groups by X.Y and keeps the highest patch, so duplicates or a different order in the answer change nothing.
    • Three attempts with a 10s timeout each. Fewer releases offered than asked for fails the step instead of quietly shrinking the matrix.
    • The README example gives the job permissions: {}, since it needs no token.
    • Consumers pin @v1, not @main.
    • The README shows a count expression for workflows that only want the full matrix on some runs (for example, only on PRs into main). The default is 3 on every run.
  • test.yml gets a wp-test-matrix job that runs the action against the real endpoint and fans a matrix out from its output, so a change in WordPress.org's answer fails here first.
  • README: the action is listed under composite actions, in the Slic section, and ticked in Phase 2.

Using it

jobs:
  wp-versions:
    runs-on: ubuntu-latest
    permissions: {}
    outputs:
      versions: ${{ steps.matrix.outputs.versions }}
    steps:
      - id: matrix
        uses: stellarwp/plugin-toolbox/.github/actions/wp-test-matrix@v1

  test:
    needs: wp-versions
    name: ${{ matrix.suite }} (WP ${{ matrix.wp }})
    strategy:
      fail-fast: false
      matrix:
        suite: [unit, wpunit]
        wp: ${{ fromJSON(needs.wp-versions.outputs.versions) }}
    # setup-slic: wp-version: ${{ matrix.wp }}

Testing

  • node --test: all tests pass, 14 of them new in tests/actions/wp-test-matrix/. They cover the count input, duplicates, order, 7.10 above 7.9, betas and RCs, retries, and failing when too few releases come back.
  • actionlint 1.7.12 with the flags test.yml uses: clean.
  • Ran the action locally against the live endpoint: ["7.1.5","7.0.9","6.9.12"].
  • The wp-test-matrix jobs on this PR run it on a real runner and fan out one job per version.

Summary by CodeRabbit

  • New Features
    • Added a WordPress test matrix action that selects the latest patch release from each eligible WordPress version branch and provides the results as a JSON list. The number of versions can be configured.
    • Added workflow support for running tests against each selected version, with checks for valid version formats.
  • Bug Fixes
    • Added retries for temporary WordPress version lookup failures; the workflow reports an error if the requested number of versions is unavailable.
  • Documentation
    • Added guidance on configuring and using the action in workflows.

…T-4410]

- Why: plugin test workflows pin one WordPress version, so a regression in a
  new WordPress release reaches support before CI. The six TEC repo PRs for
  SOFT-4410 to SOFT-4415 each wired the same lookup in by hand.
- What: a github-script action that lists the newest X.Y releases from the
  WordPress.org version check, each at its latest patch, as a JSON array for
  strategy.matrix. count picks how many (default 3); fewer offered fails.
  Unit tests, a live job in test.yml, README entries.
- Impact: any plugin feeds the output into its matrix and passes each
  version to setup-slic's wp-version; new WordPress releases rotate in
  without editing a workflow.
@linear

linear Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The new composite action selects recent WordPress releases and exposes them as a JSON output. A workflow uses that output as a matrix and validates each version. Documentation and tests cover the action and its integration.

Changes: WordPress test matrix

Layer / File(s) Summary
Action contract and version selection
.github/actions/wp-test-matrix/action.yml, .github/actions/wp-test-matrix/wp-test-matrix.js, tests/actions/wp-test-matrix/wp-test-matrix.test.js, .github/actions/wp-test-matrix/README.md
The action accepts a count and outputs selected full WordPress versions as JSON. Its script validates the count, retries requests, selects the highest patch per X.Y branch, and fails when fewer releases are available than requested. Tests cover selection, errors, retries, and output. The action README documents its inputs, output, and usage.
Workflow matrix integration
.github/workflows/test.yml, README.md
The test workflow runs the action and uses its output to create version-specific matrix legs. Each leg validates its WordPress version. The repository README documents the action in Slic instructions and the composite-action inventory.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as GitHub Actions workflow
  participant Action as wp-test-matrix action
  participant Script as wp-test-matrix.js
  participant WordPress as WordPress.org
  participant Leg as wp-test-matrix-leg
  Workflow->>Action: Run local action with count
  Action->>Script: Invoke runWpTestMatrix
  Script->>WordPress: Request version offers
  WordPress-->>Script: Return offers
  Script-->>Action: Write versions JSON output
  Action-->>Workflow: Publish versions output
  Workflow->>Leg: Expand matrix with versions
  Leg->>Leg: Validate each version
Loading

Suggested labels: enhancement

Suggested reviewers: larodiel, pauloiankoski, d4mation

Merge Risk: Minimal · up to 1a86e

This adds a new opt-in action that returns the newest WordPress releases for a test matrix, plus tests and docs. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: adding the wp-test-matrix action, which returns the newest WordPress releases for a test matrix. The changeset adds the action (action.yml, wp-test-matrix.js, README),…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: adding the wp-test-matrix action, which returns the newest WordPress releases for a test matrix. The changeset adds the action (action.yml, wp-test-matrix.js, README), a test-matrix job in test.yml, a README entry, and tests. The ticket prefix [SOFT-4410] is extra context and does not affect the match.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 0d776512-8f76-4742-8f9c-059cd3859154
Commits

Reviewing files that changed from the base of the PR and between 8b45c66 and 1a86eef.

Files selected for processing: 3

  • .github/actions/wp-test-matrix/README.md
  • .github/actions/wp-test-matrix/wp-test-matrix.js
  • tests/actions/wp-test-matrix/wp-test-matrix.test.js
Files skipped from review as they are similar to previous changes: 1

  • .github/actions/wp-test-matrix/README.md

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.

@larodiel larodiel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small change on the retries, then this is good to go from my side.

const body = await response.json()
return Array.isArray(body?.offers) ? body.offers : []
} catch (error) {
lastError = error

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a request fails, the next attempt starts right away. If api.wordpress.org has a short hiccup, all three attempts can fail within the same second, so the retries don't really help. The TEC version got a pause for free from curl --retry, which waits longer between each try.

Could we wait a little before trying again? Something like this would do:

} catch (error) {
  lastError = error
  if (attempt < ATTEMPTS) {
    await new Promise((resolve) => setTimeout(resolve, attempt * 2000))
  }
}

That waits 2s, then 4s. The test for retries can pass in a shorter wait, or use t.mock.timers, so the suite stays fast.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 1a86eef: a failed attempt now waits 2s, then 4s, and there's no wait after the last one. The tests pass in a recording sleep, so the suite stays fast.

@sdokus
sdokus requested a review from larodiel December 4, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants