Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanthemanuel committed Dec 1, 2022
1 parent ce8c74a commit fe8b6cd
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions packages/server/index.js
@@ -1,19 +1,19 @@
const { initializeStartTime } = require('./lib/util/performance_benchmark')

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

const { hookRequire } = require('./hook-require')

hookRequire({ forceTypeScript: false })

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

module.exports = run()
module.exports = startCypress()
6 changes: 3 additions & 3 deletions packages/server/package.json
Expand Up @@ -194,11 +194,11 @@
},
"files": [
"config",
"hook-require.js",
"lib",
"patches",
"server-entry.js",
"snapshot-entry.js",
"hook-require.js"
"start-cypress.js",
"v8-snapshot-entry.js"
],
"types": "index.d.ts",
"productName": "Cypress",
Expand Down
1 change: 0 additions & 1 deletion packages/server/snapshot-entry.js

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions packages/server/v8-snapshot-entry.js
@@ -0,0 +1 @@
require('./start-cypress')
5 changes: 3 additions & 2 deletions scripts/after-pack-hook.js
Expand Up @@ -6,7 +6,7 @@ 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) {
Expand Down Expand Up @@ -66,7 +66,8 @@ module.exports = async function (params) {
},
)

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) })
}
}
10 changes: 5 additions & 5 deletions scripts/binary/binary-cleanup.js
Expand Up @@ -80,7 +80,7 @@ const getDependencyPathsToKeep = async (buildAppDir) => {
absWorkingDir: unixBuildAppDir,
external: [
'./transpile-ts',
'./server-entry',
'./start-cypress',
'fsevents',
'pnpapi',
'@swc/core',
Expand Down Expand Up @@ -116,7 +116,7 @@ const getDependencyPathsToKeep = async (buildAppDir) => {
const createServerEntryPointBundle = async (buildAppDir) => {
const unixBuildAppDir = buildAppDir.split(path.sep).join(path.posix.sep)
const entryPoints = [path.join(unixBuildAppDir, 'packages/server/index.js')]
// Build the binary entry point ignoring anything that happens in the server-entry since that will be in the v8 snapshot
// Build the binary entry point ignoring anything that happens in start-cypress since that will be in the v8 snapshot
const esbuildResult = await esbuild.build({
entryPoints,
bundle: true,
Expand All @@ -126,7 +126,7 @@ const createServerEntryPointBundle = async (buildAppDir) => {
absWorkingDir: unixBuildAppDir,
external: [
'./transpile-ts',
'./server-entry',
'./start-cypress',
],
})

Expand All @@ -146,7 +146,7 @@ const createServerEntryPointBundle = async (buildAppDir) => {
return [...Object.keys(esbuildResult.metafile.inputs)].map((input) => `./${input}`)
}

const cleanup = async (buildAppDir) => {
const buildEntryPointAndCleanup = async (buildAppDir) => {
// 1. Retrieve all dependencies that still need to be kept in the binary. In theory, we could use the bundles generated here as single files within the binary,
// but for now, we just track on the dependencies that get pulled in
const keptDependencies = [...await getDependencyPathsToKeep(buildAppDir), 'package.json']
Expand Down Expand Up @@ -231,5 +231,5 @@ const cleanup = async (buildAppDir) => {
}

module.exports = {
cleanup,
buildEntryPointAndCleanup,
}
2 changes: 1 addition & 1 deletion scripts/binary/binary-integrity-check-source.js
Expand Up @@ -120,7 +120,7 @@ function integrityCheck (options) {
fileName: 'evalmachine.<anonymous>',
},
{
functionName: 'run',
functionName: 'startCypress',
fileName: 'evalmachine.<anonymous>',
},
{
Expand Down
6 changes: 3 additions & 3 deletions scripts/binary/binary-sources.js
Expand Up @@ -4,18 +4,18 @@ const path = require('path')

const escapeString = (string) => string.replaceAll(`\``, `\\\``).replaceAll(`$`, `\\$`)

function read ({ file }) {
function read (file) {
const pathToFile = require.resolve(`./${file}`)

return fs.readFileSync(pathToFile, 'utf8')
}

const getBinaryEntryPointSource = () => {
return read({ file: 'binary-entry-point-source.js' })
return read('binary-entry-point-source.js')
}

const getIntegrityCheckSource = (baseDirectory) => {
const fileSource = read({ file: 'binary-integrity-check-source.js' })
const fileSource = read('binary-integrity-check-source.js')
const secret = require('crypto').randomBytes(48).toString('hex')

const mainIndexHash = crypto.createHmac('md5', secret).update(fs.readFileSync(path.join(baseDirectory, './index.js'), 'utf8')).digest('hex')
Expand Down
Expand Up @@ -937,8 +937,8 @@
"./packages/server/node_modules/uuid/dist/v3.js",
"./packages/server/node_modules/uuid/dist/v4.js",
"./packages/server/node_modules/uuid/dist/v5.js",
"./packages/server/server-entry.js",
"./packages/server/snapshot-entry.js",
"./packages/server/start-cypress.js",
"./packages/server/v8-snapshot-entry.js",
"./packages/socket/index.js",
"./packages/socket/lib/socket.ts",
"./packages/socket/node_modules/socket.io/dist/broadcast-operator.js",
Expand Down
4 changes: 2 additions & 2 deletions tooling/v8-snapshot/cache/prod-linux/snapshot-meta.cache.json
Expand Up @@ -936,8 +936,8 @@
"./packages/server/node_modules/uuid/dist/v3.js",
"./packages/server/node_modules/uuid/dist/v4.js",
"./packages/server/node_modules/uuid/dist/v5.js",
"./packages/server/server-entry.js",
"./packages/server/snapshot-entry.js",
"./packages/server/start-cypress.js",
"./packages/server/v8-snapshot-entry.js",
"./packages/socket/index.js",
"./packages/socket/lib/socket.ts",
"./packages/socket/node_modules/socket.io/dist/broadcast-operator.js",
Expand Down
4 changes: 2 additions & 2 deletions tooling/v8-snapshot/cache/prod-win32/snapshot-meta.cache.json
Expand Up @@ -939,8 +939,8 @@
"./packages/server/node_modules/uuid/dist/v3.js",
"./packages/server/node_modules/uuid/dist/v4.js",
"./packages/server/node_modules/uuid/dist/v5.js",
"./packages/server/server-entry.js",
"./packages/server/snapshot-entry.js",
"./packages/server/start-cypress.js",
"./packages/server/v8-snapshot-entry.js",
"./packages/socket/index.js",
"./packages/socket/lib/socket.ts",
"./packages/socket/node_modules/socket.io/dist/broadcast-operator.js",
Expand Down
2 changes: 1 addition & 1 deletion tooling/v8-snapshot/src/setup/config.ts
Expand Up @@ -21,7 +21,7 @@ const platformString = process.platform
const snapshotCacheBaseDir = path.resolve(__dirname, '..', '..', 'cache')

const projectBaseDir = path.join(__dirname, '..', '..', '..', '..')
const appEntryFile = require.resolve('@packages/server/snapshot-entry.js')
const appEntryFile = require.resolve('@packages/server/v8-snapshot-entry')

const cypressAppSnapshotDir = (cypressAppPath?: string) => {
const electronPackageDir = path.join(projectBaseDir, 'packages', 'electron')
Expand Down

4 comments on commit fe8b6cd

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fe8b6cd Dec 1, 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 arm64 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/11.3.0/linux-arm64/ryanm/fix/v8-improvements-fe8b6cd8f5df54f9db4b8b87c6fa387217b0bf73/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fe8b6cd Dec 1, 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/11.3.0/linux-x64/ryanm/fix/v8-improvements-fe8b6cd8f5df54f9db4b8b87c6fa387217b0bf73/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fe8b6cd Dec 1, 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 arm64 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/11.3.0/darwin-arm64/ryanm/fix/v8-improvements-fe8b6cd8f5df54f9db4b8b87c6fa387217b0bf73/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on fe8b6cd Dec 1, 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/11.3.0/darwin-x64/ryanm/fix/v8-improvements-fe8b6cd8f5df54f9db4b8b87c6fa387217b0bf73/cypress.tgz

Please sign in to comment.