perf(ci): build only the frontend projects the WAR actually contains (#36945) - #36946
perf(ci): build only the frontend projects the WAR actually contains (#36945)#36946wezell wants to merge 3 commits into
Conversation
The artifact build ran `nx run-many -t build` across the whole workspace, which
builds the sdk-* packages, ai-evals and dotcdn alongside the four apps the WAR
ships. Those outputs are never packaged and never reused:
core-web/pom.xml webResources lists exactly
dist/apps/dotcms-ui -> dotAdmin
dist/libs/dotcms-webcomponents/dist -> dotcms-webcomponents
dist/apps/dotcms-binary-field-builder
dist/apps/dotcms-block-editor
dist/libs/sdk/analytics-standalone -> built by its own execution
and both SDK publishers (deploy-javascript-sdk, and publish-sdk-next on trunk)
start from a clean checkout and rebuild sdk-* themselves - deploy-javascript-sdk
even passes --skip-nx-cache. So every SDK build in the artifact phase was thrown
away.
Narrowing to the four leaf projects is safe: nx targetDefaults gives `build` a
`dependsOn: ["^build"]`, so their dependency libs still build. `test` has no
such dependency and runs against source, so unit tests are unaffected.
This lands in two places, because the execution is bound to the `compile` phase:
Initial Artifact Build ~2.85m of nx build, on the SERIAL prefix that gates
every test job
Frontend Unit Tests `mvn test -pl :dotcms-core-web` runs compile first,
so this 33m job was dominated by a full workspace
build before `nx affected -t test` ran at all
The project list is a property so a profile can widen it, and it sits next to a
comment pointing at the webResources block it mirrors.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NH4Pes5S9d1AQorJBNeFJU
|
Claude finished @wezell's task in 1m 58s —— View job Code Review
New Issues
Notes (not blocking)
Solid, well-reasoned change — the two Medium items are about the durability of the guard, not correctness of this build. Nothing blocking. · |
sfreudenthaler
left a comment
There was a problem hiding this comment.
change is good and welcome, just one improvement i want to add in
nx.build.projects is hand-maintained to mirror the webResources block below
it, per the comment added in this PR. Add a validate-phase check that fails
the build if a webResources project isn't covered, and fix the drift it
immediately catches: edit-content-bridge is packaged into the WAR but wasn't
in nx.build.projects, so it would have silently stopped building once the
`-p ${nx.build.projects}` narrowing landed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KDuKM6fQzm3hR1oShY3EPY
|
Pushed a follow-up commit adding the drift guard we discussed: a It immediately caught a real gap: |
Fixes #36945 (frontend half; the Maven reactor trim is still open on that issue).
The artifact build ran
nx run-many -t buildover the whole workspace. The WAR contains four of those projects:Everything else it built —
sdk-*,ai-evals,dotcdn— is never packaged and never reused. Both SDK publishers (deploy-javascript-sdk, andpublish-sdk-nexton trunk) start from a clean checkout and rebuildsdk-*themselves;deploy-javascript-sdkeven passes--skip-nx-cache. That work was thrown away every single build.Why this lands twice
The execution is bound to the
compilephase, so it runs in more than the build job:Initial Artifact BuildFrontend Unit Testsmvn test -pl :dotcms-core-webrunscompilefirst, so a full workspace build ran beforenx affected -t testdid anythingThe second one is the surprise: that job's cost is mostly the build, not the tests.
unit-testis alreadynx affected.Why narrowing is safe
nx.jsontargetDefaults.buildhasdependsOn: ["^build"], so each leaf project still builds its dependency libs. Listing the four leaves is sufficient.targetDefaults.testhas no^builddependency and runs against source, so unit tests are unaffected.project.jsonfiles, and the list mirrors thewebResourcesblock directly above it in the same pom.The list is a
<nx.build.projects>property so a profile can widen it, with a comment tying it towebResourcesso the two stay in sync.Verification
pom.xmlparses; the four project names confirmed againstapps/*/project.jsonandlibs/dotcms-webcomponents/project.json. Not run locally (the worktree has nonode_modules) — CI is the check, and the signal to watch is thatdotAdminand the three sibling apps are still present in the built WAR.Note
I originally expected nx caching to be the bigger win here. It is not something to reach for blindly:
.nx/cacheis 2.0 GB on a working machine, and the GitHub Actions cache is 10 GB per repo with LRU eviction — a naiveactions/cachewould compete with the Maven repo cache and could make builds slower. Doing that properly needs a real remote cache, which is a separate decision. This PR is the part that needs no new infrastructure.