ci: Cache Electron downloads for PR tests (#336166)

Cache Electron downloads for PR tests

Warm platform-specific Electron archive caches on main and restore them in PR tests through a shared setup action. Preserve checksum validation, retries, and lookup-only dependency checks for already-warm jobs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alexandru DimaandCopilot authored and GitHub committed 2026-09-15 07:11:10 +00:00
1 parent 71e0a3d4c6
commit 175d3497e6
6 files changed
+197 -59

No files matched your search

@@ -33,3 +33,39 @@ Example usage from a workflow step:
If you change the archive format or flags, update both the `archive` and
`extract` branch of the script, and bump `build/.cachesalt` to invalidate
existing caches.
## Electron download cache
The platform jobs in [pr-node-modules.yml](../pr-node-modules.yml) also warm a
separate Electron download cache on `main`. The
[setup-electron](../../actions/setup-electron/action.yml) action shares cache
handling and download retries with the Linux, macOS, and Windows PR test
workflows:
- By default, restore cached archives and validate/prepare Electron, downloading
with up to three attempts as needed. PR jobs use this mode without saving.
- `lookup-only: 'true'` only checks for a cache entry, without restoring archives,
preparing Electron, or saving. This mode does not require npm dependencies.
- `save-cache: 'true'` also saves after successful setup on a cache miss.
The cache stores `@electron/get`'s original download archives, not the prepared
`.build/electron` application. Its key includes the runner OS, target
architecture, and a hash of `.npmrc` and `build/checksums/electron.txt`. Ordinary
`package-lock.json` changes do not invalidate it. If a downloader update changes
the cache format, bump the `electron-download-v1` prefix in `setup-electron`.
The paths match `@electron/get`'s platform defaults, including `XDG_CACHE_HOME`
on Linux and `LOCALAPPDATA` on Windows. Cache paths and keys are handled within
the action.
Even on a cache hit, PR jobs run `npm run electron` to validate and prepare the
application from the cached archives using the current checkout. Checksum
validation remains enabled: the current downloader still fetches
`SHASUMS256.txt` from GitHub, so this cache avoids the large ZIP downloads but
does not make Electron setup entirely network-independent.
On `main`, an Electron cache hit uses lookup-only checks and skips downloading
Electron. On a miss, the platform job restores `node_modules` (or installs them
if that cache also misses), then invokes `setup-electron` with `save-cache: 'true'`.
This checks the cache again before preparing and saving Electron, while keeping
already-warm jobs from extracting dependency archives unnecessarily.