From 52986b434a74cea3b0d53cd8170648fafed12da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Tue, 1 Nov 2022 07:12:43 -0700 Subject: [PATCH] smoketests should not fail by bumping version in package.json (#165132) related to #165118 --- smoke/src/main.ts | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/smoke/src/main.ts b/smoke/src/main.ts index e2657a9e4df95..ef9e04f39bfd4 100644 --- a/smoke/src/main.ts +++ b/smoke/src/main.ts @@ -263,30 +263,31 @@ async function setupRepository(): Promise { async function ensureStableCode(): Promise { 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 => {