diff --git a/README.md b/README.md index c6ab3a3779..88b5ef53cc 100644 --- a/README.md +++ b/README.md @@ -190,4 +190,8 @@ npm run binary-upload -- --platform darwin --version 0.20.0 --zip cypress.zip ``` If something goes wrong, see debug messages using `DEBUG=cypress:binary ...` environment -variable +variable. + +Because we had many problems reliably zipping built binary, for now we need +to build both Mac and Linux binary from Mac (Linux binary is built using +a Docker container), then zip it **from Mac**, then upload it. diff --git a/package.json b/package.json index 260f190a2b..2ab888fea0 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "all": "node ./scripts/run.js", "test": "echo '⚠️ This root monorepo is only for local development and new contributions. There are no tests.'", "link": "node ./scripts/link-packages.js", - "postinstall": "npm run link && npm run all install && npm run build", + "postinstall": "echo 'root postinstall' && npm run link && npm run all install && npm run build", "clean-deps": "npm run all clean-deps", "docker": "./scripts/run-docker-local.sh", "build-linux-binary": "./scripts/build-linux-binary.sh", diff --git a/scripts/binary/build.coffee b/scripts/binary/build.coffee index ad4dffe64a..5fb8a45527 100644 --- a/scripts/binary/build.coffee +++ b/scripts/binary/build.coffee @@ -1,5 +1,6 @@ _ = require("lodash") fse = require("fs-extra") +os = require("os") del = require("del") path = require("path") cp = require("child_process") @@ -44,13 +45,31 @@ smokeTests = { # can pass options to better control the build # for example # skipClean - do not delete "dist" folder before build -module.exports = (platform, version, options = {}) -> +buildCypressApp = (platform, version, options = {}) -> distDir = _.partial(meta.distDir, platform) buildDir = _.partial(meta.buildDir, platform) buildAppDir = _.partial(meta.buildAppDir, platform) log = _.partialRight(logger, platform) + canBuildInDocker = -> + platform == "linux" && os.platform() == "darwin" + + badPlatformMismatch = -> + console.error("⛔️ cannot build #{platform} from #{os.platform()}") + console.error("⛔️ should use matching platform to build it") + console.error("program arguments") + console.error(process.argv) + + checkPlatform = -> + log("#checkPlatform") + if platform == os.platform() then return + + console.log("trying to build #{platform} from #{os.platform()}") + if platform == "linux" && os.platform() == "darwin" + console.log("try running ./scripts/build-linux-binary.sh") + Promise.reject(new Error("Build platform mismatch")) + cleanupPlatform = -> log("#cleanupPlatform") @@ -215,6 +234,7 @@ module.exports = (platform, version, options = {}) -> reject new Error("Verifying App via GateKeeper failed") Promise.resolve() + .then(checkPlatform) .then(cleanupPlatform) .then(buildPackages) .then(copyPackages) @@ -238,3 +258,5 @@ module.exports = (platform, version, options = {}) -> .return({ buildDir: buildDir() }) + +module.exports = buildCypressApp diff --git a/scripts/binary/util/packages.coffee b/scripts/binary/util/packages.coffee index a009a943b0..63e279ffbd 100644 --- a/scripts/binary/util/packages.coffee +++ b/scripts/binary/util/packages.coffee @@ -29,10 +29,10 @@ npmRun = (args, cwd) -> reject(new Error(msg)) -runAllBuildJs = _.partial(npmRun, ["run", "all", "build-js"]) +runAllBuildJs = _.partial(npmRun, ["run", "all", "build-js", "--skip-packages", "cli,docs"]) # removes transpiled JS files in the original package folders -runAllCleanJs = _.partial(npmRun, ["run", "all", "clean-js"]) +runAllCleanJs = _.partial(npmRun, ["run", "all", "clean-js", "--skip-packages", "cli,docs"]) # builds all the packages except for cli and docs runAllBuild = _.partial(npmRun, @@ -100,7 +100,7 @@ npmInstallAll = (pathToPackages) -> retryNpmInstall = (pkg) -> - npmInstall = _.partial(npmRun, ["install", "--production"]) + npmInstall = _.partial(npmRun, ["install", "--production", "--quiet"]) npmInstall(pkg) .catch {code: "EMFILE"}, -> Promise @@ -114,7 +114,7 @@ npmInstallAll = (pathToPackages) -> ## prunes out all of the devDependencies ## from what was copied retryGlobbing() - .map(retryNpmInstall) + .mapSeries(retryNpmInstall) .then -> console.log("Finished NPM Installing", new Date() - started) diff --git a/scripts/binary/zip.coffee b/scripts/binary/zip.coffee index 38895754f1..a203cb3693 100644 --- a/scripts/binary/zip.coffee +++ b/scripts/binary/zip.coffee @@ -43,7 +43,7 @@ linuxZip = (src, dest) -> ) zippers = { - linux: linuxZip + linux: macZip darwin: macZip } diff --git a/scripts/build-linux-binary.sh b/scripts/build-linux-binary.sh index fdad982383..70defc7d3c 100755 --- a/scripts/build-linux-binary.sh +++ b/scripts/build-linux-binary.sh @@ -1,4 +1,4 @@ -set e+x +#!/bin/bash echo "This script should be run from monorepo's root" @@ -9,6 +9,7 @@ docker pull $name echo "Starting Docker image with monorepo volume attached" echo "In order to build Cypress Linux binary" +echo Command npm run binary-build -- "$@" # for now just run shell in the Docker container # and then the user can go through the deploy @@ -17,9 +18,8 @@ docker run \ -v $PWD:/home/person/cypress-monorepo \ -w /home/person/cypress-monorepo \ -it $name \ - /bin/bash - + npm run binary-build -- "$@" +# /bin/bash # todo: grab / compute the version to build -# npm run deploy -- --platform linux --version 0.20.0 diff --git a/scripts/run-all.js b/scripts/run-all.js index ae280347f4..c878055538 100644 --- a/scripts/run-all.js +++ b/scripts/run-all.js @@ -91,6 +91,7 @@ const mapTasks = (cmd, packages) => { runCommand = `run ${cmd}` } + console.log("filtered packages:", packages.join(", ")) return packages.map((dir, index) => { const packageName = packageNameFromPath(dir) return {