Skip to content

Commit 4972872

Browse files
chore: Updating system test node modules cache logic to support binary tests (#21187)
* Updating state cache key names to limit improper fallback matches. Sorting output for cache key for cross-arch determinism. * Trying to normalize cache output * Lost tracking for this change somehow * Changing key name to invalidate current cache. * Tweaking install script * Tweaking install script again * Another commit to test existing cache * Resetting keys for PR * Whoops, this slipped into the last commit * Missed one key rename somehow * Update system-tests/scripts/cache-key.sh Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com> Co-authored-by: Emily Rohrbough <emilyrohrbough@users.noreply.github.com>
1 parent 3d7ab6a commit 4972872

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

circle.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ commands:
201201
name: Restore system tests node_modules cache
202202
keys:
203203
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
204-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-
205204

206205
update_cached_system_tests_deps:
207206
description: 'Update the cached node_modules for projects in "system-tests/projects/**"'
@@ -215,7 +214,7 @@ commands:
215214
- restore_cache:
216215
name: Restore cache state, to check for known modules cache existence
217216
keys:
218-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-state-{{ checksum "system_tests_cache_key" }}
217+
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
219218
- run:
220219
name: Send root honeycomb event for this CI build
221220
command: cd system-tests/scripts && node ./send-root-honecomb-event.js
@@ -238,11 +237,11 @@ commands:
238237
name: Save system tests node_modules cache
239238
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
240239
paths:
241-
- ~/.cache/cy-system-tests-node-modules
240+
- /tmp/cy-system-tests-node-modules
242241
- run: touch /tmp/system_tests_node_modules_installed
243242
- save_cache:
244243
name: Save system tests node_modules cache state key
245-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-state-{{ checksum "system_tests_cache_key" }}
244+
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
246245
paths:
247246
- /tmp/system_tests_node_modules_installed
248247

@@ -262,7 +261,7 @@ commands:
262261
command: echo $PLATFORM > platform_key
263262
- restore_cache:
264263
name: Restore cache state, to check for known modules cache existence
265-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-state-{{ checksum "circle_cache_key" }}
264+
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
266265
- run:
267266
name: Bail if cache exists
268267
command: |
@@ -304,7 +303,7 @@ commands:
304303
- run: touch node_modules_installed
305304
- save_cache:
306305
name: Saving node-modules cache state key
307-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-state-{{ checksum "circle_cache_key" }}
306+
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
308307
paths:
309308
- node_modules_installed
310309
- save_cache:

system-tests/lib/dep-installer/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import fs from 'fs-extra'
22
import path from 'path'
3-
import cachedir from 'cachedir'
43
import execa from 'execa'
54
import { cyTmpDir, projectPath, projects, root } from '../fixtures'
65
import { getYarnCommand } from './yarn'
@@ -162,7 +161,7 @@ export async function scaffoldProjectNodeModules (project: string, updateLockFil
162161
await execa(cmd, { cwd: projectDir, stdio: 'inherit', shell: true })
163162
}
164163

165-
const cacheNodeModulesDir = path.join(cachedir('cy-system-tests-node-modules'), project, 'node_modules')
164+
const cacheNodeModulesDir = path.join('/tmp', 'cy-system-tests-node-modules', project, 'node_modules')
166165
const tmpNodeModulesDir = path.join(projectPath(project), 'node_modules')
167166

168167
async function removeWorkspacePackages (packages: string[]): Promise<void> {

system-tests/scripts/cache-key.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@
55
# cd to this "scripts" directory
66
cd "$(dirname "${BASH_SOURCE[0]}")"
77

8-
cat ../projects/**/{package.json,yarn.lock}
8+
# Sort glob output, as it can vary based on architecture. LC_ALL=C required for locale-agnostic sort.
9+
file_list=$(ls ../projects/**/{package.json,yarn.lock} | LC_ALL=C sort -f)
10+
11+
contents=''
12+
for t in ${file_list[@]}; do
13+
contents+=$(<$t)
14+
done
15+
16+
echo $contents

0 commit comments

Comments
 (0)