Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into isolated-runner-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kuceb committed Mar 27, 2020
2 parents 8031a43 + 7afe4f8 commit d1bc9ea
Show file tree
Hide file tree
Showing 170 changed files with 4,450 additions and 2,739 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ packages/server/test/support/fixtures/projects/e2e/cypress/integration/stdout_ex
**/.vscode
**/.history
**/.cy
**/.git
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ install:
- print-env APPVEYOR
# prints if we have sensitive variables that start with a prefix GH
# which are used to trigger other projects
- has-env GH
# ignore errors - forked pull requests will NOT have these variables set
- has-env GH || true
# clean cache to prevent install permission issues
- yarn cache clean
- yarn --frozen-lockfile || yarn --frozen-lockfile || yarn --frozen-lockfile
Expand Down
60 changes: 42 additions & 18 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ macBuildFilters: &macBuildFilters
branches:
only:
- develop
- try-new-electron-sign

defaults: &defaults
parallelism: 1
Expand Down Expand Up @@ -319,7 +320,8 @@ jobs:
command: ls -la types
working_directory: cli
- run:
command: yarn lerna exec --scope cypress "yarn dtslint"
# Run dtslint, but permit failures for now as per https://github.com/cypress-io/cypress/pull/6819
command: yarn lerna exec --scope cypress "yarn dtslint" || true
- run:
command: yarn type-check --ignore-progress
- store-npm-logs
Expand Down Expand Up @@ -651,6 +653,11 @@ jobs:
at: ~/
- run:
command: yarn workspace @packages/desktop-gui build-prod
- run:
name: Desktop GUI server
command: yarn start
working_directory: packages/desktop-gui
background: true
- run:
command: |
CYPRESS_KONFIG_ENV=production \
Expand All @@ -662,6 +669,27 @@ jobs:
path: /tmp/artifacts
- store-npm-logs

desktop-gui-visual-tests:
<<: *defaults
parallelism: 1
steps:
- attach_workspace:
at: ~/
- run:
command: yarn lerna exec --scope @packages/desktop-gui "yarn build-prod"
- run:
name: Desktop GUI server
command: yarn start
working_directory: packages/desktop-gui
background: true
- run:
# will use PERCY_TOKEN environment variable if available
command: |
CYPRESS_KONFIG_ENV=production \
yarn lerna exec --scope @packages/desktop-gui "yarn percy exec -- yarn cypress:run --spec cypress/integration/settings_spec.js"
# we don't really need any artifacts - we are only interested in visual screenshots
- store-npm-logs

"reporter-integration-tests":
<<: *defaults
steps:
Expand Down Expand Up @@ -744,6 +772,11 @@ jobs:
- run:
environment:
DEBUG: electron-builder,electron-osx-sign*
# notarization on Mac can take a while
no_output_timeout: "30m"
# if this is a forked pull request, the NEXT_DEV_VERSION environment variable
# won't be set and we will use default version, since we are not going to
# upload the dev binary build anywhere
command: yarn binary-build --platform $PLATFORM --version ${NEXT_DEV_VERSION:-0.0.0-development}
- run: yarn binary-zip --platform $PLATFORM
# Cypress binary file should be zipped to cypress.zip
Expand Down Expand Up @@ -1279,6 +1312,9 @@ linux-workflow: &linux-workflow
- desktop-gui-integration-tests-2x:
requires:
- build
- desktop-gui-visual-tests:
requires:
- build
- reporter-integration-tests:
requires:
- build
Expand Down Expand Up @@ -1423,25 +1459,19 @@ mac-workflow: &mac-workflow
executor: mac
requires:
- Mac build
filters:
branches:
only:
- develop
<<: *macBuildFilters

- upload-npm-package:
name: Mac NPM package upload
context: test-runner:upload
executor: mac
filters:
branches:
only:
- develop
<<: *macBuildFilters
requires:
- Mac NPM package

- build-binary:
name: Mac binary
context: org-global
context: test-runner:sign-mac-binary
executor: mac
<<: *macBuildFilters
requires:
Expand All @@ -1451,10 +1481,7 @@ mac-workflow: &mac-workflow
name: Mac binary upload
executor: mac
context: test-runner:upload
filters:
branches:
only:
- develop
<<: *macBuildFilters
requires:
- Mac binary

Expand All @@ -1468,10 +1495,7 @@ mac-workflow: &mac-workflow
- test-binary-against-kitchensink:
name: Test Mac binary against kitchensink
executor: mac
filters:
branches:
only:
- develop
<<: *macBuildFilters
requires:
- Mac NPM package
- Mac binary
Expand Down
4 changes: 4 additions & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ yarn test-debug --scope cypress

