Merge branch 'win-binary-495' into develop

This commit is contained in:
Gleb Bahmutov
2017-09-26 16:09:12 -04:00
committed by GitHub
10 changed files with 89 additions and 11 deletions

View File

@@ -17,6 +17,9 @@ electron = require("@packages/electron")
signOsxApp = require("electron-osx-sign")
debug = require("debug")("cypress:binary")
R = require("ramda")
la = require("lazy-ass")
check = require("check-more-types")
execa = require("execa")
meta = require("./meta")
smoke = require("./smoke")
@@ -48,6 +51,16 @@ buildCypressApp = (platform, version, options = {}) ->
log = _.partialRight(logger, platform)
testVersion = (folderNameFn) -> () ->
dir = folderNameFn()
la(check.unemptyString(dir), "missing folder for platform", platform)
console.log("testing package version in folder", dir)
execa("node", ["index.js", "--version"], {
cwd: dir
}).then (result) ->
# TODO validate version string
console.log(result.stdout)
canBuildInDocker = ->
platform is "linux" and os.platform() is "darwin"
@@ -74,7 +87,9 @@ buildCypressApp = (platform, version, options = {}) ->
log("skipClean")
return
cleanup = =>
cleanup = ->
dir = distDir()
la(check.unemptyString(dir), "empty dist dir", dir, "for platform", platform)
fs.removeAsync(distDir())
cleanup()
@@ -199,6 +214,9 @@ buildCypressApp = (platform, version, options = {}) ->
# hint: you can see all symlinks in the build folder
# using "find build/darwin/Cypress.app/ -type l -ls"
electronDistFolder = meta.buildAppDir(platform, "packages", "electron", "dist")
la(check.unemptyString(electronDistFolder),
"empty electron dist folder for platform", platform)
console.log("Removing unnecessary folder #{electronDistFolder}")
fs.removeAsync(electronDistFolder).catch(_.noop)
@@ -217,6 +235,7 @@ buildCypressApp = (platform, version, options = {}) ->
codeSign = ->
if platform isnt "darwin"
# do we need to code sign on Windows?
return Promise.resolve()
appFolder = meta.zipDir(platform)
@@ -253,9 +272,11 @@ buildCypressApp = (platform, version, options = {}) ->
.then(convertCoffeeToJs)
.then(removeTypeScript)
.then(cleanJs)
.then(elBuilder)
.then(testVersion(distDir))
.then(elBuilder) # should we delete everything in the buildDir()?
.then(removeDevElectronApp)
.then(copyPackageProxies(buildAppDir))
.then(testVersion(buildAppDir))
.then(runSmokeTests)
.then(codeSign) ## codesign after running smoke tests due to changing .cy
.then(verifyAppCanOpen)

View File

@@ -12,14 +12,17 @@ platforms = {
isValidPlatform = check.oneOf(R.values(platforms))
checkPlatform = (platform) ->
la(isValidPlatform(platform),
"invalid build platform", platform, "valid choices", R.values(platforms))
## returns a path into the /build directory
## the output folder should look something like this
## build/
## <platform>/ = linux or darwin
## ... platform-specific files
buildDir = (platform, args...) ->
la(isValidPlatform(platform),
"invalid build platform", platform, "valid choices", R.values(platforms))
checkPlatform(platform)
switch platform
when "darwin"
path.resolve("build", platform, args...)
@@ -30,31 +33,41 @@ buildDir = (platform, args...) ->
## returns a path into the /dist directory
distDir = (platform, args...) ->
checkPlatform(platform)
path.resolve("dist", platform, args...)
## returns folder to zip before uploading
zipDir = (platform) ->
checkPlatform(platform)
switch platform
when "darwin"
buildDir(platform, "Cypress.app")
when "linux"
buildDir(platform)
when "win32"
buildDir(platform)
## returns a path into the /build/*/app directory
## specific to each platform
buildAppDir = (platform, args...) ->
checkPlatform(platform)
switch platform
when "darwin"
buildDir(platform, "Cypress.app", "Contents", "resources", "app", args...)
when "linux"
buildDir(platform, "resources", "app", args...)
when "win32"
buildDir(platform, "resources", "app", args...)
buildAppExecutable = (platform) ->
checkPlatform(platform)
switch platform
when "darwin"
buildDir(platform, "Cypress.app", "Contents", "MacOS", "Cypress")
when "linux"
buildDir(platform, "Cypress")
when "win32"
buildDir(platform, "Cypress")
module.exports = {
isValidPlatform

View File

@@ -3,15 +3,25 @@ fse = require("fs-extra")
cp = require("child_process")
path = require("path")
Promise = require("bluebird")
os = require("os")
Fixtures = require("../../packages/server/test/support/helpers/fixtures")
fs = Promise.promisifyAll(fse)
canRecordVideo = () ->
os.platform() != "win32"
runSmokeTest = (buildAppExecutable) ->
new Promise (resolve, reject) ->
rand = "" + Math.random()
console.log("executable path #{buildAppExecutable}")
hasRightResponse = (stdout) ->
# there could be more debug lines in the output, so find 1 line with
# expected random value
lines = stdout.split('\n').map((s) -> s.trim())
return lines.includes(rand)
cp.exec "#{buildAppExecutable} --smoke-test --ping=#{rand}", (err, stdout, stderr) ->
stdout = stdout.replace(/\s/, "")
@@ -19,7 +29,7 @@ runSmokeTest = (buildAppExecutable) ->
console.error("smoke test failed with error %s", err.message)
return reject(err)
if stdout isnt rand
if !hasRightResponse(stdout)
throw new Error("Stdout: '#{stdout}' did not match the random number: '#{rand}'")
else
console.log("smokeTest passes")
@@ -31,11 +41,21 @@ runProjectTest = (buildAppExecutable, e2e) ->
new Promise (resolve, reject) ->
env = _.omit(process.env, "CYPRESS_ENV")
cp.spawn(buildAppExecutable, [
"--run-project=#{e2e}", "--spec=cypress/integration/simple_passing_spec.coffee"
], {
if !canRecordVideo()
console.log("cannot record video on this platform yet, disabling")
env.CYPRESS_VIDEO_RECORDING = "false"
args = [
"--run-project=#{e2e}",
"--spec=cypress/integration/simple_passing_spec.coffee"
]
options = {
stdio: "inherit", env: env
})
}
console.log("running project test")
console.log(buildAppExecutable, args.join(" "))
cp.spawn(buildAppExecutable, args, options)
.on "exit", (code) ->
if code is 0
resolve()