Repository navigation
Reduce the need for npm by installing built files from the WordPress mirror - #246
ramonfincken wants to merge 3 commits into
Conversation
…ld as source of truth for CSS and JS files
|
Perhaps I'm missing something. But why can't the test runner just use the https://github.com/WordPress/WordPress repository instead of the nightly? Using the nightly loses a level of fidelity because you can't control which commit is tested. But the WordPress SVN repository is updated by the build server after every commit to wordpress-develop and mirrored here to GitHub. The only challenge there is a search would need to be performed to find the corresponding changeset. |
|
The point is to copy the nightly JS/CSs files, not the PHP ones. But hold on, i will try using another path. |
|
Thanks for your talk at WordCamp by the way :) |
|
Picking this up, thanks Ramon for the first attempt. The original direction here still makes sense, but the implementation needs a different shape now. #246 still runs The alternative desrosj suggested looks viable: the WordPress/WordPress built mirror carries the exact develop revision in each commit message ( Plan: a new opt-in I will push the new approach to this PR, with a same-revision comparison of the npm route and the mirror route. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @ramon@creativepulses.nl. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
# Conflicts: # prepare.php
The test suite runs against src/ of the wordpress-develop checkout, which needs the generated scripts, styles and block assets. Until now the only way to get them was npm install and npm run build:dev, so every host needs Node.js and npm for a PHP test run. With WPT_ASSETS_SOURCE=mirror, prepare.php reads the checked-out revision from the clone, finds the WordPress/WordPress commit built from that revision (every mirror commit names it), downloads that tree and copies the files the checkout ignores into src/. Tracked files stay as checked out. When no mirror commit exists for the revision yet, or the expected files are missing, the npm build runs as before. The default stays npm. Supersedes the approach first tried in this PR, which patched core's Gruntfile and copied the nightly build into build/.
Problem
The test suite runs against
src/of the wordpress-develop checkout, andsrc/only works after the build has written the generated scripts, styles and block assets into it. The only wayprepare.phphad to get them wasnpm install && npm run build:dev, so a host needs Node.js and npm, anode_modulestree and the Gutenberg artifact download fromghcr.ioto run a PHP test suite (#244). The first version of this PR tried to shortcut that by patching core's Gruntfile and copying the nightly's files intobuild/; it keptnpm install, lost the exact revision, andbuild/is no longer where the tests look since #351.Fix
A new opt-in
WPT_ASSETS_SOURCE=mirror.prepare.phpthen:git-svn-id: .../trunk@NNNNN, present in a shallow clone too);Built from https://develop.svn.wordpress.org/trunk@NNNNN(branches map tox.y-branch), about a minute behind develop; the lookup reads the latest 100 commits through the public GitHub API, unauthenticated;src/only the files the checkout ignores (git check-ignore), so tracked files stay exactly as checked out;wp-includes/js/jquery/jquery.js,wp-includes/js/dist/blocks.js,wp-includes/css/dist/block-library/style.css,wp-admin/js/common.js).Any miss (no mirror commit yet, download or copy failure, missing sentinel) logs the reason and runs the npm build as before.
WPT_ASSETS_SOURCE=npm(the default) is unchanged. An unknown value stopsprepare.phpwith a clear error.What changes for hosts
Nothing unless they set
WPT_ASSETS_SOURCE=mirror. With it, a successful run does not touch Node.js or npm: nonode_modules, no Gutenberg download, andprepare.phpfinishes in well under a minute instead of several. When the mirror has no commit for the revision yet, or the download or validation fails, the npm build runs as before, so Node.js and npm stay installed. Documented inREADME.mdand.env.default.Verification
Local, macOS 27 (arm64), PHP 8.5.11, MySQL 26.7.0 (Homebrew), Node 26.10 / npm 11.19, the real runner (
prepare.phpthentest.php), core trunk r64238 (same commit for every run below).WPT_ASSETS_SOURCE=mirrorWPT_ASSETS_SOURCE=npm(default)prepare.php, fresh clone to "Prepared environment"npm install21 s with a warm npm cache +build:dev23 snode_modules804 MBsrc/tinymce.jsis the extra one)The one failure is
Tests_Admin_wpPostsListTable::test_search_hierarchical_pages_first_pageon both routes, a local environment issue unrelated to the built files; the warnings are PHP 8.5 deprecations inside core's tests, identical on both. The junit reports name the same failing test and nothing else.The only file the npm build writes that the mirror does not carry is
src/wp-includes/js/tinymce/tinymce.js(the mirror shipstinymce.min.jsandwp-tinymce.js); nothing intests/phpunit/testsreferences it. The mirror route copied nothing the build does not also write.Also exercised: the revision parser on the checkout (
trunk@64238), on a repository without agit-svn-idline and on a non-repository (null, null); the mirror lookup for a branch (branches/7.1@64164-> the mirror commit built from it) and for a revision that does not exist (null); the fallback with a checkout whose revision the mirror never built, and with the GitHub API unreachable: both return false before touchingsrc/, soprepare.phpcontinues with the npm build.Five full runs in all (four mirror, one npm) on that revision, every one with the same single failure. The first mirror run copied
wp-adminandwp-includesonly and came out four assertions short; adding the bundled themes' minified styles to the copy (two files) closed that gap. The last run used the exact code in this PR: 25944 tests, 4561463 assertions, 1 failure, 86 warnings, 74 skipped, 300 s. Logs, scripts and junit reports are in my notes and can be shared on request.Concurrency: two
prepare.phpruns for the same revision, started together with separate prepare directories, both finished in 23 s with byte-identicalsrc/trees, each in its own temporary work directory (wpt-built-assets-<sha>-<pid>-<random>), nothing left behind. A forced download failure (awgetthat exits 1) returns to the npm path and leaves no temporary directory either.Notes
branches/x.y) map to the mirror'sx.y-branchthe same way.tar,rsyncandwget.Use of AI
AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: investigation, implementation, the proof runs and the PR wording. I reviewed the reasoning and the results and take responsibility for the contribution.