Files
cypress/scripts/binary/bump.coffee
Chris Breiding 6ba8d7cc93 Electron v5.0.10 (#4720)
* fix specs

* use debugger protocol for cookie handling in electron

* use latest gulp

* use rimraf instead of gulp-clean

* use electron 3.1.8 and node 10.2.1

* use gulp 4 in packages/static

* fix sendCommandAsync, log Schema.getDomains on CDP connect

* autofill e2e test name [skip ci]

* electron@5.0.7, see what new failures exist

* --no-sandbox for launching Electron

* update cookies logic for electron

* node 12

* update snapshot for new node

* update error message for new node

* stub sendCommandAsync

* only connect to socket if path has been replaced, fixes #4776

* update node-sass to support node 12

* skip wacky socket tests for now

* snapshot

* fix run_plugins_spec snapshot, don't include stack trace

* use --no-sandbox on linux to run as root

* allow sendCommandAsync to resolve

* use euid for root check

* log domains even if undefined

* don't worry about ending 1xx responses immediately anymore

* use --max-http-header-size, change max size from 8kb to 1mb, fix #76

* do not send 502 on failed websocket, just send back ECONNRESET

* update websocket spec port to not collide with other test

* update outdated expect

* Revert "only connect to socket if path has been replaced, fixes #4776"

This reverts commit f179eda5ca.

* update gulp in root

* update https-proxy unit tests

* update network spec to properly close server

* update reporter spec

* update https-proxy-agent to fix node 10.10.0 change

discussion: https://github.com/nodejs/node/issues/24474\#issuecomment-511963799

* only pass --max-http-header-size on node >=12

* use own server-destroy implementation that supports secureConnect events

* oops

* update socket_spec

* electron 6.0.0

* console.table introduced in node 10

* change browserify entry to init.js

* handle edge case when no response body

* console.table added in node 10

* do not exit app when all BrowserWindows are closed

* update e2e snapshots

* value may not be null

* update plugins spec

* correct cookie expiry, use browser.getversion for CDP version check

* fix snapshotting for require stacks

* reorder cookies in spec

* warn when depreated electron callback apis are used

* only report 1 plugin error per process

* cleanup

* node 12.4.0, cypress/browsers:node12.4.0-chrome76 docker image

* update shell.openExternal to promisified

* update dialog.showOpenDialog to promisified

* update webContents.session.setProxy to promisified

* updating native dependencies since we don't need ancient node ABI support anymore

* WIP: switch cookies to simpler, jar-less approach

* WIP: switch cookies to simpler, jar-less approach

* making tests pass

* improve cookie filtering logic

* Remove unneeded Promise.try

* filter what makes it to the extension

* properly re-set superdomain cookies on cross-origin cy.visit

* allow comma-separated list of e2e tests

* sort cookies in order of expiration date, ascending

* updating tests, cleanup

* update tests

* version electron as a devDependency, electron@6.0.1

* cleanup, remove old automation

* cleanup, remove old automation

* bump chokidar to fix win10 + node12 issue

was seeing this on windows:
https://github.com/nuxt/nuxt.js/issues/6035

fixed with version bump

* enable now-supported quit role, re-enable old tests

* don't need that arg there

* remove last deprecated callback electron invocations

* Delete cypress.json

* responding to PR feedback

* cleanup

* invoke

* use 'quit' role

* Use new appMenu role for Cypress menu on mac

* electron@6.0.2

* electron@6.0.3

* remove domain: cookie.domain and see what happens

* remove setErrorHandler

* Revert "remove domain: cookie.domain and see what happens"

This reverts commit 49e916896d.

* add unit tests for cookies

* ci

* fix project-content css

* electron@6.0.4

* fix specs_list test

* electron@6.0.7

* some cleanup

* electron@6.0.9

* Update 8_reporters_spec.coffee.js

* electron@5.0.10 - Chromium 73, Node 12

* cli: fix the STDIN pipe on Windows (#5045)

* cli: pipe stdin

* uggh, here is the actual change

* update cli unit tests

* add unit test

* more permissive check for json to include application/vnd.api+j… (#5166)

* more permissive check for json to include

* add json test for content-type application/vnd.api+json

* cruder solution passes e2e tests locally, so let's go with that

* Remove 'charset' from content-type before checking if JSON

* fix eslint for fixture specs (#5176)

* update eslint to lint files within 'fixtures' in support files

- ignore some edge cases like jquery, jsx and obvious js files we wrote
with broken code

* Fixes from eslint to 'fixtures' files

* Catch env variable with reserved name CYPRESS_ENV 1621 (#1626)

* server: check CYPRESS_ENV variable when merging configs

* catch invalid CYPRESS_ENV value in CLI, close #1621

* linting

* sanitize platform in test snapshot

* linting

* update error message text

* add missing comma

* fix finally merge in JS code

* pass CLI linter

* fix log reference, should be debug

* use correct sinon reference

* update message, show first part in red

* update error message text

* Addresses #2953 (#5174)

* Addresses #2953

* Added proper test for new error message

* Didn't realize it ran this test as well, whoops

* Implementing changes as suggested by @jennifer-shehane

* Fixing tests and error output. Moved the checks to the start of the get command to ensure we always catch improper options

* Removing issue test since the querying spec covers it

* Using coffescript isArray check

* depromisify things that were promisified b/t electron 5 <=> 6

Revert "update shell.openExternal to promisified"

This reverts commit 8b6460d015.

Revert "update dialog.showOpenDialog to promisified"

This reverts commit 5f178b075b.

Revert "update webContents.session.setProxy to promisified"

This reverts commit 727df3a4e5.

* node12.4.0-chrome76 => node12.0.0-chrome75

* fix tests for electron downgrade

* node12.0.0-chrome75 => node12.0.0-chrome73


Co-authored-by: Zach Bloomquist <github@chary.us>
Co-authored-by: Brian Mann <brian.mann86@gmail.com>
2019-09-24 14:35:24 -04:00

303 lines
9.0 KiB
CoffeeScript

_ = require("lodash")
fs = require("fs-extra")
Promise = require("bluebird")
bumpercar = require("@cypress/bumpercar")
path = require("path")
la = require('lazy-ass')
check = require('check-more-types')
R = require("ramda")
os = require("os")
{configFromEnvOrJsonFile, filenameToShellVariable} = require('@cypress/env-or-json-file')
makeEmptyGithubCommit = require("make-empty-github-commit")
parse = require("parse-github-repo-url")
{setCommitStatus} = require("@cypress/github-commit-status-check")
fs = Promise.promisifyAll(fs)
car = null
# all the projects to trigger / run / change environment variables for
_PROVIDERS = {
appVeyor: {
main: "cypress-io/cypress"
win32: [
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-example-repos"
]
}
circle: {
main: "cypress-io/cypress"
linux: [
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-module-api"
"cypress-io/cypress-test-node-versions"
"cypress-io/cypress-test-nested-projects"
"cypress-io/cypress-test-ci-environments"
"cypress-io/cypress-test-example-repos"
]
darwin: [
"cypress-io/cypress-test-tiny"
"cypress-io/cypress-test-example-repos"
]
}
}
remapProjects = (projectsByProvider) ->
list = []
_.mapValues projectsByProvider, (provider, name) ->
remapPlatform = (platform, repos) ->
repos.forEach (repo) ->
list.push({
repo
provider: name
platform
})
if provider.win32 then remapPlatform("win32", provider.win32)
if provider.linux then remapPlatform("linux", provider.linux)
if provider.darwin then remapPlatform("darwin", provider.darwin)
list
remapMain = (projectsByProvider) ->
list = []
_.mapValues projectsByProvider, (provider, name) ->
list.push({
repo: provider.main
provider: name
})
list
# make flat list of objects
# {repo, provider, platform}
PROJECTS = remapProjects(_PROVIDERS)
getCiConfig = ->
key = path.join("scripts", "support", "ci.json")
config = configFromEnvOrJsonFile(key)
if !config
console.error('⛔️ Cannot find CI credentials')
console.error('Using @cypress/env-or-json-file module')
console.error('and filename', key)
console.error('which is environment variable', filenameToShellVariable(key))
throw new Error('CI config not found')
config
awaitEachProjectAndProvider = (projects, fn, filter = R.identity) ->
creds = getCiConfig()
## configure a new Bumpercar
providers = {}
if check.unemptyString(creds.githubToken)
providers.travis = {
githubToken: creds.githubToken
}
if check.unemptyString(creds.circleToken)
providers.circle = {
circleToken: creds.circleToken
}
if check.unemptyString(creds.appVeyorToken)
providers.appVeyor = {
appVeyorToken: creds.appVeyorToken
}
if check.unemptyString(creds.buildkiteToken)
providers.buildkite = {
buildkiteToken: creds.buildkiteToken
}
providerNames = Object.keys(providers)
console.log("configured providers", providerNames)
la(check.not.empty(providerNames), "empty list of providers")
car = bumpercar.create({providers})
filteredProjects = R.filter(filter, projects)
if check.empty(filteredProjects)
console.log("⚠️ zero filtered projects left after filtering")
console.log("filtered projects:")
console.table(filteredProjects)
Promise.mapSeries filteredProjects, (project) ->
fn(project.repo, project.provider, creds)
# do not trigger all projects if there is specific provider
# for example appVeyor should be used for Windows testing
getFilterByProvider = (providerName, platformName) ->
if providerName
console.log("only allow projects for provider", providerName)
providerFilter = R.propEq("provider", providerName)
else
providerFilter = R.identity
if platformName
console.log("only allow projects for platform", platformName)
platformFilter = R.propEq("platform", platformName)
else
platformFilter = R.identity
# combined filter is when both filters pass
projectFilter = R.allPass([providerFilter, platformFilter])
projectFilter
module.exports = {
_PROVIDERS,
remapProjects,
getFilterByProvider,
nextVersion: (version) ->
MAIN_PROJECTS = remapMain(_PROVIDERS)
console.log("Setting next version to build", version)
console.log("In these projects:")
console.table(MAIN_PROJECTS)
la(check.unemptyString(version),
"missing next version to set", version)
setNextDevVersion = (project, provider) ->
console.log("setting env var NEXT_DEV_VERSION to %s on %s in project %s",
version, provider, project)
car.updateProjectEnv(project, provider, {
NEXT_DEV_VERSION: version,
})
awaitEachProjectAndProvider(MAIN_PROJECTS, setNextDevVersion)
# in each project, set a couple of environment variables
version: (nameOrUrl, binaryVersionOrUrl, platform, providerName) ->
console.log("All possible projects:")
console.table(PROJECTS)
la(check.unemptyString(nameOrUrl),
"missing cypress name or url to set", nameOrUrl)
if check.semver(nameOrUrl)
console.log("for version", nameOrUrl)
nameOrUrl = "cypress@#{nameOrUrl}"
console.log("full NPM install name is", nameOrUrl)
la(check.unemptyString(binaryVersionOrUrl),
"missing binary version or url", binaryVersionOrUrl)
result = {
versionName: nameOrUrl,
binary: binaryVersionOrUrl
}
projectFilter = getFilterByProvider(providerName)
updateProject = (project, provider) ->
console.log("setting environment variables in", project)
car.updateProjectEnv(project, provider, {
CYPRESS_NPM_PACKAGE_NAME: nameOrUrl,
CYPRESS_INSTALL_BINARY: binaryVersionOrUrl
})
awaitEachProjectAndProvider(PROJECTS, updateProject, projectFilter)
.then R.always(result)
# triggers test projects on multiple CIs
# the test projects will exercise the new version of
# the Cypress test runner we just built
runTestProjects: (getStatusAndMessage, providerName, version, platform) ->
projectFilter = getFilterByProvider(providerName, platform)
makeCommit = (project, provider, creds) ->
## make empty commit to trigger CIs
## project is owner/repo string like cypress-io/cypress-test-tiny
console.log("making commit to project", project)
# print if we have a few github variables present
console.log("do we have GH_APP_ID?", Boolean(process.env.GH_APP_ID))
console.log("do we have GH_INSTALLATION_ID?", Boolean(process.env.GH_INSTALLATION_ID))
console.log("do we have GH_PRIVATE_KEY?", Boolean(process.env.GH_PRIVATE_KEY))
parsedRepo = parse(project)
owner = parsedRepo[0]
repo = parsedRepo[1]
{ status, message } = getStatusAndMessage(repo)
if not message
message =
"""
Testing new Cypress version #{version}
"""
if process.env.CIRCLE_BUILD_URL
message += "\n"
message += "Circle CI build url #{process.env.CIRCLE_BUILD_URL}"
if process.env.APPVEYOR
slug = process.env.APPVEYOR_PROJECT_SLUG
build = process.env.APPVEYOR_BUILD_ID
message += "\n"
message += "AppVeyor CI #{slug} #{build}"
defaultOptions = {
owner,
repo,
message,
token: creds.githubToken,
}
createGithubCommitStatusCheck = ({ sha }) ->
return if not status
# status is {owner, repo, sha} and maybe a few other properties
isStatus = check.schema({
owner: check.unemptyString,
repo: check.unemptyString,
sha: check.commitId,
context: check.unemptyString,
platform: check.unemptyString,
arch: check.unemptyString
})
if not isStatus(status)
console.error("Invalid status object %o", status)
targetUrl = "https://github.com/#{owner}/#{repo}/commit/#{sha}"
commitStatusOptions = {
targetUrl,
owner: status.owner,
repo: status.repo,
sha: status.sha,
context: status.context,
state: 'pending',
description: "#{owner}/#{repo}",
}
console.log(
'creating commit status check',
commitStatusOptions.description,
commitStatusOptions.context
)
setCommitStatus(commitStatusOptions)
if not version
return makeEmptyGithubCommit(defaultOptions).then(createGithubCommitStatusCheck)
# first try to commit to branch for next upcoming version
specificBranchOptions = {
owner: owner,
repo: repo,
token: creds.githubToken,
message,
branch: version
}
makeEmptyGithubCommit(specificBranchOptions)
.catch () ->
# maybe there is no branch for next version
# try default branch
makeEmptyGithubCommit(defaultOptions)
.then(createGithubCommitStatusCheck)
awaitEachProjectAndProvider(PROJECTS, makeCommit, projectFilter)
}