forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
7,888 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
packages: | ||
- name: install | ||
type: generic | ||
srcs: | ||
- "**" | ||
config: | ||
commands: | ||
- ["yarn"] | ||
- name: init | ||
type: generic | ||
deps: | ||
- ":install" | ||
config: | ||
commands: | ||
- ["yarn", "--cwd", "./install/build", "compile"] | ||
- ["yarn", "--cwd", "./install", "gitpod:link"] | ||
- ["yarn", "--cwd", "./install", "compile"] | ||
- ["yarn", "--cwd", "./install", "download-builtin-extensions"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const url = require("url"); | ||
const azure = require("azure-storage"); | ||
const mime = require("mime"); | ||
const cosmos_1 = require("@azure/cosmos"); | ||
const retry_1 = require("./retry"); | ||
function log(...args) { | ||
console.log(...[`[${new Date().toISOString()}]`, ...args]); | ||
} | ||
function error(...args) { | ||
console.error(...[`[${new Date().toISOString()}]`, ...args]); | ||
} | ||
if (process.argv.length < 3) { | ||
error('Usage: node sync-mooncake.js <quality>'); | ||
process.exit(-1); | ||
} | ||
async function sync(commit, quality) { | ||
log(`Synchronizing Mooncake assets for ${quality}, ${commit}...`); | ||
const client = new cosmos_1.CosmosClient({ endpoint: process.env['AZURE_DOCUMENTDB_ENDPOINT'], key: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); | ||
const container = client.database('builds').container(quality); | ||
const query = `SELECT TOP 1 * FROM c WHERE c.id = "${commit}"`; | ||
const res = await container.items.query(query, {}).fetchAll(); | ||
if (res.resources.length !== 1) { | ||
throw new Error(`No builds found for ${commit}`); | ||
} | ||
const build = res.resources[0]; | ||
log(`Found build for ${commit}, with ${build.assets.length} assets`); | ||
const storageAccount = process.env['AZURE_STORAGE_ACCOUNT_2']; | ||
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_STORAGE_ACCESS_KEY_2']) | ||
.withFilter(new azure.ExponentialRetryPolicyFilter(20)); | ||
const mooncakeBlobService = azure.createBlobService(storageAccount, process.env['MOONCAKE_STORAGE_ACCESS_KEY'], `${storageAccount}.blob.core.chinacloudapi.cn`) | ||
.withFilter(new azure.ExponentialRetryPolicyFilter(20)); | ||
// mooncake is fussy and far away, this is needed! | ||
blobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000; | ||
mooncakeBlobService.defaultClientRequestTimeoutInMs = 10 * 60 * 1000; | ||
for (const asset of build.assets) { | ||
try { | ||
const blobPath = url.parse(asset.url).path; | ||
if (!blobPath) { | ||
throw new Error(`Failed to parse URL: ${asset.url}`); | ||
} | ||
const blobName = blobPath.replace(/^\/\w+\//, ''); | ||
log(`Found ${blobName}`); | ||
if (asset.mooncakeUrl) { | ||
log(` Already in Mooncake ✔️`); | ||
continue; | ||
} | ||
const readStream = blobService.createReadStream(quality, blobName, undefined); | ||
const blobOptions = { | ||
contentSettings: { | ||
contentType: mime.lookup(blobPath), | ||
cacheControl: 'max-age=31536000, public' | ||
} | ||
}; | ||
const writeStream = mooncakeBlobService.createWriteStreamToBlockBlob(quality, blobName, blobOptions, undefined); | ||
log(` Uploading to Mooncake...`); | ||
await new Promise((c, e) => readStream.pipe(writeStream).on('finish', c).on('error', e)); | ||
log(` Updating build in DB...`); | ||
const mooncakeUrl = `${process.env['MOONCAKE_CDN_URL']}${blobPath}`; | ||
await (0, retry_1.retry)(() => container.scripts.storedProcedure('setAssetMooncakeUrl') | ||
.execute('', [commit, asset.platform, asset.type, mooncakeUrl])); | ||
log(` Done ✔️`); | ||
} | ||
catch (err) { | ||
error(err); | ||
} | ||
} | ||
log(`All done ✔️`); | ||
} | ||
function main() { | ||
const commit = process.env['BUILD_SOURCEVERSION']; | ||
if (!commit) { | ||
error('Skipping publish due to missing BUILD_SOURCEVERSION'); | ||
return; | ||
} | ||
const quality = process.argv[2]; | ||
sync(commit, quality).catch(err => { | ||
error(err); | ||
process.exit(1); | ||
}); | ||
} | ||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/*!-------------------------------------------------------- | ||
* Copyright (C) Gitpod. All rights reserved. | ||
*--------------------------------------------------------*/ | ||
|
||
// @ts-check | ||
'use strict'; | ||
|
||
require('./gulpfile.server').defineTasks({ | ||
qualifier: 'gitpod', | ||
header: [ | ||
'/*!--------------------------------------------------------', | ||
' * Copyright (C) Gitpod. All rights reserved.', | ||
' *--------------------------------------------------------*/' | ||
].join('\n') | ||
}); | ||
|
||
const promisify = require('util').promisify; | ||
const cp = require('child_process'); | ||
const argv = require('yargs').argv; | ||
const vsce = require('vsce'); | ||
const gulp = require('gulp'); | ||
const path = require('path'); | ||
const es = require('event-stream'); | ||
const util = require('./lib/util'); | ||
const task = require('./lib/task'); | ||
const rename = require('gulp-rename'); | ||
const ext = require('./lib/extensions'); | ||
|
||
const extensionsPath = path.join(path.dirname(__dirname), 'extensions'); | ||
const marketplaceExtensions = ['gitpod', 'gitpod-ui', 'gitpod-remote-ssh']; | ||
const outMarketplaceExtensions = 'out-gitpod-marketplace'; | ||
const cleanMarketplaceExtensions = task.define('clean-gitpod-marketplace-extensions', util.rimraf(outMarketplaceExtensions)); | ||
const bumpMarketplaceExtensions = task.define('bump-marketplace-extensions', () => { | ||
if ('new-version' in argv && argv['new-version']) { | ||
const newVersion = argv['new-version']; | ||
console.log(newVersion); | ||
return Promise.allSettled(marketplaceExtensions.map(async extensionName => { | ||
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' }); | ||
if (stderr) { | ||
throw new Error('failed to bump up version: ' + stderr); | ||
} | ||
})); | ||
} | ||
}); | ||
const bundleMarketplaceExtensions = task.define('bundle-gitpod-marketplace-extensions', task.series( | ||
cleanMarketplaceExtensions, | ||
bumpMarketplaceExtensions, | ||
() => | ||
ext.minifyExtensionResources( | ||
es.merge( | ||
...marketplaceExtensions.map(extensionName => | ||
ext.fromLocal(path.join(extensionsPath, extensionName), false) | ||
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`)) | ||
) | ||
) | ||
).pipe(gulp.dest(outMarketplaceExtensions)) | ||
)); | ||
gulp.task(bundleMarketplaceExtensions); | ||
const publishMarketplaceExtensions = task.define('publish-gitpod-marketplace-extensions', task.series( | ||
bundleMarketplaceExtensions, | ||
() => Promise.allSettled(marketplaceExtensions.map(extensionName => { | ||
vsce.publish({ | ||
cwd: path.join(outMarketplaceExtensions, extensionName) | ||
}); | ||
})) | ||
)); | ||
gulp.task(publishMarketplaceExtensions); | ||
const packageMarketplaceExtensions = task.define('package-gitpod-marketplace-extensions', task.series( | ||
bundleMarketplaceExtensions, | ||
() => Promise.allSettled(marketplaceExtensions.map(extensionName => { | ||
vsce.createVSIX({ | ||
cwd: path.join(outMarketplaceExtensions, extensionName) | ||
}); | ||
})) | ||
)); | ||
gulp.task(packageMarketplaceExtensions); | ||
for (const extensionName of marketplaceExtensions) { | ||
const cleanExtension = task.define('gitpod:clean-extension:' + extensionName, util.rimraf(path.join(outMarketplaceExtensions, extensionName))); | ||
const bumpExtension = task.define('gitpod:bump-extension:' + extensionName, async () => { | ||
if ('new-version' in argv && argv['new-version']) { | ||
const newVersion = argv['new-version']; | ||
const { stderr } = await promisify(cp.exec)(`yarn version --new-version ${newVersion} --cwd ${path.join(extensionsPath, extensionName)} --no-git-tag-version`, { encoding: 'utf8' }); | ||
if (stderr) { | ||
throw new Error('failed to bump up version: ' + stderr); | ||
} | ||
} | ||
}); | ||
const bundleExtension = task.define('gitpod:bundle-extension:' + extensionName, task.series( | ||
cleanExtension, | ||
bumpExtension, | ||
() => | ||
ext.minifyExtensionResources( | ||
ext.fromLocal(path.join(extensionsPath, extensionName), false) | ||
.pipe(rename(p => p.dirname = `${extensionName}/${p.dirname}`)) | ||
).pipe(gulp.dest(outMarketplaceExtensions)) | ||
)); | ||
gulp.task(bundleExtension); | ||
const publishExtension = task.define('gitpod:publish-extension:' + extensionName, task.series( | ||
bundleExtension, | ||
() => vsce.publish({ | ||
cwd: path.join(outMarketplaceExtensions, extensionName) | ||
}) | ||
)); | ||
gulp.task(publishExtension); | ||
const packageExtension = task.define('gitpod:package-extension:' + extensionName, task.series( | ||
bundleExtension, | ||
() => vsce.createVSIX({ | ||
cwd: path.join(outMarketplaceExtensions, extensionName) | ||
}) | ||
)); | ||
gulp.task(packageExtension); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.