This will take and compare snapshots of the CLI output. To update snapshots, see `snap-shot-it` instructions: https://github.com/bahmutov/snap-shot-it#advanced-use

#### Type Linting

When testing with `dtslint`, you may need to remove existing typescript installations before running the type linter (for instance, on OS X, you might `rm -rf ~/.dts/typescript-installs`) in order to reproduce issues with new versions of typescript (i.e., `@next`).

### Manual

To build and test an NPM package:
Expand Down
19 changes: 19 additions & 0 deletions cli/__snapshots__/spawn_spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
exports['lib/exec/spawn .start forces colors and streams when supported 1'] = {
"FORCE_COLOR": "1",
"DEBUG_COLORS": "1",
"MOCHA_COLORS": "1",
"FORCE_STDIN_TTY": "1",
"FORCE_STDOUT_TTY": "1",
"FORCE_STDERR_TTY": "1",
"NODE_OPTIONS": "--max-http-header-size=1048576 --http-parser=legacy"
}

exports['lib/exec/spawn .start does not force colors and streams when not supported 1'] = {
"FORCE_COLOR": "0",
"DEBUG_COLORS": "0",
"FORCE_STDIN_TTY": "0",
"FORCE_STDOUT_TTY": "0",
"FORCE_STDERR_TTY": "0",
"NODE_OPTIONS": "--max-http-header-size=1048576 --http-parser=legacy"
}

