smoketests should not fail by bumping version in package.json (#165132)

related to #165118
This commit is contained in:
João Moreno
2022-11-01 07:12:43 -07:00
committed by GitHub
parent 18f1101f70
commit a2e787228f

View File

@@ -263,30 +263,31 @@ async function setupRepository(): Promise<void> {
async function ensureStableCode(): Promise<void> {
let stableCodePath = opts['stable-build'];
if (!stableCodePath) {
const { major, minor } = parseVersion(version!);
const majorMinorVersion = `${major}.${minor - 1}`;
const versionsReq = await retry(() => measureAndLog(() => fetch('https://update.code.visualstudio.com/api/releases/stable', { headers: { 'x-api-version': '2' } }), 'versionReq', logger), 1000, 20);
const current = parseVersion(version!);
const versionsReq = await retry(() => measureAndLog(() => fetch('https://update.code.visualstudio.com/api/releases/stable'), 'versionReq', logger), 1000, 20);
if (!versionsReq.ok) {
throw new Error('Could not fetch releases from update server');
}
const versions: { version: string }[] = await measureAndLog(() => versionsReq.json(), 'versionReq.json()', logger);
const prefix = `${majorMinorVersion}.`;
const previousVersion = versions.find(v => v.version.startsWith(prefix));
const versions: string[] = await measureAndLog(() => versionsReq.json(), 'versionReq.json()', logger);
const stableVersion = versions.find(raw => {
const version = parseVersion(raw);
return version.major < current.major || (version.major === current.major && version.minor < current.minor);
});
if (!previousVersion) {
throw new Error(`Could not find suitable stable version ${majorMinorVersion}`);
if (!stableVersion) {
throw new Error(`Could not find suitable stable version for ${version}`);
}
logger.log(`Found VS Code v${version}, downloading previous VS Code version ${previousVersion.version}...`);
logger.log(`Found VS Code v${version}, downloading previous VS Code version ${stableVersion}...`);
let lastProgressMessage: string | undefined = undefined;
let lastProgressReportedAt = 0;
const stableCodeDestination = path.join(testDataPath, 's');
const stableCodeExecutable = await retry(() => measureAndLog(() => vscodetest.download({
cachePath: stableCodeDestination,
version: previousVersion.version,
version: stableVersion,
extractSync: true,
reporter: {
report: report => {