Skip to content

Commit

Permalink
smoketests should not fail by bumping version in package.json (micros…
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Nov 1, 2022
1 parent 35e39c9 commit 52986b4
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions smoke/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 52986b4

Please sign in to comment.