mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-26 19:09:32 -06:00
chore: use a file for cache versioning and not env (#23811)
Co-authored-by: Rachel <Raquel.rudermano@gmail.com>
This commit is contained in:
3
.circleci/cache-version.txt
Normal file
3
.circleci/cache-version.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
# Bump this version to force CI to re-create the cache from scratch.
|
||||
|
||||
9-13-22
|
||||
@@ -224,7 +224,7 @@ commands:
|
||||
command: node ./scripts/get-platform-key.js > 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-{{ checksum "circle_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
- run:
|
||||
name: Move node_modules back from /tmp
|
||||
command: |
|
||||
@@ -251,7 +251,7 @@ commands:
|
||||
- restore_cache:
|
||||
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{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
|
||||
update_cached_system_tests_deps:
|
||||
description: 'Update the cached node_modules for projects in "system-tests/projects/**"'
|
||||
@@ -265,7 +265,7 @@ commands:
|
||||
- restore_cache:
|
||||
name: Restore cache state, to check for known modules cache existence
|
||||
keys:
|
||||
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
- v{{ checksum ".circleci/cache-version.txt" }}-{{ 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-honeycomb-event.js
|
||||
@@ -279,20 +279,20 @@ commands:
|
||||
- restore_cache:
|
||||
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-
|
||||
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-
|
||||
- run:
|
||||
name: Update system-tests node_modules cache
|
||||
command: yarn workspace @tooling/system-tests projects:yarn:install
|
||||
- save_cache:
|
||||
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" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
paths:
|
||||
- /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" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-system-tests-projects-node-modules-cache-{{ checksum "system_tests_cache_key" }}
|
||||
paths:
|
||||
- /tmp/system_tests_node_modules_installed
|
||||
|
||||
@@ -312,7 +312,7 @@ commands:
|
||||
command: node ./scripts/get-platform-key.js > platform_key
|
||||
- restore_cache:
|
||||
name: Restore cache state, to check for known modules cache existence
|
||||
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
- run:
|
||||
name: Bail if cache exists
|
||||
command: |
|
||||
@@ -324,7 +324,7 @@ commands:
|
||||
- restore_cache:
|
||||
name: Restore weekly yarn cache
|
||||
keys:
|
||||
- v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
|
||||
- v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
|
||||
- run:
|
||||
name: Install Node Modules
|
||||
command: |
|
||||
@@ -341,7 +341,7 @@ commands:
|
||||
steps:
|
||||
- save_cache:
|
||||
name: Saving node modules for root, cli, and all globbed workspace packages
|
||||
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
paths:
|
||||
- node_modules
|
||||
- cli/node_modules
|
||||
@@ -352,18 +352,18 @@ commands:
|
||||
steps:
|
||||
- save_cache:
|
||||
name: Saving node modules for root, cli, and all globbed workspace packages
|
||||
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
paths:
|
||||
- /tmp/node_modules_cache
|
||||
- run: touch node_modules_installed
|
||||
- save_cache:
|
||||
name: Saving node-modules cache state key
|
||||
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-state-of-node-modules-cache-{{ checksum "circle_cache_key" }}
|
||||
paths:
|
||||
- node_modules_installed
|
||||
- save_cache:
|
||||
name: Save weekly yarn cache
|
||||
key: v{{ .Environment.CACHE_VERSION }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
|
||||
key: v{{ checksum ".circleci/cache-version.txt" }}-{{ checksum "platform_key" }}-deps-root-weekly-{{ checksum "cache_date" }}
|
||||
paths:
|
||||
- ~/.yarn
|
||||
- ~/.cy-npm-cache
|
||||
@@ -461,7 +461,7 @@ There are also a set of system tests in [`system-tests`](system-tests) which att
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
If you're curious how we manage all of these tests in CI check out our [CircleCI config](.circleci/config.yml).
|
||||
|
||||
#### Docker
|
||||
|
||||
@@ -474,7 +474,7 @@ Sometimes tests pass locally, but fail in CI. Our CI environment is dockerized.
|
||||
$ yarn docker
|
||||
```
|
||||
|
||||
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).
|
||||
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).
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Testing other projects
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Two main strategies are used to spawn these test projects:
|
||||
|
||||
@@ -9,7 +9,7 @@ Two main strategies are used to spawn these test projects:
|
||||
|
||||
## `test-binary-against-repo` jobs
|
||||
|
||||
A number of CI jobs in `circle.yml` clone test projects and run tests as part of `cypress-io/cypress`'s CI pipeline.
|
||||
A number of CI jobs in `.circleci/config.yml` clone test projects and run tests as part of `cypress-io/cypress`'s CI pipeline.
|
||||
|
||||
You can find a list of test projects that do this by searching for usage of the `test-binary-against-repo` step.
|
||||
|
||||
@@ -19,4 +19,4 @@ One advantage to local CI is that it does not require creating commits to anothe
|
||||
|
||||
## `binary-system-tests`
|
||||
|
||||
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).
|
||||
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).
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
"gulp:debug": "node --inspect-brk ./node_modules/.bin/gulp",
|
||||
"dev-debug": "node ./scripts/debug.js dev",
|
||||
"docker": "./scripts/run-docker-local.sh",
|
||||
"effective:circle:config": "circleci config process circle.yml | sed /^#/d",
|
||||
"ensure-deps": "./scripts/ensure-dependencies.sh",
|
||||
"get-next-version": "node scripts/get-next-version.js",
|
||||
"postinstall": "node ./scripts/run-postInstall.js",
|
||||
|
||||
@@ -43,9 +43,9 @@ Upgrading `electron` involves more than just bumping this package's `package.jso
|
||||
- [ ] [`/.node-version`](../../.node-version) - used by `nvm` and other Node version managers
|
||||
- [ ] [`/package.json`](../../package.json) - update `engines`
|
||||
- [ ] [`/scripts/run-docker-local.sh`](../../scripts/run-docker-local.sh) - update Docker image to the new matching `browsers` image
|
||||
- [ ] [`/circle.yml`](../../circle.yml)
|
||||
- [ ] [`/.circleci/config.yml`](../../.circleci/config.yml)
|
||||
- Update the Docker `image`s to the new matching `browsers` image.
|
||||
- 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.
|
||||
- [ ] 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!)
|
||||
- [ ] **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.
|
||||
- [ ] **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.
|
||||
- [ ] **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.
|
||||
|
||||
@@ -43,8 +43,8 @@ async function readCircleEnv () {
|
||||
if (!circleEnv) throw new Error('No Environment object was found.')
|
||||
|
||||
// last-ditch effort to check that an empty circle env is accurately reflecting process.env (external PRs)
|
||||
if (process.env.CACHE_VERSION && Object.keys(circleEnv).length === 0) {
|
||||
throw new Error('CACHE_VERSION is set, but circleEnv is empty')
|
||||
if (process.env.COPY_CIRCLE_ARTIFACTS && Object.keys(circleEnv).length === 0) {
|
||||
throw new Error('COPY_CIRCLE_ARTIFACTS is set, but circleEnv is empty')
|
||||
}
|
||||
|
||||
return circleEnv
|
||||
|
||||
@@ -12,7 +12,7 @@ describe('circle-env', () => {
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
delete process.env.CACHE_VERSION
|
||||
delete process.env.COPY_CIRCLE_ARTIFACTS
|
||||
process.env.CI = 'true'
|
||||
process.env.CIRCLE_INTERNAL_CONFIG = '/foo.json'
|
||||
})
|
||||
@@ -44,14 +44,14 @@ describe('circle-env', () => {
|
||||
await _checkCanaries()
|
||||
})
|
||||
|
||||
it('fails if CACHE_VERSION does exist', async () => {
|
||||
process.env.CACHE_VERSION = 'foo'
|
||||
it('fails if COPY_CIRCLE_ARTIFACTS does exist', async () => {
|
||||
process.env.COPY_CIRCLE_ARTIFACTS = 'foo'
|
||||
|
||||
try {
|
||||
await _checkCanaries()
|
||||
throw new Error('should not reach')
|
||||
} catch (err) {
|
||||
expect(err.message).to.include('CACHE_VERSION is set, but circleEnv is empty')
|
||||
expect(err.message).to.include('COPY_CIRCLE_ARTIFACTS is set, but circleEnv is empty')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user