From bf8bd57e03c99183023d32d393a50bed10b06cb5 Mon Sep 17 00:00:00 2001 From: Mark Lee Date: Wed, 8 Apr 2026 17:45:09 -0700 Subject: [PATCH] refactor(ci): extract mise/asdf caching to e2e-only cache Split the shared daily cache into a slim daily cache (for all jobs) and an e2e-specific cache (for machine-executor jobs that need tool binaries). This reduces cache restore size for non-e2e Docker jobs while preserving tool caching for e2e jobs. - Revert v2 cache key prefix back to v1 (stale v2 entries expire in 15d) - Remove ~/.asdf and ~/.local/share/mise from daily cache - Add v1-e2e-daily-cache with ~/.asdf and ~/.local/share/mise - Add restore_e2e_cache parameter to setup_environment (default: false) - Pass restore_e2e_cache: true from e2e job Refs: DT-5282 Assisted-By: claude-opus 4.6 via OpenCode --- orbs/shared/commands/setup_environment.yml | 14 +++++++++++++- orbs/shared/jobs/e2e.yaml | 1 + orbs/shared/jobs/save_cache.yaml | 13 +++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/orbs/shared/commands/setup_environment.yml b/orbs/shared/commands/setup_environment.yml index 0ba10bca1..ca3efa46b 100755 --- a/orbs/shared/commands/setup_environment.yml +++ b/orbs/shared/commands/setup_environment.yml @@ -22,6 +22,12 @@ parameters: description: Skips restoring the cache in case a clean slate is needed. type: boolean default: true + restore_e2e_cache: + description: >- + Restore the e2e daily cache containing asdf/mise tool installs. + Use for machine executor jobs that need tool binaries. + type: boolean + default: false checkout_method: description: checkout method per https://circleci.com/docs/reference/configuration-reference/#checkout type: enum @@ -37,7 +43,13 @@ steps: steps: - restore_cache: keys: - - v2-daily-cache-{{ arch }}- + - v1-daily-cache-{{ arch }}- + - when: + condition: << parameters.restore_e2e_cache >> + steps: + - restore_cache: + keys: + - v1-e2e-daily-cache-{{ arch }}- # Adds a github org scoped SSH key to the project added by Wheatley - add_ssh_keys - when: diff --git a/orbs/shared/jobs/e2e.yaml b/orbs/shared/jobs/e2e.yaml index e70c9135c..2d905dbc1 100644 --- a/orbs/shared/jobs/e2e.yaml +++ b/orbs/shared/jobs/e2e.yaml @@ -55,6 +55,7 @@ resource_class: << parameters.resource_class >> steps: - setup_environment: machine: true + restore_e2e_cache: true - run: name: Run E2E Tests command: KUBECONFIG="$HOME/.outreach/kubeconfig.yaml" make e2e diff --git a/orbs/shared/jobs/save_cache.yaml b/orbs/shared/jobs/save_cache.yaml index ba8ba7269..d8d3a28bb 100644 --- a/orbs/shared/jobs/save_cache.yaml +++ b/orbs/shared/jobs/save_cache.yaml @@ -60,7 +60,7 @@ steps: steps: - restore_cache: keys: - - v2-toggle-daily-cache-{{ arch }}-{{ .Revision }} + - v1-toggle-daily-cache-{{ arch }}-{{ .Revision }} - run: name: Check cache flag command: | @@ -77,15 +77,20 @@ steps: - run: name: Run tests command: make test + # Daily cache restored by all jobs (Docker and machine executors) - save_cache: - key: v2-daily-cache-{{ arch }}-{{ epoch }} + key: v1-daily-cache-{{ arch }}-{{ epoch }} paths: - "~/.cache" - - "~/.asdf" - "~/.outreach/.cache" + # E2E cache with asdf/mise tool installs for machine-executor jobs + - save_cache: + key: v1-e2e-daily-cache-{{ arch }}-{{ epoch }} + paths: + - "~/.asdf" - "~/.local/share/mise" - save_cache: - key: v2-toggle-daily-cache-{{ arch }}-{{ .Revision }} + key: v1-toggle-daily-cache-{{ arch }}-{{ .Revision }} paths: - "~/cache-toggle"