Use 'platform-arch' naming scheme for downloads (#3998)

* use 'platform-arch' naming scheme for downloads

* do full builds for this branch

* Revert "do full builds for this branch"

This reverts commit 6d539513e7.

* update wrong comments

* chore: test upload getCDN functions

* linting js

* unit test refactored manifest

* linting
This commit is contained in:
Zach Bloomquist
2019-04-29 09:27:41 -07:00
committed by Gleb Bahmutov
parent c7f4feae26
commit 47e98fa1d0
12 changed files with 166 additions and 29 deletions

View File

@@ -19,14 +19,17 @@ uploadFileName = "cypress.tgz"
isNpmPackageFile = check.extension(npmPackageExtension)
# wonder if our CDN url would just work
# https://cdn.cypress.io/desktop/0.20.1/osx64/cypress.zip
# the package tgz file will be uploaded into unique folder
# in our case something like this
# https://cdn.cypress.io/beta/npm/0.20.2/<some unique version info>/cypress.tgz
npmFolder = "npm"
# https://cdn.cypress.io/beta/npm/<version>/<some unique hash>/cypress.tgz
rootFolder = "beta"
npmFolder = "npm"
getCDN = ({version, hash, filename}) ->
la(check.semver(version), 'invalid version', version)
la(check.unemptyString(hash), 'missing hash', hash)
la(check.unemptyString(filename), 'missing filename', filename)
la(isNpmPackageFile(filename), 'wrong extension for file', filename)
[konfig("cdn_url"), rootFolder, npmFolder, version, hash, filename].join("/")
getUploadDirName = (options) ->

View File

@@ -14,19 +14,24 @@ R = require("ramda")
konfig = require("../../packages/server/lib/konfig")
uploadUtils = require("./util/upload")
# we zip the binary on every platform and upload under same name
binaryExtension = ".zip"
uploadFileName = "cypress.zip"
isBinaryFile = check.extension(binaryExtension)
# wonder if our CDN url would just work
# https://cdn.cypress.io/desktop/0.20.1/osx64/cypress.zip
# in our case something like this
# https://cdn.cypress.io/desktop/binary/0.20.2/<platform>/<some unique version info>/cypress.tgz
rootFolder = "beta"
folder = "binary"
# the binary will be uploaded into unique folder
# in our case something like this
# https://cdn.cypress.io/desktop/binary/0.20.2/<platform>/<some unique version info>/cypress.zip
getCDN = ({version, hash, filename, platform}) ->
la(check.semver(version), 'invalid version', version)
la(check.unemptyString(hash), 'missing hash', hash)
la(check.unemptyString(filename), 'missing filename', filename)
la(isBinaryFile(filename), 'wrong extension for file', filename)
la(check.unemptyString(platform), 'missing platform', platform)
[konfig("cdn_url"), rootFolder, folder, version, platform, hash, filename].join("/")
getUploadDirName = (options) ->

View File

@@ -30,7 +30,7 @@ module.exports = {
uploadUtils.getS3Credentials()
# store uploaded application in subfolders by platform and version
# something like desktop/0.20.1/osx64/
# something like desktop/0.20.1/darwin-x64/
getUploadDirName: ({version, platform}) ->
aws = @getAwsObj()
platformArch = uploadUtils.getUploadNameByOsAndArch(platform)
@@ -38,31 +38,44 @@ module.exports = {
console.log("target directory %s", dirName)
dirName
createRemoteManifest: (folder, version) ->
getUrl = (uploadOsName) ->
{
url: [konfig('cdn_url'), folder, version, uploadOsName, zipName].join("/")
}
getManifestUrl: (folder, version, uploadOsName) ->
{
url: [konfig('cdn_url'), folder, version, uploadOsName, zipName].join("/")
}
obj = {
getRemoteManifest: (folder, version) ->
la(check.unemptyString(folder), 'missing manifest folder', folder)
la(check.semver(version), 'invalid manifest version', version)
getUrl = @getManifestUrl.bind(null, folder, version)
{
name: "Cypress"
version: version
packages: {
## keep these for compatibility purposes
## although they are now deprecated
mac: getUrl("osx64")
win: getUrl("win64")
linux64: getUrl("linux64")
mac: getUrl("darwin-x64")
win: getUrl("win32-ia32")
linux64: getUrl("linux-x64")
## start adding the new ones
## using node's platform
darwin: getUrl("osx64")
win32: getUrl("win32")
win64: getUrl("win64")
linux: getUrl("linux64")
darwin: getUrl("darwin-x64")
win32: getUrl("win32-ia32")
linux: getUrl("linux-x64")
## the new-new names that use platform and arch as is
"darwin-x64": getUrl("darwin-x64")
"linux-x64": getUrl("linux-x64")
"win32-ia32": getUrl("win32-ia32")
"win32-x64": getUrl("win32-x64")
}
}
createRemoteManifest: (folder, version) ->
obj = @getRemoteManifest(folder, version)
src = path.resolve("manifest.json")
fs.outputJsonAsync(src, obj).return(src)

View File

@@ -123,14 +123,14 @@ getUploadNameByOsAndArch = (platform) ->
uploadNames = {
darwin: {
"x64": "osx64"
"x64": "darwin-x64"
},
linux: {
"x64": "linux64"
"x64": "linux-x64"
},
win32: {
"x64": "win64",
"ia32": "win32"
"x64": "win32-x64",
"ia32": "win32-ia32"
}
}
name = _.get(uploadNames[platform], arch)

View File

@@ -0,0 +1,23 @@
const snapshot = require('snap-shot-it')
/* eslint-env mocha */
describe('getCDN', () => {
context('npm package', () => {
const { getCDN } = require('../../binary/upload-npm-package')
it('returns CDN s3 path', () => {
const options = {
platform: 'darwin-x64',
filename: 'cypress.tgz',
version: '3.3.0',
// ci name + commit sha + build number
hash: 'ci-name-e154a40f3f76abd39a1d85c0ebc0ff9565015706-123',
}
snapshot({
input: options,
result: getCDN(options),
})
})
})
})

View File

@@ -0,0 +1,16 @@
const snapshot = require('snap-shot-it')
/* eslint-env mocha */
describe('upload', () => {
const upload = require('../../binary/upload')
context('getRemoteManifest', () => {
it('returns object with download urls for each platform', () => {
const folder = 'desktop'
const version = '3.3.0'
const manifest = upload.getRemoteManifest(folder, version)
snapshot('test runner manifest', manifest)
})
})
})

View File

@@ -0,0 +1,23 @@
const snapshot = require('snap-shot-it')
/* eslint-env mocha */
describe('getCDN', () => {
context('binary', () => {
const { getCDN } = require('../../binary/upload-unique-binary')
it('returns CDN s3 path', () => {
const options = {
platform: 'darwin-x64',
filename: 'cypress.zip',
version: '3.3.0',
// ci name + commit sha + build number
hash: 'ci-name-e154a40f3f76abd39a1d85c0ebc0ff9565015706-123',
}
snapshot({
input: options,
result: getCDN(options),
})
})
})
})