Skip to content

Commit 1400049

Browse files
authored
improve(ci): cut hosted test import time with warm caches (#123465)
* perf(ci): restore hosted test caches across lanes * perf(ci): restore caches in remaining Vitest lanes
1 parent db4379b commit 1400049

4 files changed

Lines changed: 123 additions & 9 deletions

File tree

‎.github/actions/setup-node-env/action.yml‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ inputs:
4343
description: Whether to persist Vitest's experimental filesystem module cache.
4444
required: false
4545
default: "false"
46+
restore-test-caches:
47+
description: Whether to restore the Vitest transform and test-scope Node compile caches together.
48+
required: false
49+
default: "false"
4650
node-compile-cache:
4751
description: Whether to persist Node's on-disk V8 compile cache.
4852
required: false
@@ -178,7 +182,7 @@ runs:
178182
${{ github.repository }}-vitest-fs-v3-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', '**/package.json', '**/tsconfig*.json', 'vitest.config.*', 'test/vitest/**', 'src/state/*.sql', '!**/node_modules/**') }}-
179183
180184
- name: Restore Vitest transform cache
181-
if: inputs.vitest-fs-cache == 'true' && inputs.save-vitest-fs-cache != 'true' && runner.os != 'Windows'
185+
if: (inputs.vitest-fs-cache == 'true' || inputs.restore-test-caches == 'true') && inputs.save-vitest-fs-cache != 'true' && runner.os != 'Windows'
182186
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
183187
with:
184188
path: /var/tmp/openclaw-vitest-fs-cache
@@ -187,7 +191,7 @@ runs:
187191
${{ github.repository }}-vitest-fs-v3-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}-${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', '**/package.json', '**/tsconfig*.json', 'vitest.config.*', 'test/vitest/**', 'src/state/*.sql', '!**/node_modules/**') }}-
188192
189193
- name: Configure Vitest transform cache
190-
if: inputs.vitest-fs-cache == 'true' && runner.os != 'Windows'
194+
if: (inputs.vitest-fs-cache == 'true' || inputs.restore-test-caches == 'true') && runner.os != 'Windows'
191195
env:
192196
CACHE_GENERATION: ${{ hashFiles('pnpm-lock.yaml', 'pnpm-workspace.yaml', '**/package.json', '**/tsconfig*.json', 'vitest.config.*', 'test/vitest/**', 'src/state/*.sql', '!**/node_modules/**') }}
193197
CACHE_WRITER: ${{ inputs.save-vitest-fs-cache == 'true' && '1' || '0' }}
@@ -216,7 +220,7 @@ runs:
216220
217221
- name: Select Node compile cache epoch
218222
id: node-compile-cache-epoch
219-
if: inputs.node-compile-cache == 'true' && runner.os != 'Windows'
223+
if: (inputs.node-compile-cache == 'true' || inputs.restore-test-caches == 'true') && runner.os != 'Windows'
220224
shell: bash
221225
env:
222226
CACHE_SCOPE: ${{ inputs.node-compile-cache-scope }}
@@ -238,7 +242,7 @@ runs:
238242
${{ github.repository }}-node-compile-v3-${{ inputs.node-compile-cache-scope }}-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}-
239243
240244
- name: Restore Node compile cache
241-
if: inputs.node-compile-cache == 'true' && inputs.save-node-compile-cache != 'true' && runner.os != 'Windows'
245+
if: (inputs.node-compile-cache == 'true' || inputs.restore-test-caches == 'true') && inputs.save-node-compile-cache != 'true' && runner.os != 'Windows'
242246
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
243247
with:
244248
path: /var/tmp/openclaw-node-compile-cache
@@ -247,7 +251,7 @@ runs:
247251
${{ github.repository }}-node-compile-v3-${{ inputs.node-compile-cache-scope }}-protected-${{ runner.os }}-${{ runner.arch }}-node-${{ inputs.node-version }}-
248252
249253
- name: Configure Node compile cache
250-
if: inputs.node-compile-cache == 'true' && runner.os != 'Windows'
254+
if: (inputs.node-compile-cache == 'true' || inputs.restore-test-caches == 'true') && runner.os != 'Windows'
251255
env:
252256
CACHE_WRITER: ${{ inputs.save-node-compile-cache == 'true' && '1' || '0' }}
253257
shell: bash

‎.github/workflows/ci.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,7 @@ jobs:
15051505
install-bun: "false"
15061506
dependency-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
15071507
use-actions-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
1508+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'true' || 'false' }}
15081509

15091510
- name: Download exact-run built runtime
15101511
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
@@ -1585,6 +1586,7 @@ jobs:
15851586
# preflight; hosted paths use the pnpm store cache instead.
15861587
dependency-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
15871588
use-actions-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
1589+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'true' || 'false' }}
15881590

15891591
- &cache_playwright_chromium
15901592
name: Cache Playwright Chromium
@@ -1659,6 +1661,7 @@ jobs:
16591661
# Blacksmith runs restore the preflight-published dependency tree.
16601662
dependency-cache: ${{ (vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.run_attempt > 1)) && 'false' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false') }}
16611663
use-actions-cache: ${{ (vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.run_attempt > 1)) && 'true' || (github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true') }}
1664+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'true' || 'false' }}
16621665

16631666
- *cache_playwright_chromium
16641667
- *install_playwright_chromium
@@ -1828,6 +1831,7 @@ jobs:
18281831
# preflight; hosted paths use the pnpm store cache instead.
18291832
dependency-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
18301833
use-actions-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
1834+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && (matrix.task == 'bundled-protocol' || matrix.task == 'contracts-plugins-ci-routing' || matrix.task == 'ci-routing' || matrix.task == 'bun-launcher') && 'true' || 'false' }}
18311835

18321836
- name: Run ${{ matrix.task }} (${{ matrix.runtime }})
18331837
env:
@@ -2101,6 +2105,7 @@ jobs:
21012105
# preflight; hosted paths use the pnpm store cache instead.
21022106
dependency-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
21032107
use-actions-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
2108+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'true' || 'false' }}
21042109

21052110
- name: Run plugin contract shard
21062111
env:
@@ -2143,6 +2148,7 @@ jobs:
21432148
# preflight; hosted paths use the pnpm store cache instead.
21442149
dependency-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'true' || 'false' }}
21452150
use-actions-cache: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND != 'github' && github.event_name != 'workflow_dispatch' && github.repository == 'openclaw/openclaw' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'openclaw/openclaw') && 'false' || 'true' }}
2151+
restore-test-caches: ${{ vars.OPENCLAW_CI_RUNNER_BACKEND == 'github' && 'true' || 'false' }}
21462152

21472153
- name: Run channel contract shard
21482154
env:

0 commit comments

Comments
 (0)