Files
mattermost/.github/workflows/e2e-ci-cache-warm.yml
T
Jesse Hallam c3726ccb6b chore(ci): warm node and npm caches daily; make CI jobs restore read-only (#37393)
* chore(ci): warm node and npm caches daily; make CI jobs restore read-only

Add daily scheduled workflows on master that warm two independent caches,
each in its own workflow mirroring its consumers:

- webapp-ci-cache-warm.yml warms the webapp node_modules cache
  (keyed on webapp/package-lock.json)
- e2e-ci-cache-warm.yml warms the E2E ~/.npm registry cache
  (keyed on the cypress/playwright/api lockfiles)

Webapp CI and the E2E/api CI jobs now restore these caches read-only instead
of writing them, so the daily jobs keep the caches warm. The E2E ~/.npm
restore is factored into a reusable restore-e2e-npm-cache composite action,
and webapp-setup gains a read-only mode for the node_modules cache.

* chore(ci): guard cache-warm workflows with a concurrency group

* chore(ci): drop unused node-cache-dependency-path output

* chore(ci): reuse webapp-setup for node_modules in e2e-tests-check
2026-07-08 16:38:11 +00:00

79 lines
3.2 KiB
YAML

# Warms the ~/.npm registry cache used by the e2e suites (cypress, playwright,
# api). Runs once per day on master; all e2e/api CI jobs restore this cache
# read-only via .github/actions/restore-e2e-npm-cache and never write back, so
# this job is its sole writer.
#
# The cache is keyed on the OS/arch and a hash of all e2e lockfiles. Keep the key
# below in sync with .github/actions/restore-e2e-npm-cache, which is the canonical
# definition of the bucket's lockfile set. PRs that change a lockfile miss the
# exact key and fall back to the most recent warm entry via restore-keys.
#
# The webapp node_modules cache is warmed separately by webapp-ci-cache-warm.yml.
name: E2E CI Cache Warm
on:
schedule:
- cron: "0 1 * * *" # Daily 1am UTC — 1 h before e2e CI typically runs
workflow_dispatch:
# Prevent an overlapping manual dispatch and scheduled run from both missing the
# lookup and then racing to reserve the same cache key.
concurrency:
group: e2e-ci-cache-warm
cancel-in-progress: false
permissions:
contents: read
actions: write # required to save the Actions cache
jobs:
warm:
name: Warm E2E npm Registry Cache
runs-on: ubuntu-24.04
# Bound a hung run so it can't hold the concurrency group for the default
# 6-hour timeout and block subsequent warm runs.
timeout-minutes: 60
steps:
- name: Checkout mattermost project
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Check if npm registry cache already warm
id: e2e-npm-check
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ~/.npm
key: node-cache-${{ runner.os }}-${{ runner.arch }}-npm-e2e-${{ hashFiles('e2e-tests/cypress/package-lock.json', 'e2e-tests/playwright/package-lock.json', 'api/package-lock.json') }}
lookup-only: true
- name: ci/setup-node
if: steps.e2e-npm-check.outputs.cache-hit != 'true'
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: ".nvmrc"
# ~/.npm is content-addressable and grows additively across installs, so we
# populate it by running each suite's install, then save the single bucket.
- name: Install playwright npm packages
if: steps.e2e-npm-check.outputs.cache-hit != 'true'
working-directory: e2e-tests/playwright
run: npm ci
- name: Install cypress npm packages
if: steps.e2e-npm-check.outputs.cache-hit != 'true'
working-directory: e2e-tests/cypress
run: npm ci
- name: Install api npm packages
if: steps.e2e-npm-check.outputs.cache-hit != 'true'
working-directory: api
run: npm ci
- name: Save npm registry cache
if: steps.e2e-npm-check.outputs.cache-hit != 'true'
uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: ~/.npm
key: node-cache-${{ runner.os }}-${{ runner.arch }}-npm-e2e-${{ hashFiles('e2e-tests/cypress/package-lock.json', 'e2e-tests/playwright/package-lock.json', 'api/package-lock.json') }}