Repository navigation
perf(ui-build): cache openmetadata-ui dist across workflows - #30700
Conversation
Every workflow triggering mvn ... clean package / -pl openmetadata-dist -am paid a ~5 min frontend-maven-plugin cost per run. On a typical PR push six such workflows fire concurrently, burning ~30 min of runner time for byte-identical dist output. Three layers land together: 1. Vite/pom cleanup — --ignore-scripts to skip the recursive preinstall that the maven reactor already did, shared node install path between the two frontend modules, explicit yarn run build-check execution to replace the suppressed postinstall, preprocessorMaxWorkers: true for parallel Less compilation across ~450 files, and a small barrel optimizer that rewrites @untitledui/icons named imports to per-icon deep imports (~1,000 fewer transforms in Rollup). 2. Pom auto-skip — a skip-ui-build profile activated by the presence of src/main/resources/ui/dist/index.html (app) or index.es.js (library), which sets a skip.ui.build property honored by every frontend-maven-plugin execution. mvn clean deletes dist so a clean build always rebuilds; any workflow that populates dist beforehand skips the ~5 min build. 3. .github/actions/cache-ui-dist composite action wrapping actions/cache with a content hash of every input that can affect vite output (UI src, package.json, yarn.lock, vite.config.ts, index.html, parseSchemas.js, both poms, spec schemas, ANTLR grammars, bundled JSON data). Optional variant input keeps PW_E2E_BUILD/PW_E2E_BUNDLE outputs in their own cache buckets. Wired into six workflows (playwright-knowledge-graph-postgresql-e2e, playwright-postgresql-e2e, maven-sonar-build, java-playwright-nightly, security-scan, docker-openmetadata-server). Actions cache is repo-scoped, so the first workflow to build a given UI source tree populates the cache; every subsequent workflow for the same SHA hits it. Measured locally (mvn -DskipTests -pl openmetadata-ui-core-components, openmetadata-ui -am package): - Baseline: 6:44 - Phase 1 alone: 5:56 - Cache-hit path: 4.24s (99% cut on UI portion) - Cache-miss path: 5:50 (populates cache for the fleet) Rollback: bump ui-dist-v1 → ui-dist-v2 in cache-ui-dist/action.yml to invalidate all cache entries atomically. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
✅ Playwright Results — workflow succeededValidated commit ✅ 568 passed · ❌ 0 failed · 🟡 1 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 56m 21s ⏱️ Max setup 3m 14s · max shard execution 20m 16s · max shard-job elapsed before upload 23m 26s · reporting 4s 🌐 203.11 requests/attempt · 2.83 app boots/UI scenario · 15.13% common-shard skew Optimization targets still in progress:
🟡 1 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
`mvn ... -pl openmetadata-dist -am` (used by playwright-postgresql-e2e and java-playwright-nightly) only pulls maven-declared deps into the reactor. openmetadata-dist depends on openmetadata-ui but not on openmetadata-ui-core-components, so the core-components module was excluded from the reactor and its dist/ never built. Before the phase 1 change, package.json's preinstall hook silently built core-components as a side effect of `yarn install` in openmetadata-ui. Adding --ignore-scripts to that yarn install (to skip the redundant recursive install/build) removed that safety net, exposing the missing maven dep. Add an <optional>true</optional> maven dep from openmetadata-ui to openmetadata-ui-core-components. Optional keeps the core-components jar off downstream consumers' transitive classpath — this dep exists solely to declare reactor ordering. Verified locally with `mvn -DskipTests -pl openmetadata-dist -am clean package`: reactor now includes `OpenMetadata UI Core Components [9/11]` and builds successfully (total 6:50, core-components 41s, vite 4:25). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ow level Follow-up to 5e4dafc. That commit added the fork-PR-via-pull_request_target guard inside .github/actions/cache-ui-dist so the actions/cache step is skipped for the dangerous case. That closes the runtime attack, but CodeQL is a static analyser and does not resolve conditionals through composite-action calls, so the "Cache Poisoning via execution of untrusted code" High alert kept firing on the three workflows that use pull_request_target. Move the guard onto the `- uses: ./.github/actions/cache-ui-dist` step itself in each pull_request_target-triggered workflow (playwright-knowledge-graph- postgresql-e2e, playwright-postgresql-e2e, maven-sonar-build), so CodeQL sees it at the workflow level. The internal guard stays as defence in depth. The other three workflows using the composite action (java-playwright-nightly, security-scan, docker-openmetadata-server) don't need this guard because none of them trigger on pull_request_target — no fork-trust-boundary crossing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (3)
.github/actions/cache-ui-dist/action.yml:103
- The composite action exports
SKIP_UI_BUILD=trueon any cache hit. If a cache entry was saved incomplete/empty (e.g., from a failed build), later runs can still get a cache hit for that key. Adding a quick sanity check for both required dist entrypoints before exporting the env var makes the skip behavior more robust.
- name: Signal skip-ui-build to maven on cache hit
if: steps.cache.outputs.cache-hit == 'true'
shell: bash
run: echo "SKIP_UI_BUILD=true" >> "$GITHUB_ENV"
openmetadata-ui-core-components/pom.xml:124
- This comment is a bit misleading: the shared install directory is
${maven.multiModuleProjectDirectory}/target/frontend, so it is outside each module’starget/, but a root-levelmvn cleanwill still delete it (since it deletes${maven.multiModuleProjectDirectory}/target). Clarifying this avoids confusion when debugging why node/yarn are re-downloaded.
and openmetadata-ui (see openmetadata-ui/pom.xml). The reactor builds
this module first, downloads node+yarn here, and the ui module reuses
the same install (frontend-maven-plugin skips re-download when the
version matches). Path is outside target/ so `mvn clean` at either
module does not wipe the shared install. -->
openmetadata-ui/src/main/resources/ui/vite.config.ts:257
preprocessorMaxWorkerswas previously pinned to 1 specifically to avoid Less race conditions in CI (per the removed inline comment / prior PR context). Re-enabling parallel workers here risks reintroducing flaky UI builds on GitHub Actions runners; consider keeping CI on 1 and only enabling parallelism locally.
css: {
preprocessorMaxWorkers: true,
preprocessorOptions: {
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (1)
openmetadata-ui/src/main/resources/ui/vite.config.ts:257
preprocessorMaxWorkerswas previously pinned to1to avoid intermittent Less race-condition crashes in CI (see referenced PR #26787). Switching it back totruerisks reintroducing flaky CI builds unless there's a verified upstream fix. Consider keeping CI serialized while allowing local parallelism (or gating with an explicit env flag).
css: {
preprocessorMaxWorkers: true,
preprocessorOptions: {
🚦 Removed from the merge queue —
|
…heck + force push) Addresses gitar-bot's PR review of PR #30700 (issue comment 5176722147), targeting the merge_group post-run block that opens/updates the `ci/auto-refresh-timing-baseline` PR. 1. `gh pr list ... --jq '.[0].number'` on an empty array emits the string "null", not an empty string. The `|| echo ""` fallback only fires on non-zero exit, which does not happen here — so `existing` became "null", `[[ -n "$existing" ]]` was true, and the job ran `gh pr edit null ...` and failed under `set -e`. On the very first run the `gh pr create` branch was never reached and the auto-refresh PR was never opened. Switch the jq filter to `.[0].number // empty` so no-PR really produces the empty string. 2. `git push --force-with-lease` is rejected with "stale info" when the remote branch exists but was not fetched. The workflow's `Checkout` step only pulls `main`, so `origin/ci/auto-refresh-timing-baseline` has no local ref, and every merge_group run after the first would fail this push. Since the branch is bot-owned (no concurrent human writers to protect), use plain `--force`. The auto-refresh job originated on main and is unrelated to the perf work in this PR — but the review flagged it against this PR's diff after main was merged in, so fold the fix in here. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🚦 Removed from the merge queue —
|
Code Review ✅ Approved 3 resolved / 3 findingsOptimizes the UI Maven build by caching compiled dist artifacts across workflows and parallelizing Vite processing, addressing the stale property comment omits new SKIP_UI_BUILD env gate, PR-existence check treats empty result as literal null, and git push --force-with-lease can fail with stale info on reruns findings. ✅ 3 resolved✅ Quality: Stale property comment omits new SKIP_UI_BUILD env gate
✅ Bug: PR-existence check treats empty result as literal "null"
✅ Bug: git push --force-with-lease can fail with 'stale info' on reruns
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source |
Describe your changes:
Every workflow triggering
mvn ... clean packageormvn ... -pl openmetadata-dist -amwas paying a ~5 min frontend-maven-plugin cost per run — on a typical PR push, six such workflows fire concurrently and burn ~30 min of runner time producing byte-identical dist output. This PR lands three layers together — vite/pom cleanup (parallel Less workers,--ignore-scripts+ explicityarn run build-check, shared node install between the two frontend modules, an@untitledui/iconsbarrel-optimize plugin that removes ~1,000 icon transforms), askip-ui-buildmaven profile that auto-activates whendist/index.htmlordist/index.es.jsis present so every frontend-maven-plugin execution short-circuits, and a.github/actions/cache-ui-distcomposite action that keysactions/cache@v5on a content hash of every input that can affect vite output (UI src, package.json, yarn.lock, vite.config.ts, index.html, parseSchemas.js, both poms, spec schemas, ANTLR grammars, bundled JSON data). Six workflows (playwright-knowledge-graph-postgresql-e2e,playwright-postgresql-e2e,maven-sonar-build,java-playwright-nightly,security-scan,docker-openmetadata-server) opt in with a singleuses:line, andplaywright-postgresql-e2epasses a distinctvariantsoPW_E2E_BUILD/PW_E2E_BUNDLEoutputs stay in their own cache buckets. Locally measured onmvn -DskipTests -pl openmetadata-ui-core-components,openmetadata-ui -am package: baseline 6:44, phase 1 alone 5:56, cache-miss 5:50, cache-hit 4.24s (99% cut on the UI portion). Rollback is one line — bumpui-dist-v1→ui-dist-v2in the composite action to invalidate every cache entry atomically.Type of change:
High-level design:
Three cooperating layers, none of which require workflow orchestration between jobs:
Vite + pom hygiene (repo-only, effective immediately):
openmetadata-ui/pom.xml:install --frozen-lockfile --ignore-scriptsskips the recursivepreinstallhook that re-installed and re-builtopenmetadata-ui-core-componentsafter the reactor already did; a new explicityarn run build-checkexecution regenerates the gitignoredsrc/generated/antlr/andsrc/jsons/*that the suppressedpostinstallwould have produced.installDirectory=${maven.multiModuleProjectDirectory}/target/frontend, so node+yarn are downloaded once per reactor build.vite.config.ts:preprocessorMaxWorkers: trueparallelises Less across the ~450 .less files (was pinned to 1 in PR Disable parallel Less processing to avoid race conditions in CI #26787); a smallbarrel-optimize-untitled-iconsplugin rewritesimport { Home02 } from '@untitledui/icons'toimport { Home02 } from '@untitledui/icons/Home02', cutting ~1,000 icon transforms in Rollup (package hassideEffects: false, so this is behaviour-preserving).Pom auto-skip (repo-only, enables layer 3):
skip-ui-buildprofile activated by<file><exists>${project.basedir}/src/main/resources/ui/dist/{index.html|index.es.js}</exists></file>. The profile flipsskip.ui.build=true; every frontend-maven-plugin execution honors<skip>${skip.ui.build}</skip>.mvn cleandeletes dist, so a clean build always rebuilds; a build that finds dist already populated (from cache, prior local build, or artifact restore) fast-paths through Java compile +maven-resources-pluginjar packaging in ~4 s.Shared cache (
.github/actions/cache-ui-dist/action.yml+ six workflow opt-ins):actions/cache@v5with cache paths on both modules'dist/and a key that is ahashFiles(...)of every input affecting vite output. Optionalvariantinput creates separate cache buckets for Playwright'sPW_E2E_BUILD/PW_E2E_BUNDLEchunking modes so a non-e2e build never returns an e2e-shaped dist.Alternatives considered: a dedicated
ui-build.ymlworkflow producing an artifact reused across all downstream workflows viaworkflow_run— rejected because it adds a cross-workflow dependency, artifact upload/download latency, and coordination that the repo-wide cache pattern avoids for free. Splitting the UI out of the Maven reactor entirely would deliver a bigger structural win but is out of scope for this PR.Backward-compat: the default
skip.ui.build=falsepreserves existing behaviour for localmvn ... clean packageand any workflow that doesn't opt in to the composite action. Docker release path (docker-openmetadata-server.yml) still ships.brfiles because we didn't gate brotli emission.Tests:
Use cases covered
mvn -DskipTests -pl openmetadata-ui-core-components,openmetadata-ui -am packagewith dist absent → full rebuild, ~5:50.mvn clean package→ clean deletes dist → full rebuild path.playwright-postgresql-e2epassesvariant: pw-e2e-build/pw-e2e-bundleso its e2e-shaped dist never returns to a non-e2e workflow.Unit tests
Not applicable — this is a build/CI infrastructure change with no runtime code paths.
Backend integration tests
Not applicable — no backend API changes.
Ingestion integration tests
Not applicable — no ingestion changes.
Playwright (UI) tests
Not applicable — no UI runtime changes; the vite plugin rewrite is compile-time and produces byte-identical output for the same source inputs.
Manual testing performed
openmetadata-ui/src/main/resources/ui/dist/index.htmlandopenmetadata-ui-core-components/src/main/resources/ui/dist/index.es.jspresent,mvn -DskipTests -pl openmetadata-ui-core-components,openmetadata-ui -am packagecompleted in 4.24s — everyfrontend-maven-pluginexecution logged its--- ... ---banner but noDone in Xsline (confirmed<skip>honored); jar packaging succeeded with 25 asset files undertarget/classes/assets/and producedopenmetadata-ui-2.0.0-SNAPSHOT.jar(50 MB).rm -rfon both dist dirs and both module targets, the same command completed in 5:50 with vite build reporting✓ built in 4m 56sand 1147.br+ 1147.gzfiles emitted.nm:@untitledui/iconstransform count dropped from 1174 → 167 (86% reduction); withpreprocessorMaxWorkers: trueand the plugin, isolatedyarn buildimproved from 5:27 → 4:52 hot-cache.actions/checkout@v7and before the corresponding mvn step.UI screen recording / screenshots:
Not applicable — no UI runtime changes.
Checklist:
🤖 Generated with Claude Code
Greptile Summary
This PR introduces reusable UI distribution caching and Maven build skipping to reduce repeated frontend compilation.
Confidence Score: 4/5
The PR is not yet safe to merge because stale source-tree dist files and incomplete core-components cache fingerprinting can cause CI and release builds to package outdated frontend output.
The skip profiles remain activated by dist files outside Maven’s target directories, so clean builds can still bypass frontend compilation, and the cache key still excludes core-components Vite and TypeScript configuration even though those files control its generated library output.
Files Needing Attention: openmetadata-ui/pom.xml, openmetadata-ui-core-components/pom.xml, .github/actions/cache-ui-dist/action.yml
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Workflow checkout] --> B[Compute UI input hash] B --> C{Cached dist exists?} C -->|Yes| D[Restore app and core dist] C -->|No| E[Maven frontend build] D --> F[Maven skip-ui-build profiles] E --> G[Save dist cache] F --> H[Package UI resources] G --> HReviews (4): Last reviewed commit: "Merge branch 'main' into optimize-ui-mav..." | Re-trigger Greptile