From 6273488b356f28a24b766b88b88782008ed7f6a1 Mon Sep 17 00:00:00 2001 From: Sewer56 Date: Tue, 19 May 2026 13:32:20 +0100 Subject: [PATCH 1/2] Cache Electron native rebuild outputs Defer @vortex/main electron-rebuild during pnpm install, restore cached native build outputs, then run one explicit electron-rebuild step before pnpm run build. This branch is based on the separate Electron rebuild controls PR. This commit owns the behavior change from implicit postinstall rebuild to deferred explicit rebuild plus caches. Cached outputs cover @nexusmods/fomod-installer-native, drivelist, leveldown, winapi-bindings, xxhash-addon, and @parcel/watcher build/bin directories under pnpm's virtual store. Header caches cover ~/.electron-gyp and ~/.cache/node-gyp. Measurement on Sewer56/Vortex: Baseline full-postinstall main runs: - https://github.com/Sewer56/Vortex/actions/runs/26099098244 - https://github.com/Sewer56/Vortex/actions/runs/26099100086 - https://github.com/Sewer56/Vortex/actions/runs/26099101744 Warmup/verification run: - https://github.com/Sewer56/Vortex/actions/runs/26099103356 Optimized warm-cache runs: - https://github.com/Sewer56/Vortex/actions/runs/26099876762 - https://github.com/Sewer56/Vortex/actions/runs/26099878560 - https://github.com/Sewer56/Vortex/actions/runs/26099880447 All optimized warm-cache runs logged `Electron native cache hit: true` on both Ubuntu and Windows. Ubuntu combined install + cache restore + rebuild median: 86s -> 32s (-54s). Rebuild step itself was 1s with cache. Windows combined install + cache restore + rebuild median: 332s -> 260s (-72s). Rebuild step itself was 2s with cache. Note: the first verification run had a Windows native-output cache miss and spent 67s in the explicit rebuild, confirming warm-cache measurements need a serialized warmup first. --- .github/workflows/main.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fc90de534..62e0ea5b9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,40 @@ jobs: - name: Install dependencies run: pnpm install + env: + VORTEX_ELECTRON_REBUILD: "defer" + + - name: Cache native build headers + uses: actions/cache@v4 + with: + path: | + ~/.electron-gyp + ~/.cache/node-gyp + key: native-headers-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'src/main/package.json') }} + + - name: Cache Electron native rebuild outputs + id: electron-native-cache + uses: actions/cache@v4 + with: + path: | + node_modules/.pnpm/@nexusmods+fomod-installer-native@*/node_modules/@nexusmods/fomod-installer-native/build + node_modules/.pnpm/@nexusmods+fomod-installer-native@*/node_modules/@nexusmods/fomod-installer-native/bin + node_modules/.pnpm/drivelist@*/node_modules/drivelist/build + node_modules/.pnpm/drivelist@*/node_modules/drivelist/bin + node_modules/.pnpm/leveldown@*/node_modules/leveldown/build + node_modules/.pnpm/leveldown@*/node_modules/leveldown/bin + node_modules/.pnpm/winapi-bindings@*/node_modules/winapi-bindings/build + node_modules/.pnpm/winapi-bindings@*/node_modules/winapi-bindings/bin + node_modules/.pnpm/xxhash-addon@*/node_modules/xxhash-addon/build + node_modules/.pnpm/xxhash-addon@*/node_modules/xxhash-addon/bin + node_modules/.pnpm/@parcel+watcher@*/node_modules/@parcel/watcher/build + node_modules/.pnpm/@parcel+watcher@*/node_modules/@parcel/watcher/bin + key: electron-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'src/main/package.json', 'src/main/postinstall.mjs') }} + + - name: Rebuild Electron native modules + run: | + echo "Electron native cache hit: ${{ steps.electron-native-cache.outputs.cache-hit }}" + pnpm --filter @vortex/main exec electron-rebuild - name: Build run: pnpm run build From 9e3864cf35c877f35c909855848fb93285101901 Mon Sep 17 00:00:00 2001 From: Sewer56 Date: Thu, 21 May 2026 12:45:21 +0100 Subject: [PATCH 2/2] Remove package json from native cache keys https://github.com/Nexus-Mods/Vortex/pull/23272#discussion_r3280998352 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 62e0ea5b9..b77cc031c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,7 +56,7 @@ jobs: path: | ~/.electron-gyp ~/.cache/node-gyp - key: native-headers-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml', 'src/main/package.json') }} + key: native-headers-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('package.json', 'pnpm-lock.yaml') }} - name: Cache Electron native rebuild outputs id: electron-native-cache @@ -75,7 +75,7 @@ jobs: node_modules/.pnpm/xxhash-addon@*/node_modules/xxhash-addon/bin node_modules/.pnpm/@parcel+watcher@*/node_modules/@parcel/watcher/build node_modules/.pnpm/@parcel+watcher@*/node_modules/@parcel/watcher/bin - key: electron-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'src/main/package.json', 'src/main/postinstall.mjs') }} + key: electron-native-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', 'src/main/postinstall.mjs') }} - name: Rebuild Electron native modules run: |