Skip to content

Commit

Permalink
Merge branch 'main' into CLOUDP-286331
Browse files Browse the repository at this point in the history
  • Loading branch information
Anemy authored Jan 14, 2025
2 parents 4c77061 + 4916ea6 commit 0e5ac49
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 37 deletions.
2 changes: 1 addition & 1 deletion THIRD-PARTY-NOTICES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
The following third-party software is used by and included in **Mongodb Compass**.
This document was automatically generated on Mon Jan 13 2025.
This document was automatically generated on Tue Jan 14 2025.

## List of dependencies

Expand Down
2 changes: 1 addition & 1 deletion docs/tracking-plan.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Compass Tracking Plan

Generated on Mon, Jan 13, 2025 at 02:06 PM
Generated on Tue, Jan 14, 2025 at 03:51 PM

## Table of Contents

Expand Down
96 changes: 63 additions & 33 deletions packages/compass-e2e-tests/smoke-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ import {
assertCommonBuildInfo,
} from './helpers/buildinfo';

const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const;
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const;

function isSupportedPlatform(
value: unknown
): value is typeof SUPPORTED_PLATFORMS[number] {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
return SUPPORTED_PLATFORMS.includes(value as any);
}

function isSupportedArch(
value: unknown
): value is typeof SUPPORTED_ARCHS[number] {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
return SUPPORTED_ARCHS.includes(value as any);
}

function getDefaultPlatform() {
const {
platform,
env: { PLATFORM },
} = process;
if (isSupportedPlatform(PLATFORM)) {
return PLATFORM;
} else if (isSupportedPlatform(platform)) {
return platform;
}
}

function getDefaultArch() {
const {
arch,
env: { ARCH },
} = process;
if (isSupportedArch(ARCH)) {
return ARCH;
} else if (isSupportedArch(arch)) {
return arch;
}
}

const argv = yargs(hideBin(process.argv))
.scriptName('smoke-tests')
.detectLocale(false)
Expand All @@ -32,26 +73,15 @@ const argv = yargs(hideBin(process.argv))
type: 'string',
default: process.env.EVERGREEN_BUCKET_KEY_PREFIX,
})
.option('version', {
type: 'string',
// For dev versions we need this from evergreen. For beta or stable (or by
// default, ie. when testing a locally packaged app) we get it from the
// package.json
default: process.env.DEV_VERSION_IDENTIFIER,
description:
'Will be read from packages/compass/package.json if not specified',
})
.option('platform', {
type: 'string',
choices: ['win32', 'darwin', 'linux'],
choices: SUPPORTED_PLATFORMS,
demandOption: true,
default: process.env.PLATFORM ?? process.platform,
default: getDefaultPlatform(),
})
.option('arch', {
type: 'string',
choices: ['x64', 'arm64'],
choices: SUPPORTED_ARCHS,
demandOption: true,
default: process.env.ARCH ?? process.arch,
default: getDefaultArch(),
})
.option('package', {
type: 'string',
Expand All @@ -65,7 +95,7 @@ const argv = yargs(hideBin(process.argv))
'linux_tar',
'linux_rpm',
'rhel_tar',
],
] as const,
demandOption: true,
description: 'Which package to test',
})
Expand All @@ -88,7 +118,6 @@ const argv = yargs(hideBin(process.argv))
type SmokeTestsContext = {
bucketName?: string;
bucketKeyPrefix?: string;
version?: string;
platform: 'win32' | 'darwin' | 'linux';
arch: 'x64' | 'arm64';
package:
Expand All @@ -112,48 +141,49 @@ async function readJson<T extends object>(...segments: string[]): Promise<T> {
return result as T;
}

async function readPackageVersion(packagePath: string) {
const pkg = await readJson(packagePath, 'package.json');
assert(
'version' in pkg && typeof pkg.version === 'string',
'Expected a package version'
);
return pkg.version;
}

async function run() {
const parsedArgs = argv.parseSync();

const context = parsedArgs as SmokeTestsContext;
const context: SmokeTestsContext = argv.parseSync();

console.log(
'context',
pick(context, [
'skipDownload',
'bucketName',
'bucketKeyPrefix',
'version',
'platform',
'arch',
'package',
])
);

const compassDir = path.resolve(__dirname, '..', '..', 'packages', 'compass');
// use the specified DEV_VERSION_IDENTIFIER if set or load version from packages/compass/package.json
const version = context.version ?? (await readPackageVersion(compassDir));
const outPath = path.resolve(__dirname, 'hadron-build-info.json');

// build-info
const infoArgs = {
format: 'json',
dir: compassDir,
version,
platform: context.platform,
arch: context.arch,
out: outPath,
};
console.log('infoArgs', infoArgs);

// These are known environment variables that will affect the way
// writeBuildInfo works. Log them as a reminder and for our own sanity
console.log(
'info env vars',
pick(process.env, [
'HADRON_DISTRIBUTION',
'HADRON_APP_VERSION',
'HADRON_PRODUCT',
'HADRON_PRODUCT_NAME',
'HADRON_READONLY',
'HADRON_ISOLATED',
'DEV_VERSION_IDENTIFIER',
'IS_RHEL',
])
);
writeBuildInfo(infoArgs);
const buildInfo = await readJson(infoArgs.out);

Expand Down
3 changes: 3 additions & 0 deletions packages/compass/src/app/components/update-toasts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const RestartCompassToastContent = ({
<button
className={cx(buttonStyles, darkmode && buttonDarkStyles)}
onClick={onUpdateClicked}
data-testid="auto-update-restart-button"
>
Restart
</button>
Expand Down Expand Up @@ -83,6 +84,7 @@ export function onAutoupdateExternally({
Compass features.
</Body>
<Link
data-testid="auto-update-download-link"
as="a"
target="_blank"
href={'https://www.mongodb.com/try/download/compass'}
Expand Down Expand Up @@ -137,6 +139,7 @@ export function onAutoupdateInstalled({ newVersion }: { newVersion: string }) {
title: `Compass ${newVersion} installed successfully`,
description: (
<Link
data-testid="auto-update-release-notes-link"
as="a"
target="_blank"
href={`https://github.com/mongodb-js/compass/releases/tag/v${newVersion}`}
Expand Down
10 changes: 8 additions & 2 deletions packages/compass/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,15 @@ const app = {
});
}

log.info(mongoLogId(1_001_000_338), 'Main Window', 'Recent version info', {
previousVersion: state.previousVersion,
highestInstalledVersion: state.highestInstalledVersion,
APP_VERSION,
});

if (
semver.gt(APP_VERSION, state.previousVersion) &&
state.previousVersion !== DEFAULT_APP_VERSION
state.previousVersion !== DEFAULT_APP_VERSION &&
APP_VERSION !== state.previousVersion
) {
// Wait a bit before showing the update toast.
setTimeout(() => {
Expand Down

0 comments on commit 0e5ac49

Please sign in to comment.