forked from microsoft/azuredatastudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert build folder update to fix it properly (microsoft#22981)
* Revert "Disable publishing crash reports temporarily (microsoft#22950)" This reverts commit 13a791d. * Revert "Compile build folder (microsoft#22811)" This reverts commit 2c07c09.
- Loading branch information
1 parent
70e756b
commit 9af7a04
Showing
33 changed files
with
1,467 additions
and
1,482 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the Source EULA. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import { DocumentClient } from 'documentdb'; | ||
|
||
interface Config { | ||
id: string; | ||
frozen: boolean; | ||
} | ||
|
||
function createDefaultConfig(quality: string): Config { | ||
return { | ||
id: quality, | ||
frozen: false | ||
}; | ||
} | ||
|
||
function getConfig(quality: string): Promise<Config> { | ||
const client = new DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT']!, { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); | ||
const collection = 'dbs/builds/colls/config'; | ||
const query = { | ||
query: `SELECT TOP 1 * FROM c WHERE c.id = @quality`, | ||
parameters: [ | ||
{ name: '@quality', value: quality } | ||
] | ||
}; | ||
|
||
return new Promise<Config>((c, e) => { | ||
client.queryDocuments(collection, query).toArray((err, results) => { | ||
if (err && err.code !== 409) { return e(err); } | ||
|
||
c(!results || results.length === 0 ? createDefaultConfig(quality) : results[0] as any as Config); | ||
}); | ||
}); | ||
} | ||
|
||
function doRelease(commit: string, quality: string): Promise<void> { | ||
const client = new DocumentClient(process.env['AZURE_DOCUMENTDB_ENDPOINT']!, { masterKey: process.env['AZURE_DOCUMENTDB_MASTERKEY'] }); | ||
const collection = 'dbs/builds/colls/' + quality; | ||
const query = { | ||
query: 'SELECT TOP 1 * FROM c WHERE c.id = @id', | ||
parameters: [{ name: '@id', value: commit }] | ||
}; | ||
|
||
let updateTries = 0; | ||
|
||
function update(): Promise<void> { | ||
updateTries++; | ||
|
||
return new Promise<void>((c, e) => { | ||
client.queryDocuments(collection, query).toArray((err, results) => { | ||
if (err) { return e(err); } | ||
if (results.length !== 1) { return e(new Error('No documents')); } | ||
|
||
const release = results[0]; | ||
release.isReleased = true; | ||
|
||
client.replaceDocument(release._self, release, err => { | ||
if (err && err.code === 409 && updateTries < 5) { return c(update()); } | ||
if (err) { return e(err); } | ||
|
||
console.log('Build successfully updated.'); | ||
c(); | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
return update(); | ||
} | ||
|
||
async function release(commit: string, quality: string): Promise<void> { | ||
const config = await getConfig(quality); | ||
|
||
console.log('Quality config:', config); | ||
|
||
if (config.frozen) { | ||
console.log(`Skipping release because quality ${quality} is frozen.`); | ||
return; | ||
} | ||
|
||
await doRelease(commit, quality); | ||
} | ||
|
||
function env(name: string): string { | ||
const result = process.env[name]; | ||
|
||
if (!result) { | ||
throw new Error(`Skipping release due to missing env: ${name}`); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
async function main(): Promise<void> { | ||
const commit = env('BUILD_SOURCEVERSION'); | ||
const quality = env('VSCODE_QUALITY'); | ||
|
||
await release(commit, quality); | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err); | ||
process.exit(1); | ||
}); |
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
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
Oops, something went wrong.