Skip to content

Commit 12406c4

Browse files
chore: use a file for cache versioning and not env (#23811)
Co-authored-by: Rachel <[email protected]>
1 parent fada0be commit 12406c4

File tree

8 files changed

+29
-27
lines changed

8 files changed

+29
-27
lines changed

.circleci/cache-version.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Bump this version to force CI to re-create the cache from scratch.
2+
3+
9-13-22

circle.yml renamed to .circleci/config.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ commands:
224224
command: node ./scripts/get-platform-key.js > platform_key
225225
- restore_cache:
226226
name: Restore cache state, to check for known modules cache existence
227-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
227+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
228228
- run:
229229
name: Move node_modules back from /tmp
230230
command: |
@@ -251,7 +251,7 @@ commands:
251251
- restore_cache:
252252
name: Restore system tests node_modules cache
253253
keys:
254-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
254+
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
255255

256256
update_cached_system_tests_deps:
257257
description: 'Update the cached node_modules for projects in "system-tests/projects/**"'
@@ -265,7 +265,7 @@ commands:
265265
- restore_cache:
266266
name: Restore cache state, to check for known modules cache existence
267267
keys:
268-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
268+
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
269269
- run:
270270
name: Send root honeycomb event for this CI build
271271
command: cd system-tests/scripts && node ./send-root-honeycomb-event.js
@@ -279,20 +279,20 @@ commands:
279279
- restore_cache:
280280
name: Restore system tests node_modules cache
281281
keys:
282-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
283-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-
282+
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
283+
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-
284284
- run:
285285
name: Update system-tests node_modules cache
286286
command: yarn workspace @tooling/system-tests projects:yarn:install
287287
- save_cache:
288288
name: Save system tests node_modules cache
289-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
289+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
290290
paths:
291291
- /tmp/cy-system-tests-node-modules
292292
- run: touch /tmp/system_tests_node_modules_installed
293293
- save_cache:
294294
name: Save system tests node_modules cache state key
295-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
295+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
296296
paths:
297297
- /tmp/system_tests_node_modules_installed
298298

@@ -312,7 +312,7 @@ commands:
312312
command: node ./scripts/get-platform-key.js > platform_key
313313
- restore_cache:
314314
name: Restore cache state, to check for known modules cache existence
315-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
315+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
316316
- run:
317317
name: Bail if cache exists
318318
command: |
@@ -324,7 +324,7 @@ commands:
324324
- restore_cache:
325325
name: Restore weekly yarn cache
326326
keys:
327-
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
327+
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
328328
- run:
329329
name: Install Node Modules
330330
command: |
@@ -341,7 +341,7 @@ commands:
341341
steps:
342342
- save_cache:
343343
name: Saving node modules for root, cli, and all globbed workspace packages
344-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
344+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
345345
paths:
346346
- node_modules
347347
- cli/node_modules
@@ -352,18 +352,18 @@ commands:
352352
steps:
353353
- save_cache:
354354
name: Saving node modules for root, cli, and all globbed workspace packages
355-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
355+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
356356
paths:
357357
- /tmp/node_modules_cache
358358
- run: touch node_modules_installed
359359
- save_cache:
360360
name: Saving node-modules cache state key
361-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
361+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
362362
paths:
363363
- node_modules_installed
364364
- save_cache:
365365
name: Save weekly yarn cache
366-
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
366+
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
367367
paths:
368368
- ~/.yarn
369369
- ~/.cy-npm-cache

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ There are also a set of system tests in [`system-tests`](system-tests) which att
461461

462462
Additionally, we test the code by running it against various other example projects in CI. See CI badges and links at the top of this document.
463463

464-
If you're curious how we manage all of these tests in CI check out our [`circle.yml`](circle.yml) file found in the root `cypress` directory.
464+
If you're curious how we manage all of these tests in CI check out our [CircleCI config](.circleci/config.yml).
465465

466466
#### Docker
467467

@@ -474,7 +474,7 @@ Sometimes tests pass locally, but fail in CI. Our CI environment is dockerized.
474474
$ yarn docker
475475
```
476476

477-
There is a script [scripts/run-docker-local.sh](scripts/run-docker-local.sh) that runs the cypress image (see [circle.yml](circle.yml) for the current image name).
477+
There is a script [scripts/run-docker-local.sh](scripts/run-docker-local.sh) that runs the cypress image (see [CircleCI config](.circleci/config.yml) for the current image name).
478478

479479
The image will start and will map the root of the repository to `/cypress` inside the image. Now you can modify the files using your favorite environment and rerun tests inside the docker environment.
480480

guides/testing-other-projects.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Testing other projects
22

3-
In `develop`, `master`, and any other branch configured in [`circle.yml`](../circle.yml), the Cypress binary and npm package are built and uploaded to `cdn.cypress.io`. Then, tests are run, using a variety of real-world example repositories.
3+
In `develop`, `master`, and any other branch configured in [the CircleCI config](../.circleci/config.yml), the Cypress binary and npm package are built and uploaded to `cdn.cypress.io`. Then, tests are run, using a variety of real-world example repositories.
44

55
Two main strategies are used to spawn these test projects:
66

@@ -9,7 +9,7 @@ Two main strategies are used to spawn these test projects:
99

1010
## `test-binary-against-repo` jobs
1111

12-
A number of CI jobs in `circle.yml` clone test projects and run tests as part of `cypress-io/cypress`'s CI pipeline.
12+
A number of CI jobs in `.circleci/config.yml` clone test projects and run tests as part of `cypress-io/cypress`'s CI pipeline.
1313

1414
You can find a list of test projects that do this by searching for usage of the `test-binary-against-repo` step.
1515

@@ -19,4 +19,4 @@ One advantage to local CI is that it does not require creating commits to anothe
1919

2020
## `binary-system-tests`
2121

22-
System tests in `/system-tests/test-binary` are run against the built Cypress App in CI. For more details, see the [README](../system-tests/README.md).
22+
System tests in `/system-tests/test-binary` are run against the built Cypress App in CI. For more details, see the [README](../system-tests/README.md).

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"gulp:debug": "node --inspect-brk ./node_modules/.bin/gulp",
3737
"dev-debug": "node ./scripts/debug.js dev",
3838
"docker": "./scripts/run-docker-local.sh",
39-
"effective:circle:config": "circleci config process circle.yml | sed /^#/d",
4039
"ensure-deps": "./scripts/ensure-dependencies.sh",
4140
"get-next-version": "node scripts/get-next-version.js",
4241
"postinstall": "node ./scripts/run-postInstall.js",

packages/electron/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ Upgrading `electron` involves more than just bumping this package's `package.jso
4343
- [ ] [`/.node-version`](../../.node-version) - used by `nvm` and other Node version managers
4444
- [ ] [`/package.json`](../../package.json) - update `engines`
4545
- [ ] [`/scripts/run-docker-local.sh`](../../scripts/run-docker-local.sh) - update Docker image to the new matching `browsers` image
46-
- [ ] [`/circle.yml`](../../circle.yml)
46+
- [ ] [`/.circleci/config.yml`](../../.circleci/config.yml)
4747
- Update the Docker `image`s to the new matching `browsers` image.
4848
- Update the `xcode` version to one with the same major Node.js version bundled. There is usually not an exact match, this is ok as long as the major version number as the same.
4949
- [ ] Do a global search for the old Node.js version to identify any new areas that may need updating/unification, and update those locations (and this document!)
5050
- [ ] **Manually smoke test `cypress open`.** Upgrading Electron can break the `desktop-gui` in unexpected ways. Since testing in this area is weak, double-check that things like launching `cypress open`, signing into the Dashboard, and launching Electron tests still work.
51-
- [ ] **Fix failing tests.** Usually, these are due to breaking changes in either Node.js or Electron. Check the changelogs of both to find relevant changes.
51+
- [ ] **Fix failing tests.** Usually, these are due to breaking changes in either Node.js or Electron. Check the changelogs of both to find relevant changes.

scripts/circle-env.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ async function readCircleEnv () {
4343
if (!circleEnv) throw new Error('No Environment object was found.')
4444

4545
// last-ditch effort to check that an empty circle env is accurately reflecting process.env (external PRs)
46-
if (process.env.CACHE_VERSION && Object.keys(circleEnv).length === 0) {
47-
throw new Error('CACHE_VERSION is set, but circleEnv is empty')
46+
if (process.env.COPY_CIRCLE_ARTIFACTS && Object.keys(circleEnv).length === 0) {
47+
throw new Error('COPY_CIRCLE_ARTIFACTS is set, but circleEnv is empty')
4848
}
4949

5050
return circleEnv

scripts/unit/circle-env-spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('circle-env', () => {
1212
})
1313

1414
beforeEach(() => {
15-
delete process.env.CACHE_VERSION
15+
delete process.env.COPY_CIRCLE_ARTIFACTS
1616
process.env.CI = 'true'
1717
process.env.CIRCLE_INTERNAL_CONFIG = '/foo.json'
1818
})
@@ -44,14 +44,14 @@ describe('circle-env', () => {
4444
await _checkCanaries()
4545
})
4646

47-
it('fails if CACHE_VERSION does exist', async () => {
48-
process.env.CACHE_VERSION = 'foo'
47+
it('fails if COPY_CIRCLE_ARTIFACTS does exist', async () => {
48+
process.env.COPY_CIRCLE_ARTIFACTS = 'foo'
4949

5050
try {
5151
await _checkCanaries()
5252
throw new Error('should not reach')
5353
} catch (err) {
54-
expect(err.message).to.include('CACHE_VERSION is set, but circleEnv is empty')
54+
expect(err.message).to.include('COPY_CIRCLE_ARTIFACTS is set, but circleEnv is empty')
5555
}
5656
})
5757
})

0 commit comments

Comments
 (0)