Repository navigation
Conversation
…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.
larodiel
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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'sstrategy.matrix. With the defaultcountof 3 that is["7.1.5","7.0.9","6.9.12"]today. Each version goes to setup-slic's existingwp-versioninput, 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: asksapi.wordpress.org/core/version-check/1.7/, keeps the highest patch of each X.Y, skips betas and RCs, and returns the newestcountreleases. It runs on github-script like the other toolbox actions, so there's nothing to build.permissions: {}, since it needs no token.@v1, not@main.countexpression for workflows that only want the full matrix on some runs (for example, only on PRs intomain). The default is 3 on every run.test.ymlgets awp-test-matrixjob 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.Using it
Testing
node --test: all tests pass, 14 of them new intests/actions/wp-test-matrix/. They cover the count input, duplicates, order,7.10above7.9, betas and RCs, retries, and failing when too few releases come back.test.ymluses: clean.["7.1.5","7.0.9","6.9.12"].wp-test-matrixjobs on this PR run it on a real runner and fan out one job per version.Summary by CodeRabbit