form upload hash from CI environment vars if not set

This commit is contained in:
Gleb Bahmutov
2017-10-23 16:01:04 -04:00
parent f0814cc522
commit 6d64ca42d6
5 changed files with 22 additions and 9 deletions
+3
View File
@@ -73,6 +73,9 @@ uploadNpmPackage = (args = []) ->
la(isNpmPackageFile(options.file),
"invalid file to upload extension", options.file)
if not options.hash
options.hash = uploadUtils.formHashFromEnvironment()
la(check.unemptyString(options.hash), "missing hash to give", options)
la(check.unemptyString(options.version), "missing version", options)
@@ -76,6 +76,9 @@ uploadUniqueBinary = (args = []) ->
la(isBinaryFile(options.file),
"invalid file to upload extension", options.file)
if not options.hash
options.hash = uploadUtils.formHashFromEnvironment()
la(check.unemptyString(options.hash), "missing hash to give", options)
la(check.unemptyString(options.version), "missing version", options)
+12 -1
View File
@@ -10,6 +10,16 @@ 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 "#{env.BUILDKITE_BRANCH}-#{env.BUILDKITE_COMMIT}-#{env.BUILDKITE_BUILD_NUMBER}"
if env.CIRCLE
return "#{env.CIRCLE_BRANCH}-#{env.CIRCLE_SHA1}-#{env.CIRCLE_BUILD_NUM}"
if env.APPVEYOR
return "#{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 = () ->
## gleb: fix this plzzzzzz
old = process.cwd()
@@ -133,5 +143,6 @@ module.exports = {
purgeDesktopAppFromCache,
purgeDesktopAppAllPlatforms,
getUploadNameByOs,
saveUrl
saveUrl,
formHashFromEnvironment
}
+3 -5
View File
@@ -29,21 +29,19 @@ if (!shouldBuildBinary()) {
process.exit(0)
}
console.log('building binary')
console.log('building Windows binary')
const hash = `${process.env.APPVEYOR_REPO_BRANCH}-${process.env.APPVEYOR_REPO_COMMIT}-${process.env.APPVEYOR_BUILD_ID}`
const filename = `cypress-${process.env.NEXT_DEV_VERSION}.tgz`
const version = process.env.NEXT_DEV_VERSION
la(is.unemptyString(version), 'missing NEXT_DEV_VERSION')
console.log('building version', version)
console.log('upload hash', hash)
shell.exec(`node scripts/binary.js upload-npm-package --file cli/build/${filename} --version ${version} --hash ${hash}`)
shell.exec(`node scripts/binary.js upload-npm-package --file cli/build/${filename} --version ${version}`)
shell.cat('npm-package-url.json')
shell.exec(`npm run binary-build -- --platform windows --version ${version}`)
shell.exec('npm run binary-zip')
shell.ls('-l', '*.zip')
shell.exec(`node scripts/binary.js upload-unique-binary --file cypress.zip --version ${version} --hash ${hash}`)
shell.exec(`node scripts/binary.js upload-unique-binary --file cypress.zip --version ${version}`)
shell.cat('binary-url.json')
shell.exec('node scripts/test-other-projects.js --npm npm-package-url.json --binary binary-url.json --provider appVeyor')