Skip to content

Commit

Permalink
Merge branch 'develop' into ryanm/chore/create-start-of-v8-snapshot-s…
Browse files Browse the repository at this point in the history
…cript
  • Loading branch information
ryanthemanuel committed Dec 4, 2022
2 parents 359d0ad + 57b0eac commit a0c6ccb
Show file tree
Hide file tree
Showing 48 changed files with 716 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .circleci/cache-version.txt
@@ -1,3 +1,3 @@
# Bump this version to force CI to re-create the cache from scratch.

10-31-22
12-01-22
11 changes: 6 additions & 5 deletions .circleci/workflows.yml
Expand Up @@ -28,7 +28,7 @@ mainBuildFilters: &mainBuildFilters
only:
- develop
- /^release\/\d+\.\d+\.\d+$/
- 'feature/run-all-specs'
- 'ryanm/fix/v8-improvements'

# usually we don't build Mac app - it takes a long time
# but sometimes we want to really confirm we are doing the right thing
Expand All @@ -37,15 +37,15 @@ macWorkflowFilters: &darwin-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'feature/run-all-specs', << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand All @@ -63,6 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters
when:
or:
- equal: [ develop, << pipeline.git.branch >> ]
- equal: [ 'ryanm/fix/v8-improvements', << pipeline.git.branch >> ]
- matches:
pattern: /^release\/\d+\.\d+\.\d+$/
value: << pipeline.git.branch >>
Expand Down Expand Up @@ -128,7 +129,7 @@ commands:
- run:
name: Check current branch to persist artifacts
command: |
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* ]]; then
if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "ryanm/fix/v8-improvements" ]]; then
echo "Not uploading artifacts or posting install comment for this branch."
circleci-agent step halt
fi
Expand Down Expand Up @@ -1928,7 +1929,7 @@ jobs:
<<: *defaultsParameters
resource_class:
type: string
default: large
default: xlarge
resource_class: << parameters.resource_class >>
steps:
- restore_cached_workspace
Expand Down
7 changes: 7 additions & 0 deletions npm/cypress-schematic/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/schematic-v2.4.0](https://github.com/cypress-io/cypress/compare/@cypress/schematic-v2.3.0...@cypress/schematic-v2.4.0) (2022-12-02)


### Features

* Queries, Detached DOM, and Retry-Ability ([#24628](https://github.com/cypress-io/cypress/issues/24628)) ([9ae911f](https://github.com/cypress-io/cypress/commit/9ae911f396fa6cac0a1464537d1492d68cbb1898)), closes [#23665](https://github.com/cypress-io/cypress/issues/23665) [#24022](https://github.com/cypress-io/cypress/issues/24022) [#23791](https://github.com/cypress-io/cypress/issues/23791) [#24203](https://github.com/cypress-io/cypress/issues/24203) [#24417](https://github.com/cypress-io/cypress/issues/24417)

# [@cypress/schematic-v2.3.0](https://github.com/cypress-io/cypress/compare/@cypress/schematic-v2.2.0...@cypress/schematic-v2.3.0) (2022-11-01)


Expand Down
12 changes: 12 additions & 0 deletions npm/mount-utils/CHANGELOG.md
@@ -1,3 +1,15 @@
# [@cypress/mount-utils-v4.0.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v3.0.0...@cypress/mount-utils-v4.0.0) (2022-12-02)


### chore

* remove experimentalSessionAndOrigin flag ([#24340](https://github.com/cypress-io/cypress/issues/24340)) ([69873ae](https://github.com/cypress-io/cypress/commit/69873ae9884228f15310fd151e42cbc0cb712817))


### BREAKING CHANGES

* removed experimentalSessionAndOrigin flag. testIsolation defaults to strict

# [@cypress/mount-utils-v3.0.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.1.0...@cypress/mount-utils-v3.0.0) (2022-11-07)


Expand Down
7 changes: 7 additions & 0 deletions npm/react/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/react-v7.0.2](https://github.com/cypress-io/cypress/compare/@cypress/react-v7.0.1...@cypress/react-v7.0.2) (2022-12-02)


### Bug Fixes

* remove cypress.server.defaults, cy.server and cy.route ([#24411](https://github.com/cypress-io/cypress/issues/24411)) ([2f18a8c](https://github.com/cypress-io/cypress/commit/2f18a8cbd2d1a90fe1f77a29cdc89571bf54109e))

# [@cypress/react-v7.0.1](https://github.com/cypress-io/cypress/compare/@cypress/react-v7.0.0...@cypress/react-v7.0.1) (2022-11-08)


Expand Down
12 changes: 12 additions & 0 deletions npm/vite-dev-server/CHANGELOG.md
@@ -1,3 +1,15 @@
# [@cypress/vite-dev-server-v5.0.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v4.0.1...@cypress/vite-dev-server-v5.0.0) (2022-12-02)


### chore

* remove experimentalSessionAndOrigin flag ([#24340](https://github.com/cypress-io/cypress/issues/24340)) ([69873ae](https://github.com/cypress-io/cypress/commit/69873ae9884228f15310fd151e42cbc0cb712817))


### BREAKING CHANGES

* removed experimentalSessionAndOrigin flag. testIsolation defaults to strict

# [@cypress/vite-dev-server-v4.0.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v4.0.0...@cypress/vite-dev-server-v4.0.1) (2022-11-08)


Expand Down
7 changes: 7 additions & 0 deletions npm/vue/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/vue-v5.0.3](https://github.com/cypress-io/cypress/compare/@cypress/vue-v5.0.2...@cypress/vue-v5.0.3) (2022-12-02)


### Bug Fixes

* remove cypress.server.defaults, cy.server and cy.route ([#24411](https://github.com/cypress-io/cypress/issues/24411)) ([2f18a8c](https://github.com/cypress-io/cypress/commit/2f18a8cbd2d1a90fe1f77a29cdc89571bf54109e))

# [@cypress/vue-v5.0.2](https://github.com/cypress-io/cypress/compare/@cypress/vue-v5.0.1...@cypress/vue-v5.0.2) (2022-11-23)


Expand Down
7 changes: 7 additions & 0 deletions npm/webpack-batteries-included-preprocessor/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/webpack-batteries-included-preprocessor-v2.3.0](https://github.com/cypress-io/cypress/compare/@cypress/webpack-batteries-included-preprocessor-v2.2.4...@cypress/webpack-batteries-included-preprocessor-v2.3.0) (2022-12-02)


### Features

* Create public `Cypress.ensure` API for use with custom queries ([#24697](https://github.com/cypress-io/cypress/issues/24697)) ([8ff38cd](https://github.com/cypress-io/cypress/commit/8ff38cdb01adb1a4d317154d5baafa2eff5bad3d))

# [@cypress/webpack-batteries-included-preprocessor-v2.2.4](https://github.com/cypress-io/cypress/compare/@cypress/webpack-batteries-included-preprocessor-v2.2.3...@cypress/webpack-batteries-included-preprocessor-v2.2.4) (2022-11-23)


Expand Down
7 changes: 7 additions & 0 deletions npm/webpack-preprocessor/CHANGELOG.md
@@ -1,3 +1,10 @@
# [@cypress/webpack-preprocessor-v5.15.6](https://github.com/cypress-io/cypress/compare/@cypress/webpack-preprocessor-v5.15.5...@cypress/webpack-preprocessor-v5.15.6) (2022-12-02)


### Bug Fixes

* **breaking:** exclude node_modules from cross-origin-callback-loader ([#24952](https://github.com/cypress-io/cypress/issues/24952)) ([27c425d](https://github.com/cypress-io/cypress/commit/27c425dda318c316f751a000b77b39fe727999d5))

# [@cypress/webpack-preprocessor-v5.15.5](https://github.com/cypress-io/cypress/compare/@cypress/webpack-preprocessor-v5.15.4...@cypress/webpack-preprocessor-v5.15.5) (2022-11-10)


Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -4,7 +4,7 @@
"description": "Cypress is a next generation front end testing tool built for the modern web",
"private": true,
"scripts": {
"binary-build": "node ./scripts/binary.js build",
"binary-build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 node ./scripts/binary.js build",
"binary-deploy": "node ./scripts/binary.js deploy",
"binary-deploy-linux": "./scripts/build-linux-binary.sh",
"binary-ensure": "node ./scripts/binary.js ensure",
Expand Down Expand Up @@ -70,6 +70,7 @@
"prepare": "husky install"
},
"dependencies": {
"bytenode": "1.3.7",
"nvm": "0.0.4"
},
"devDependencies": {
Expand Down Expand Up @@ -140,6 +141,7 @@
"commander": "6.2.1",
"common-tags": "1.8.0",
"conventional-recommended-bump": "6.1.0",
"cross-env": "7.0.3",
"debug": "^4.3.2",
"dedent": "^0.7.0",
"del": "3.0.0",
Expand Down
9 changes: 2 additions & 7 deletions packages/rewriter/script/worker-shim.js
Expand Up @@ -3,13 +3,8 @@ if (process.env.CYPRESS_INTERNAL_ENV === 'production') {
throw new Error(`${__filename} should only run outside of prod`)
}

if (require.name !== 'customRequire') {
// Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism
const hook = './hook'
const { hookRequire } = require('@packages/server/hook-require')

const { hookRequire } = require(`@packages/server/${hook}-require`)

hookRequire(true)
}
hookRequire({ forceTypeScript: true })

require('../lib/threads/worker.ts')
6 changes: 3 additions & 3 deletions packages/server/hook-require.js
Expand Up @@ -9,7 +9,7 @@ function runWithSnapshot (forceTypeScript) {
const { snapshotRequire } = require('@packages/v8-snapshot-require')
const projectBaseDir = process.env.PROJECT_BASE_DIR

const supportTS = forceTypeScript || typeof global.snapshotResult === 'undefined' || global.supportTypeScript
const supportTS = forceTypeScript || typeof global.getSnapshotResult === 'undefined' || global.supportTypeScript

snapshotRequire(projectBaseDir, {
diagnosticsEnabled: isDev,
Expand All @@ -30,8 +30,8 @@ function runWithSnapshot (forceTypeScript) {
})
}

const hookRequire = (forceTypeScript) => {
if (['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE) || typeof snapshotResult === 'undefined') {
const hookRequire = ({ forceTypeScript }) => {
if (['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE) || typeof getSnapshotResult === 'undefined') {
require('@packages/ts/register')
} else {
runWithSnapshot(forceTypeScript)
Expand Down
21 changes: 11 additions & 10 deletions packages/server/index.js
@@ -1,18 +1,19 @@
const { initializeStartTime } = require('./lib/util/performance_benchmark')

const run = async () => {
initializeStartTime()
const startCypress = async () => {
try {
initializeStartTime()

if (require.name !== 'customRequire') {
// Purposefully make this a dynamic require so that it doesn't have the potential to get picked up by snapshotting mechanism
const hook = './hook'
const { hookRequire } = require('./hook-require')

const { hookRequire } = require(`${hook}-require`)
hookRequire({ forceTypeScript: false })

hookRequire(false)
await require('./start-cypress')
} catch (error) {
// eslint-disable-next-line no-console
console.error(error)
process.exit(1)
}

await require('./server-entry')
}

module.exports = run()
module.exports = startCypress()
5 changes: 3 additions & 2 deletions packages/server/package.json
Expand Up @@ -194,10 +194,11 @@
},
"files": [
"config",
"hook-require.js",
"lib",
"patches",
"server-entry.js",
"hook-require.js"
"start-cypress.js",
"v8-snapshot-entry.js"
],
"types": "index.d.ts",
"productName": "Cypress",
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/server/v8-snapshot-entry.js
@@ -0,0 +1 @@
require('./start-cypress')
4 changes: 2 additions & 2 deletions packages/ts/registerDir.js
Expand Up @@ -8,8 +8,8 @@ const path = require('path')
// build has been done correctly
module.exports = function (scopeDir) {
// Only set up ts-node if we're not using the snapshot
// @ts-ignore snapshotResult is a global defined in the v8 snapshot
if (['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE) || typeof snapshotResult === 'undefined') {
// @ts-ignore getSnapshotResult is a global defined in the v8 snapshot
if (['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE) || typeof getSnapshotResult === 'undefined') {
try {
// Prevent double-compiling if we're testing the app and already have ts-node hook installed
// TODO(tim): e2e testing does not like this, I guess b/c it's currently using the tsconfig
Expand Down
17 changes: 7 additions & 10 deletions packages/v8-snapshot-require/src/snapshot-require.ts
Expand Up @@ -181,8 +181,8 @@ export function snapshotRequire (
// 1. Assign snapshot which is a global if it was embedded
const sr: Snapshot =
opts.snapshotOverride ||
// @ts-ignore global snapshotResult
(typeof snapshotResult !== 'undefined' ? snapshotResult : undefined)
// @ts-ignore global getSnapshotResult
(typeof getSnapshotResult !== 'undefined' ? getSnapshotResult() : undefined)

// If we have no snapshot we don't need to hook anything
if (sr != null || alwaysHook) {
Expand Down Expand Up @@ -239,10 +239,7 @@ export function snapshotRequire (
moduleNeedsReload,
})

// @ts-ignore global snapshotResult
// 8. Ensure that the user passed the project base dir since the loader
// cannot resolve modules without it
if (typeof snapshotResult !== 'undefined') {
if (typeof sr !== 'undefined') {
const projectBaseDir = process.env.PROJECT_BASE_DIR

if (projectBaseDir == null) {
Expand Down Expand Up @@ -290,8 +287,8 @@ export function snapshotRequire (

// 11. Inject those globals

// @ts-ignore global snapshotResult
snapshotResult.setGlobals(
// @ts-ignore setGlobals is a function on global sr
sr.setGlobals(
global,
checked_process,
checked_window,
Expand All @@ -305,8 +302,8 @@ export function snapshotRequire (

// @ts-ignore private module var
require.cache = Module._cache
// @ts-ignore global snapshotResult
snapshotResult.customRequire.cache = require.cache
// @ts-ignore customRequire is a property of global sr
sr.customRequire.cache = require.cache

// 12. Add some 'magic' functions that we can use from inside the
// snapshot in order to integrate module loading
Expand Down
13 changes: 10 additions & 3 deletions scripts/after-pack-hook.js
Expand Up @@ -6,7 +6,8 @@ const os = require('os')
const path = require('path')
const { setupV8Snapshots } = require('@tooling/v8-snapshot')
const { flipFuses, FuseVersion, FuseV1Options } = require('@electron/fuses')
const { cleanup } = require('./binary/binary-cleanup')
const { buildEntryPointAndCleanup } = require('./binary/binary-cleanup')
const { getIntegrityCheckSource, getBinaryEntryPointSource } = require('./binary/binary-sources')

module.exports = async function (params) {
console.log('****************************')
Expand Down Expand Up @@ -55,6 +56,8 @@ module.exports = async function (params) {
}

if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) {
await fs.writeFile(path.join(outputFolder, 'index.js'), getBinaryEntryPointSource())

await flipFuses(
exePathPerPlatform[os.platform()],
{
Expand All @@ -63,7 +66,11 @@ module.exports = async function (params) {
},
)

await setupV8Snapshots(params.appOutDir)
await cleanup(outputFolder)
// Build out the entry point and clean up prior to setting up v8 snapshots so that the state of the binary is correct
await buildEntryPointAndCleanup(outputFolder)
await setupV8Snapshots({
cypressAppPath: params.appOutDir,
integrityCheckSource: getIntegrityCheckSource(outputFolder),
})
}
}

0 comments on commit a0c6ccb

Please sign in to comment.