Build Linux Cypress in Docker for #217 (#220)

* deploy: working on linux build via Docker for #217

* reworking deploy links

* include register files from coffee and ts

* smoke test passes in docker container
This commit is contained in:
Gleb Bahmutov
2017-06-26 16:15:01 -04:00
committed by GitHub
parent dabde92154
commit 1638260656
12 changed files with 120 additions and 50 deletions
+25
View File
@@ -0,0 +1,25 @@
set e+x
echo "This script should be run from monorepo's root"
name=cypress/internal:chrome58
echo "Pulling CI container $name"
docker pull $name
echo "Starting Docker image with monorepo volume attached"
echo "In order to build Cypress Linux binary"
# for now just run shell in the Docker container
# and then the user can go through the deploy
docker run \
-e npm_config_loglevel='warn' \
-v $PWD:/home/person/cypress-monorepo \
-w /home/person/cypress-monorepo \
-it $name \
/bin/bash
# todo: grab / compute the version to build
# npm run deploy -- --platform linux --version 0.20.0
+11 -8
View File
@@ -386,23 +386,22 @@ class Base
new Promise (resolve, reject) =>
rand = "" + Math.random()
options = {
env: {
CYPRESS_ENV: "production"
}
}
cp.exec "#{@buildPathToAppExecutable()} --smoke-test --ping=#{rand}", options, (err, stdout, stderr) ->
cp.exec "#{@buildPathToAppExecutable()} --smoke-test --ping=#{rand}", (err, stdout, stderr) ->
stdout = stdout.replace(/\s/, "")
return reject(err) if err
if err
console.error("smoke test failed with error %s", err.message)
return reject(err)
if stdout isnt rand
throw new Error("Stdout: '#{stdout}' did not match the random number: '#{rand}'")
else
console.log("smokeTest passes")
resolve()
verifyAppPackage = =>
new Promise (resolve, reject) =>
console.log("verifyAppPackage")
cp.exec "#{@buildPathToAppExecutable()} --return-pkg", (err, stdout, stderr) ->
return reject(err) if err
@@ -411,12 +410,16 @@ class Base
try
expect(stdout.env).to.eq("production")
catch err
console.error("failed to verify app via --return-pkg")
console.log(stdout)
return reject(err)
console.log("app verified")
resolve()
smokeTest().then(verifyAppPackage)
smokeTest()
# TODO refactor verifying app package
# .then(verifyAppPackage)
cleanupCy: ->
appData.removeSymlink()
+22 -4
View File
@@ -13,12 +13,26 @@ coffee = require("@packages/coffee")
electron = require("@packages/electron")
packages = require("./util/packages")
Darwin = require("./darwin")
Linux = require("./linux")
fs = Promise.promisifyAll(fs)
log = (msg, platform) ->
console.log(chalk.yellow(msg), chalk.bgWhite(chalk.black(platform)))
runDarwinSmokeTest = ->
darwin = new Darwin("darwin")
darwin.runSmokeTest()
runLinuxSmokeTest = ->
linux = new Linux("linux")
linux.runSmokeTest()
smokeTests = {
darwin: runDarwinSmokeTest,
linux: runLinuxSmokeTest
}
module.exports = (platform, version) ->
## returns a path into the /dist directory
distDir = (args...) ->
@@ -35,7 +49,7 @@ module.exports = (platform, version) ->
when "darwin"
buildDir("Cypress.app", "Contents", "resources", "app", args...)
when "linux"
buildDir("Cypress", "resources", "app", args...)
buildDir("resources", "app", args...)
cleanupPlatform = ->
log("#cleanupPlatform", platform)
@@ -74,7 +88,10 @@ module.exports = (platform, version) ->
env: "production"
})
.then =>
str = "require('./packages/server')"
str = """
process.env.CYPRESS_ENV = 'production'
require('./packages/server')
"""
fs.outputFileAsync(distDir("index.js"), str)
@@ -156,8 +173,9 @@ module.exports = (platform, version) ->
runSmokeTest = ->
log("#runSmokeTest", platform)
darwin = new Darwin(platform)
darwin.runSmokeTest()
# console.log("skipping smoke test for now")
smokeTest = smokeTests[platform]
smokeTest()
Promise
.bind(@)
+3
View File
@@ -105,6 +105,9 @@ deploy = {
deploy: ->
## read off the argv
# to skip further questions like platform and version
# pass these as options like this
# npm run deploy -- --platform darwin --version 0.20.0
options = @parseOptions(process.argv)
askWhichPlatform(options.platform)
+5 -2
View File
@@ -18,7 +18,7 @@ class Linux extends Base
@buildPathToApp()
buildPathToApp: ->
path.join @buildPathToAppFolder(), "Cypress"
path.join @buildPathToAppFolder() #, "Cypress"
buildPathToAppExecutable: ->
path.join @buildPathToApp(), "Cypress"
@@ -40,12 +40,15 @@ class Linux extends Base
@tryXvfb(@_runFailingProjectTest)
tryXvfb: (p) ->
console.log("tryXvfb")
xvfb = new Xvfb()
xvfb = Promise.promisifyAll(xvfb)
xvfb.startAsync()
.then (xvfxProcess) =>
.then (xvfbProcess) =>
console.log("executing in xvfb process %j", xvfbProcess)
Promise.try(p.bind(@))
.finally ->
console.log("stopping xvfb")
xvfb.stopAsync()
runSmokeTest: ->
+10
View File
@@ -113,6 +113,14 @@ npmInstallAll = (pathToPackages) ->
.then ->
console.log("Finished NPM Installing", new Date() - started)
removePackageJson = (filename) ->
if filename.endsWith("/package.json") then path.dirname(filename) else filename
ensureFoundSomething = (files) ->
if files.length == 0
throw new Error("Could not find any files")
files
symlinkAll = (pathToDistPackages, pathTo) ->
console.log("symlink these packages", pathToDistPackages)
baseDir = path.dirname(pathTo())
@@ -122,6 +130,7 @@ symlinkAll = (pathToDistPackages, pathTo) ->
# console.log(pkg, dist)
## strip off the initial './'
## ./packages/foo -> node_modules/@packages/foo
pkg = removePackageJson(pkg)
dest = pathTo("node_modules", "@packages", path.basename(pkg))
console.log(toBase(pkg), "link ->", toBase(dest))
@@ -132,6 +141,7 @@ symlinkAll = (pathToDistPackages, pathTo) ->
)
glob(pathToDistPackages)
.then(ensureFoundSomething)
.map(symlink)
module.exports = {