exports['lib/exec/spawn .start detects kill signal exits with error on SIGKILL 1'] = `
The Test Runner unexpectedly exited via a exit event with signal SIGKILL
Expand Down
2 changes: 1 addition & 1 deletion cli/lib/exec/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {
}

const { onStderrData, electronLogging } = overrides
const envOverrides = util.getEnvOverrides()
const envOverrides = util.getEnvOverrides(options)
const electronArgs = _.clone(args)
const node11WindowsFix = isPlatform('win32')

Expand Down
2 changes: 1 addition & 1 deletion cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const os = require('os')
const url = require('url')
const path = require('path')
const debug = require('debug')('cypress:cli')
const request = require('request')
const request = require('@cypress/request')
const Promise = require('bluebird')
const requestProgress = require('request-progress')
const { stripIndent } = require('common-tags')
Expand Down
28 changes: 27 additions & 1 deletion cli/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const util = {
return isCi
},

getEnvOverrides () {
getEnvOverrides (options = {}) {
return _
.chain({})
.extend(util.getEnvColors())
Expand All @@ -277,9 +277,35 @@ const util = {
.mapValues((value) => { // stringify to 1 or 0
return value ? '1' : '0'
})
.extend(util.getNodeOptions(options))
.value()
},

getNodeOptions (options, nodeVersion) {
if (!nodeVersion) {
nodeVersion = Number(process.versions.node.split('.')[0])
}

if (options.dev && nodeVersion < 12) {
// `node` is used instead of Electron when --dev is passed, so this won't work if Node is too old
debug('NODE_OPTIONS=--max-http-header-size could not be set because we\'re in dev mode and Node is < 12.0.0')

return
}

// https://github.com/cypress-io/cypress/issues/5431
const NODE_OPTIONS = `--max-http-header-size=${1024 ** 2} --http-parser=legacy`

if (_.isString(process.env.NODE_OPTIONS)) {
return {
NODE_OPTIONS: `${NODE_OPTIONS} ${process.env.NODE_OPTIONS}`,
ORIGINAL_NODE_OPTIONS: process.env.NODE_OPTIONS || '',
}
}

return { NODE_OPTIONS }
},

getForceTty () {
return {
FORCE_STDIN_TTY: util.isTty(process.stdin.fd),
Expand Down
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@cypress/listr-verbose-renderer": "0.4.1",
"@cypress/request": "2.88.5",
"@cypress/xvfb": "1.2.4",
"@types/blob-util": "1.3.3",
"@types/bluebird": "3.5.29",
Expand All @@ -45,7 +46,7 @@
"eventemitter2": "4.1.2",
"execa": "1.0.0",
"executable": "4.1.1",
"extract-zip": "1.6.7",
"extract-zip": "1.7.0",
"fs-extra": "8.1.0",
"getos": "3.1.4",
"is-ci": "2.0.0",
Expand All @@ -59,7 +60,6 @@
"ospath": "1.2.2",
"pretty-bytes": "5.3.0",
"ramda": "0.26.1",
"request": "cypress-io/request#b5af0d1fa47eec97ba980cde90a13e69a2afcd16",
"request-progress": "3.0.0",
"supports-color": "7.1.0",
"tmp": "0.1.0",
Expand Down
5 changes: 5 additions & 0 deletions cli/schema/cypress.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@
],
"default": "bundled",
"description": "If set to 'system', Cypress will try to find a Node.js executable on your path to use when executing your plugins. Otherwise, Cypress will use the Node version bundled with Cypress."
},
"experimentalGetCookiesSameSite": {
"type": "boolean",
"default": false,
"description": "If `true`, Cypress will add `sameSite` values to the objects yielded from `cy.setCookie()`, `cy.getCookie()`, and `cy.getCookies()`. This will become the default behavior in Cypress 5.0."
}
}
}
17 changes: 2 additions & 15 deletions cli/test/lib/exec/spawn_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,7 @@ describe('lib/exec/spawn', function () {

return spawn.start([], { env: {} })
.then(() => {
expect(cp.spawn.firstCall.args[2].env).to.deep.eq({
FORCE_COLOR: '1',
DEBUG_COLORS: '1',
MOCHA_COLORS: '1',
FORCE_STDERR_TTY: '1',
FORCE_STDIN_TTY: '1',
FORCE_STDOUT_TTY: '1',
})
snapshot(cp.spawn.firstCall.args[2].env)
})
})

Expand Down Expand Up @@ -368,13 +361,7 @@ describe('lib/exec/spawn', function () {

return spawn.start([], { env: {} })
.then(() => {
expect(cp.spawn.firstCall.args[2].env).to.deep.eq({
FORCE_COLOR: '0',
DEBUG_COLORS: '0',
FORCE_STDERR_TTY: '0',
FORCE_STDIN_TTY: '0',
FORCE_STDOUT_TTY: '0',
})
snapshot(cp.spawn.firstCall.args[2].env)
})
})

Expand Down
44 changes: 44 additions & 0 deletions cli/test/lib/util_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require('../spec_helper')
const os = require('os')
const tty = require('tty')
const snapshot = require('../support/snapshot')
const mockedEnv = require('mocked-env')
const supportsColor = require('supports-color')
const proxyquire = require('proxyquire')
const hasha = require('hasha')
Expand All @@ -11,6 +12,9 @@ const la = require('lazy-ass')
const util = require(`${lib}/util`)
const logger = require(`${lib}/logger`)

// https://github.com/cypress-io/cypress/issues/5431
const expectedNodeOptions = `--max-http-header-size=${1024 * 1024} --http-parser=legacy`

describe('util', () => {
beforeEach(() => {
sinon.stub(process, 'exit')
Expand Down Expand Up @@ -213,6 +217,7 @@ describe('util', () => {
FORCE_COLOR: '1',
DEBUG_COLORS: '1',
MOCHA_COLORS: '1',
NODE_OPTIONS: expectedNodeOptions,
})

util.supportsColor.returns(false)
Expand All @@ -224,7 +229,46 @@ describe('util', () => {
FORCE_STDERR_TTY: '0',
FORCE_COLOR: '0',
DEBUG_COLORS: '0',
NODE_OPTIONS: expectedNodeOptions,
})
})
})

context('.getNodeOptions', () => {
let restoreEnv

afterEach(() => {
if (restoreEnv) {
restoreEnv()
restoreEnv = null
}
})

it('adds required NODE_OPTIONS', () => {
restoreEnv = mockedEnv({
NODE_OPTIONS: undefined,
})

expect(util.getNodeOptions({})).to.deep.eq({
NODE_OPTIONS: expectedNodeOptions,
})
})

it('includes existing NODE_OPTIONS', () => {
restoreEnv = mockedEnv({
NODE_OPTIONS: '--foo --bar',
})

expect(util.getNodeOptions({})).to.deep.eq({
NODE_OPTIONS: `${expectedNodeOptions} --foo --bar`,
ORIGINAL_NODE_OPTIONS: '--foo --bar',
})
})

it('does not return if dev is set and version < 12', () => {
expect(util.getNodeOptions({
dev: true,
}, 11)).to.be.undefined
})
})

Expand Down
4 changes: 4 additions & 0 deletions cli/types/cypress-npm-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ declare module 'cypress' {
* Group recorded tests together under a single run name
*/
group: string
/**
* Tag string for the recorded run, like "production,nightly"
*/
tag: string
/**
* Display the browser instead of running headlessly
*/
Expand Down

0 comments on commit d1bc9ea

Please sign in to comment.