Skip to content

Commit

Permalink
chore: Updating system test node modules cache logic to support binar…
Browse files Browse the repository at this point in the history
…y 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>
  • Loading branch information
tbiethman and emilyrohrbough committed Apr 26, 2022
1 parent 3d7ab6a commit 4972872
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
11 changes: 5 additions & 6 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ commands:
name: Restore system tests node_modules cache
keys:
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-

update_cached_system_tests_deps:
description: 'Update the cached node_modules for projects in "system-tests/projects/**"'
Expand All @@ -215,7 +214,7 @@ commands:
- restore_cache:
name: Restore cache state, to check for known modules cache existence
keys:
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-state-{{ checksum "system_tests_cache_key" }}
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
- run:
name: Send root honeycomb event for this CI build
command: cd system-tests/scripts && node ./send-root-honecomb-event.js
Expand All @@ -238,11 +237,11 @@ commands:
name: Save system tests node_modules cache
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
paths:
- ~/.cache/cy-system-tests-node-modules
- /tmp/cy-system-tests-node-modules
- run: touch /tmp/system_tests_node_modules_installed
- save_cache:
name: Save system tests node_modules cache state key
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-state-{{ checksum "system_tests_cache_key" }}
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
paths:
- /tmp/system_tests_node_modules_installed

Expand All @@ -262,7 +261,7 @@ commands:
command: echo $PLATFORM > platform_key
- restore_cache:
name: Restore cache state, to check for known modules cache existence
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-state-{{ checksum "circle_cache_key" }}
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
- run:
name: Bail if cache exists
command: |
Expand Down Expand Up @@ -304,7 +303,7 @@ commands:
- run: touch node_modules_installed
- save_cache:
name: Saving node-modules cache state key
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-state-{{ checksum "circle_cache_key" }}
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
paths:
- node_modules_installed
- save_cache:
Expand Down
3 changes: 1 addition & 2 deletions system-tests/lib/dep-installer/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import fs from 'fs-extra'
import path from 'path'
import cachedir from 'cachedir'
import execa from 'execa'
import { cyTmpDir, projectPath, projects, root } from '../fixtures'
import { getYarnCommand } from './yarn'
Expand Down Expand Up @@ -162,7 +161,7 @@ export async function scaffoldProjectNodeModules (project: string, updateLockFil
await execa(cmd, { cwd: projectDir, stdio: 'inherit', shell: true })
}

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

async function removeWorkspacePackages (packages: string[]): Promise<void> {
Expand Down
10 changes: 9 additions & 1 deletion system-tests/scripts/cache-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@
# cd to this "scripts" directory
cd "$(dirname "${BASH_SOURCE[0]}")"

cat ../projects/**/{package.json,yarn.lock}
# Sort glob output, as it can vary based on architecture. LC_ALL=C required for locale-agnostic sort.
file_list=$(ls ../projects/**/{package.json,yarn.lock} | LC_ALL=C sort -f)

contents=''
for t in ${file_list[@]}; do
contents+=$(<$t)
done

echo $contents

3 comments on commit 4972872

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4972872 Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.1/linux-x64/develop-4972872a259a9b1dcabd09106e8ff84024f34031/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4972872 Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.1/darwin-x64/develop-4972872a259a9b1dcabd09106e8ff84024f34031/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 4972872 Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.1/win32-x64/develop-4972872a259a9b1dcabd09106e8ff84024f34031/cypress.tgz

Please sign in to comment.