Skip to content

Commit 7e394af

Browse files
chore(ui): migrate vite 6 → 8, plugin-react 4 → 6; cache UI build in CI (#2501)
* chore(ui): migrate vite 6 -> 8 and plugin-react 4 -> 6 Supersedes the auto-generated bump in #2496, which only updated vite and left @vitejs/plugin-react on a peer range that excludes vite 8, breaking the UI build (and every Go job that embeds the UI assets) with ERESOLVE. - vite ^6.0.0 -> ^8.0.13 - @vitejs/plugin-react ^4.3.0 -> ^6.0.2 (peers vite ^8.0.0 only) - vite-plugin-singlefile ^2.0.0 -> ^2.3.3 (peers already allowed v8) - engines.node >=20 -> ^20.19.0 || >=22.12.0 (Vite 7+ requirement) Vite 8 ships Rolldown instead of Rollup, which rejects bundle mutation in generateBundle. The rename-output plugin was doing exactly that to flatten the singlefile-inlined HTML from src/apps/<app>/index.html down to <app>.html. Refactored it to hoist the file in closeBundle (post-write) and renamed it to flatten-output to reflect what it actually does. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * chore(ui): give flatten-output a clearer error when the HTML is missing Addresses Copilot review feedback on #2501: if the singlefile-inlined HTML isn't where we expect it (e.g. because a future Vite/Rolldown change alters the output path), throw with the app name and expected path instead of letting renameSync surface a bare ENOENT. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * perf(ui+ci): cache build artifacts and run vite in single process Introduce a content-addressable cache for the embedded UI HTML and refactor the build script to invoke vite once per Node process instead of three times. * New ui/scripts/build.mjs runs vite build() in a loop within one process, removing the cross-env dev dependency and avoiding redundant plugin/JIT warm-up. Local build time drops from ~2.4s to ~1.5s. * New .github/actions/build-ui composite action restores pkg/github/ui_dist/{get-me,issue-write,pr-write}.html from cache keyed on hashes of ui/ sources and the lockfile. On cache hit it skips Node setup and the build entirely; on miss it sets up Node and runs script/build-ui as before. Saves ~6s per workflow on Go-only PRs, which is the common case across seven workflows. * Replace the duplicated setup-node + Build UI pair in seven workflows (go, lint, docs-check, license-check, goreleaser, mcp-diff, code-scanning) with a single uses: ./.github/actions/build-ui line. code-scanning keeps a dedicated setup-node for the JavaScript CodeQL path. Output files are byte-identical to the pre-refactor build. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * perf(ci): share UI artifact cache across runner OSes The cached HTML output is platform-independent, so set enableCrossOsArchive on the cache step. With this any OS can restore the cache populated by any other OS — one shared cache instead of three. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d4e1231 commit 7e394af

12 files changed

Lines changed: 986 additions & 852 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build UI
2+
description: Restore cached UI HTML artifacts, or set up Node and run script/build-ui on cache miss.
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Cache UI artifacts
8+
id: cache-ui
9+
uses: actions/cache@v5
10+
with:
11+
path: |
12+
pkg/github/ui_dist/get-me.html
13+
pkg/github/ui_dist/issue-write.html
14+
pkg/github/ui_dist/pr-write.html
15+
key: ui-dist-v1-${{ hashFiles('ui/package-lock.json', 'ui/package.json', 'ui/index.html', 'ui/tsconfig*.json', 'ui/vite.config.ts', 'ui/src/**', 'ui/scripts/**') }}
16+
enableCrossOsArchive: true
17+
18+
- name: Set up Node.js
19+
if: steps.cache-ui.outputs.cache-hit != 'true'
20+
uses: actions/setup-node@v6
21+
with:
22+
node-version: "20"
23+
cache: npm
24+
cache-dependency-path: ui/package-lock.json
25+
26+
- name: Build UI
27+
if: steps.cache-ui.outputs.cache-hit != 'true'
28+
shell: bash
29+
run: script/build-ui
30+
31+
- name: Report UI cache status
32+
shell: bash
33+
run: |
34+
if [ "${{ steps.cache-ui.outputs.cache-hit }}" = "true" ]; then
35+
echo "UI artifacts restored from cache (skipped build)."
36+
else
37+
echo "UI artifacts rebuilt from source."
38+
fi

.github/workflows/code-scanning.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ jobs:
7878
go-version: ${{ fromJSON(steps.resolve-environment.outputs.environment).configuration.go.version }}
7979
cache: false
8080

81-
- name: Set up Node.js
82-
if: matrix.language == 'go' || matrix.language == 'javascript'
81+
- name: Set up Node.js (for JavaScript CodeQL)
82+
if: matrix.language == 'javascript'
8383
uses: actions/setup-node@v6
8484
with:
8585
node-version: "20"
@@ -88,7 +88,7 @@ jobs:
8888

8989
- name: Build UI
9090
if: matrix.language == 'go'
91-
run: script/build-ui
91+
uses: ./.github/actions/build-ui
9292

9393
- name: Autobuild
9494
uses: github/codeql-action/autobuild@v4

.github/workflows/docs-check.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ jobs:
1616
- name: Checkout code
1717
uses: actions/checkout@v6
1818

19-
- name: Set up Node.js
20-
uses: actions/setup-node@v6
21-
with:
22-
node-version: "20"
23-
cache: "npm"
24-
cache-dependency-path: ui/package-lock.json
25-
2619
- name: Build UI
27-
run: script/build-ui
20+
uses: ./.github/actions/build-ui
2821

2922
- name: Set up Go
3023
uses: actions/setup-go@v6

.github/workflows/go.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,8 @@ jobs:
2525
- name: Check out code
2626
uses: actions/checkout@v6
2727

28-
- name: Set up Node.js
29-
uses: actions/setup-node@v6
30-
with:
31-
node-version: "20"
32-
cache: "npm"
33-
cache-dependency-path: ui/package-lock.json
34-
3528
- name: Build UI
36-
shell: bash
37-
run: script/build-ui
29+
uses: ./.github/actions/build-ui
3830

3931
- name: Set up Go
4032
uses: actions/setup-go@v6

.github/workflows/goreleaser.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,8 @@ jobs:
1616
- name: Check out code
1717
uses: actions/checkout@v6
1818

19-
- name: Set up Node.js
20-
uses: actions/setup-node@v6
21-
with:
22-
node-version: "20"
23-
cache: "npm"
24-
cache-dependency-path: ui/package-lock.json
25-
2619
- name: Build UI
27-
run: script/build-ui
20+
uses: ./.github/actions/build-ui
2821

2922
- name: Set up Go
3023
uses: actions/setup-go@v6

.github/workflows/license-check.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,8 @@ jobs:
3232
GH_TOKEN: ${{ github.token }}
3333
run: gh pr checkout ${{ github.event.pull_request.number }}
3434

35-
- name: Set up Node.js
36-
uses: actions/setup-node@v6
37-
with:
38-
node-version: "20"
39-
cache: "npm"
40-
cache-dependency-path: ui/package-lock.json
41-
4235
- name: Build UI
43-
run: script/build-ui
36+
uses: ./.github/actions/build-ui
4437

4538
- name: Set up Go
4639
uses: actions/setup-go@v6

.github/workflows/lint.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v6
17-
- uses: actions/setup-node@v6
18-
with:
19-
node-version: "20"
20-
cache: "npm"
21-
cache-dependency-path: ui/package-lock.json
2217
- name: Build UI
23-
run: script/build-ui
18+
uses: ./.github/actions/build-ui
2419
- uses: actions/setup-go@v6
2520
with:
2621
go-version: '1.25'

.github/workflows/mcp-diff.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22-
- name: Set up Node.js
23-
uses: actions/setup-node@v6
24-
with:
25-
node-version: '20'
26-
2722
- name: Build UI
28-
run: script/build-ui
23+
uses: ./.github/actions/build-ui
2924

3025
- name: Run MCP Server Diff
3126
uses: SamMorrowDrums/mcp-server-diff@v2.3.5

0 commit comments

Comments
 (0)