mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-16 04:00:01 -06:00
* appveyor build for this branch * don't force install ffmpeg on windows don't force install ffmpeg on windows * derp * fix * build in appveyor * oops * delete using del * use RMDIR instead of DEL * only build 32-bit * build for x64 and x86 windows * separate win32 and win64 * require lodash * make electron arch configurable * cross-compile 32, only run in 64-bit * force install ffmpeg if necessary * it's all win10 x64, but we can force it to build for ia32 in x32 mode * add windows util * who's idea was it to make whitespace meaningful? * pass arch to npm install, pass arch to uploader * add TARGET_PLATFORM * fun fact: appveyor titlecases env var names fun fact: appveyor titlecases env var names * fix: pass args * use process * cli: use arch package to send arch to server * pass TARGET_ARCH to all npm installs * run-all * always call getUploadNameByOs * use the precise version of node, enable both x64 and ia32 arch * quotes * uh wat * move console logs to script because windows * add yet another env var to install the right node arch * use x86, not x32 * give ia32 a try, why not * use platform env again * and also try x86 again * remove notion of target_arch since we're using the right node version with arch set correctly * more comprehensive checks to ensure the arch is correct * simplify building the binary, do not accept arch as options * build the binary and test it on this branch * remove arch, ensure that process.env.Platform is set to x86 * do build the binary unless this is a forked PR * attempt to verify that this is a 32bit or 64bit windows binary * remove unused dep * consolidate commands * don't install packages in windows - just build the binary - this avoids needing to reinstall all node_modules and build-js twice * build the binary on more branches * cd up appveyor * ugh * right logic for whether or not this is a forked PR * remove unused deps * fix undefined var * platformArch * set in options * turns out we do have to npm install before building the binary * options.platformArch * comment out appveyor build 32bit/64bit verification temporarily Co-authored-by: Brian Mann <brian.mann86@gmail.com>
159 lines
5.1 KiB
CoffeeScript
159 lines
5.1 KiB
CoffeeScript
_ = require("lodash")
|
|
path = require("path")
|
|
awspublish = require('gulp-awspublish')
|
|
human = require("human-interval")
|
|
la = require("lazy-ass")
|
|
check = require("check-more-types")
|
|
cp = require("child_process")
|
|
fs = require("fs")
|
|
os = require("os")
|
|
Promise = require("bluebird")
|
|
{configFromEnvOrJsonFile, filenameToShellVariable} = require('@cypress/env-or-json-file')
|
|
konfig = require("../../../packages/server/lib/konfig")
|
|
|
|
formHashFromEnvironment = () ->
|
|
env = process.env
|
|
if env.BUILDKITE
|
|
return "buildkite-#{env.BUILDKITE_BRANCH}-#{env.BUILDKITE_COMMIT}-#{env.BUILDKITE_BUILD_NUMBER}"
|
|
if env.CIRCLECI
|
|
return "circle-#{env.CIRCLE_BRANCH}-#{env.CIRCLE_SHA1}-#{env.CIRCLE_BUILD_NUM}"
|
|
if env.APPVEYOR
|
|
return "appveyor-#{env.APPVEYOR_REPO_BRANCH}-#{env.APPVEYOR_REPO_COMMIT}-#{env.APPVEYOR_BUILD_ID}"
|
|
|
|
throw new Error("Do not know how to form unique build hash on this CI")
|
|
|
|
getS3Credentials = () ->
|
|
key = path.join('scripts', 'support', 'aws-credentials.json')
|
|
config = configFromEnvOrJsonFile(key)
|
|
|
|
if !config
|
|
console.error('⛔️ Cannot find AWS credentials')
|
|
console.error('Using @cypress/env-or-json-file module')
|
|
console.error('and filename', key)
|
|
console.error('which is environment variable', filenameToShellVariable(key))
|
|
console.error('available environment variable keys')
|
|
console.error(Object.keys(process.env))
|
|
throw new Error('AWS config not found')
|
|
|
|
la(check.unemptyString(config.bucket), 'missing AWS config bucket')
|
|
la(check.unemptyString(config.folder), 'missing AWS config folder')
|
|
config
|
|
|
|
getPublisher = (getAwsObj = getS3Credentials) ->
|
|
aws = getAwsObj()
|
|
|
|
# console.log("aws.bucket", aws.bucket)
|
|
awspublish.create {
|
|
httpOptions: {
|
|
timeout: human("10 minutes")
|
|
}
|
|
params: {
|
|
Bucket: aws.bucket
|
|
}
|
|
accessKeyId: aws.key
|
|
secretAccessKey: aws.secret
|
|
}
|
|
|
|
hasCloudflareEnvironmentVars = () ->
|
|
check.unemptyString(process.env.CF_TOKEN) &&
|
|
check.unemptyString(process.env.CF_EMAIL) &&
|
|
check.unemptyString(process.env.CF_DOMAIN)
|
|
|
|
# depends on the credentials file or environment variables
|
|
makeCloudflarePurgeCommand = (url) ->
|
|
configFile = path.resolve(__dirname, "..", "support", ".cfcli.yml")
|
|
if fs.existsSync(configFile)
|
|
console.log("using CF credentials file")
|
|
return "cfcli purgefile -c #{configFile} #{url}"
|
|
else if hasCloudflareEnvironmentVars()
|
|
console.log("using CF environment variables")
|
|
token = process.env.CF_TOKEN
|
|
email = process.env.CF_EMAIL
|
|
domain = process.env.CF_DOMAIN
|
|
return "cfcli purgefile -e #{email} -k #{token} -d #{domain} #{url}"
|
|
else
|
|
throw new Error("Cannot form Cloudflare purge command without credentials")
|
|
|
|
# purges a given url from Cloudflare
|
|
purgeCache = (url) ->
|
|
la(check.url(url), "missing url to purge", url)
|
|
|
|
new Promise (resolve, reject) =>
|
|
console.log("purging url", url)
|
|
purgeCommand = makeCloudflarePurgeCommand(url)
|
|
cp.exec purgeCommand, (err, stdout, stderr) ->
|
|
if err
|
|
console.error("Could not purge #{url}")
|
|
console.error(err.message)
|
|
return reject(err)
|
|
console.log("#purgeCache: #{url}")
|
|
resolve()
|
|
|
|
getDestktopUrl = (version, osName, zipName) ->
|
|
url = [konfig("cdn_url"), "desktop", version, osName, zipName].join("/")
|
|
url
|
|
|
|
# purges desktop application url from Cloudflare cache
|
|
purgeDesktopAppFromCache = ({version, platform, zipName}) ->
|
|
la(check.unemptyString(version), "missing desktop version", version)
|
|
la(check.unemptyString(platform), "missing platform", platform)
|
|
la(check.unemptyString(zipName), "missing zip filename")
|
|
la(check.extension("zip", zipName),
|
|
"zip filename should end with .zip", zipName)
|
|
|
|
osName = getUploadNameByOsAndArch(platform)
|
|
la(check.unemptyString(osName), "missing osName", osName)
|
|
url = getDestktopUrl(version, osName, zipName)
|
|
purgeCache(url)
|
|
|
|
# purges links to desktop app for all platforms
|
|
# for a given version
|
|
purgeDesktopAppAllPlatforms = (version, zipName) ->
|
|
la(check.unemptyString(version), "missing desktop version", version)
|
|
la(check.unemptyString(zipName), "missing zipName", zipName)
|
|
|
|
platforms = ["darwin", "linux", "win32"]
|
|
console.log("purging all desktop links for version #{version} from Cloudflare")
|
|
Promise.mapSeries platforms, (platform) ->
|
|
purgeDesktopAppFromCache({version, platform, zipName})
|
|
|
|
getUploadNameByOsAndArch = (platform) ->
|
|
## just hard code for now...
|
|
arch = os.arch()
|
|
|
|
uploadNames = {
|
|
darwin: {
|
|
"x64": "osx64"
|
|
},
|
|
linux: {
|
|
"x64": "linux64"
|
|
},
|
|
win32: {
|
|
"x64": "win64",
|
|
"ia32": "win32"
|
|
}
|
|
}
|
|
name = _.get(uploadNames[platform], arch)
|
|
if not name
|
|
throw new Error("Cannot find upload name for OS: '#{platform}' with arch: '#{arch}'")
|
|
name
|
|
|
|
saveUrl = (filename) -> (url) ->
|
|
la(check.unemptyString(filename), "missing filename", filename)
|
|
la(check.url(url), "invalid url to save", url)
|
|
s = JSON.stringify({url})
|
|
fs.writeFileSync(filename, s)
|
|
console.log("saved url", url)
|
|
console.log("into file", filename)
|
|
|
|
module.exports = {
|
|
getS3Credentials,
|
|
getPublisher,
|
|
purgeCache,
|
|
purgeDesktopAppFromCache,
|
|
purgeDesktopAppAllPlatforms,
|
|
getUploadNameByOsAndArch,
|
|
saveUrl,
|
|
formHashFromEnvironment
|
|
}
|