Skip to content

Build/Test Tools: Check file types in the build directory. - #13706

Open
adimoldovan wants to merge 2 commits into
WordPress:trunkfrom
adimoldovan:65279-check-build-files
Open

adimoldovan wants to merge 2 commits into
WordPress:trunkfrom
adimoldovan:65279-check-build-files

Conversation

@adimoldovan

@adimoldovan adimoldovan commented Sep 24, 2026 •

Copy link
Copy Markdown

Adds a verify:file-types Grunt task. It checks that the CSS and JS files in build/ sit in the directories meant for them. It follows up PR #13684.

The two checks answer different questions:

#13684 this PR
Question Did someone commit a file in the wrong place? Did a build task write a file to the wrong place?
Input tracked files in src/ build/ after a production build
Runs every PR where npm run build runs

Neither PR depends on the other.

How it works

The task runs in verify:build, next to verify:old-files and verify:source-maps. So it runs at the end of every npm run build, which CI already runs in reusable-test-core-build-process.yml before it zips build/. It needs no new workflow. It does not run in npm run build:dev.

It flags three cases under build/wp-admin/ and build/wp-includes/:

  • a non-CSS file in a css/ directory
  • a non-JS file in a js/ directory
  • a CSS or JS file outside those directories

An allow-list of 12 patterns covers the known exceptions. I measured it against a full production build (npm ci, npm run gutenberg:download, npm run build, 5,016 files). It covers all 99 exceptions inside css/ and js/ directories, and all 640 CSS and JS files outside them. Those 640 are all in wp-includes/blocks/ and wp-includes/build/.

Testing instructions

npm ci
npm run gutenberg:download
npm run build

The build passes. To see the task fail, add misplaced files and run it again:

touch build/wp-admin/stray.css build/wp-includes/js/stray.txt build/wp-includes/js/.eslintrc
npm run grunt verify:file-types

It reports all three files. Clean up:

rm build/wp-admin/stray.css build/wp-includes/js/stray.txt build/wp-includes/js/.eslintrc

Trac ticket: https://core.trac.wordpress.org/ticket/65279

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafted the task, measured the allow-list against a real build, and ran code reviews. I reviewed the result.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Adds a `verify:file-types` task to `verify:build`. It checks that CSS
directories in `build/` hold only CSS files, JS directories hold only JS
files, and no CSS or JS file sits elsewhere in `wp-admin/` or
`wp-includes/`.

The build copies files from npm packages and Gutenberg. Git does not
track them, so a check of tracked files cannot see them.

See #65279.
@adimoldovan adimoldovan self-assigned this Sep 24, 2026
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…ional.

#65278 and #65279 will decide where these files belong.

See #65279.
@adimoldovan
adimoldovan marked this pull request as ready for review September 24, 2026 10:53
@adimoldovan
adimoldovan requested a review from a team September 24, 2026 10:53
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adrianmoldovanwp, lancewillett.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

wporg-sync pushed a commit that referenced this pull request Sep 24, 2026
Check the final production build for misplaced CSS and JavaScript files and unexpected file types in their directories. Run the check alongside the existing build verification tasks.

Allow known bundled assets and mark the generated PHP exceptions as provisional while their placement remains under discussion.

Developed in: #13706

Props adrianmoldovanwp.
See #65279.


git-svn-id: https://develop.svn.wordpress.org/trunk@63917 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync pushed a commit to WordPress/WordPress that referenced this pull request Sep 24, 2026
Check the final production build for misplaced CSS and JavaScript files and unexpected file types in their directories. Run the check alongside the existing build verification tasks.

Allow known bundled assets and mark the generated PHP exceptions as provisional while their placement remains under discussion.

Developed in: WordPress/wordpress-develop#13706

Props adrianmoldovanwp.
See #65279.

Built from https://develop.svn.wordpress.org/trunk@63917


git-svn-id: http://core.svn.wordpress.org/trunk@63086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@lancewillett

Copy link
Copy Markdown
Member

@lancewillett

Copy link
Copy Markdown
Member

Reopening after the revert in https://core.trac.wordpress.org/changeset/63918.

Next step: settle the file-placement exceptions and upstream formatting approach before moving these forward.

Discussion: https://wordpress.slack.com/archives/C08D0Q6BHNY/p1790267518339219

@lancewillett lancewillett reopened this Sep 24, 2026
@lancewillett lancewillett moved this from Done to In review in WordPress Project Build Tooling Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants