-
Notifications
You must be signed in to change notification settings - Fork 245
feat: download and test with the latest release #6638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ce72c8b
c07abf3
9488ffd
866c367
07c5ad0
1782287
e5ff953
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,8 @@ import { type PackageKind } from './packages'; | |||||
| import { type SmokeTestsContext } from './context'; | ||||||
| import { pick } from 'lodash'; | ||||||
|
|
||||||
| const SUPPORTED_CHANNELS = ['dev', 'beta', 'stable'] as const; | ||||||
|
|
||||||
| function assertObjectHasKeys( | ||||||
| obj: unknown, | ||||||
| name: string, | ||||||
|
|
@@ -25,13 +27,21 @@ function assertObjectHasKeys( | |||||
|
|
||||||
| // subsets of the hadron-build info result | ||||||
|
|
||||||
| export const commonKeys = ['productName'] as const; | ||||||
| export type CommonBuildInfo = Record<typeof commonKeys[number], string>; | ||||||
| export const commonKeys = ['productName', 'channel'] as const; | ||||||
| export type CommonBuildInfo = Record<typeof commonKeys[number], string> & { | ||||||
| channel: 'dev' | 'beta' | 'stable'; | ||||||
lerouxb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| }; | ||||||
|
|
||||||
| export function assertCommonBuildInfo( | ||||||
| buildInfo: unknown | ||||||
| ): asserts buildInfo is CommonBuildInfo { | ||||||
| assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys); | ||||||
| assert( | ||||||
| SUPPORTED_CHANNELS.includes((buildInfo as any).channel), | ||||||
lerouxb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| SUPPORTED_CHANNELS.includes((buildInfo as any).channel), | |
| SUPPORTED_CHANNELS.includes((buildInfo as unknown as Channel).channel), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildInfo isn't a channel, though. it has a channel. And it is already unknown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like:
export function assertCommonBuildInfo(
buildInfo: unknown
): asserts buildInfo is CommonBuildInfo {
assertObjectHasKeys(buildInfo, 'buildInfo', commonKeys);
assert(
SUPPORTED_CHANNELS.includes((buildInfo as { channel: Channel }).channel),
`Expected ${
(buildInfo as { channel: Channel }).channel
} to be in ${SUPPORTED_CHANNELS.join(',')}`
);
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use assertObjectHasKeys to make sure buildInfo has the channel property? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already did. I added channel to commonKeys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why the (buildInfo as { channel: Channel }).channel? 🤔
Could that be buildInfo.channel as Channel instead?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,6 +145,60 @@ async function getTestSubject( | |
| } | ||
| } | ||
|
|
||
| type Arch = 'arm64' | 'x64'; | ||
|
|
||
| type PlatformShortName = | ||
| | 'darwin-arm64' | ||
| | 'darwin-x64' | ||
| | 'windows' | ||
| | 'linux_deb' | ||
| | 'linux_rpm'; | ||
|
|
||
| function getPlatformShortName( | ||
|
||
| arch: Arch, | ||
| kind: PackageKind | ||
| ): PlatformShortName { | ||
| if (arch === 'arm64') { | ||
| if (kind === 'osx_dmg' || kind === 'osx_zip') { | ||
| return 'darwin-arm64'; | ||
| } | ||
| } | ||
| if (arch === 'x64') { | ||
| if (kind === 'osx_dmg' || kind === 'osx_zip') { | ||
| return 'darwin-x64'; | ||
| } | ||
| if ( | ||
| kind === 'windows_setup' || | ||
| kind === 'windows_msi' || | ||
| kind === 'windows_zip' | ||
| ) { | ||
| return 'windows'; | ||
| } | ||
| if (kind === 'linux_deb' || kind === 'linux_tar') { | ||
| return 'linux_deb'; | ||
| } | ||
| if (kind === 'linux_rpm' || kind === 'rhel_tar') { | ||
| return 'linux_rpm'; | ||
| } | ||
| } | ||
|
|
||
| throw new Error(`Unsupported arch/kind combo: ${arch}/${kind}`); | ||
| } | ||
|
|
||
| async function getLatestRelease( | ||
| channel: 'dev' | 'beta' | 'stable', | ||
| arch: Arch, | ||
| kind: PackageKind, | ||
| forceDownload?: boolean | ||
| ): Promise<string> { | ||
| const shortName = getPlatformShortName(arch, kind); | ||
|
|
||
| return await downloadFile({ | ||
| url: `http://compass.mongodb.com/api/v2/download/latest/compass/${channel}/${shortName}`, | ||
| clearCache: forceDownload, | ||
| }); | ||
| } | ||
|
|
||
| function getInstaller(kind: PackageKind) { | ||
| if (kind === 'osx_dmg') { | ||
| return installMacDMG; | ||
|
|
@@ -179,6 +233,8 @@ async function run() { | |
| const install = getInstaller(kind); | ||
|
|
||
| try { | ||
| console.log('downgrade from this package to latest release'); | ||
|
|
||
| const appName = buildInfo.productName; | ||
|
|
||
| const { appPath, uninstall } = install({ | ||
|
|
@@ -196,6 +252,33 @@ async function run() { | |
| console.log('Cleaning up sandbox'); | ||
| fs.rmSync(context.sandboxPath, { recursive: true }); | ||
| } | ||
|
|
||
| console.log('update from latest release to this package'); | ||
| const releasepath = await getLatestRelease( | ||
| buildInfo.channel, | ||
| context.arch, | ||
| kind, | ||
| context.forceDownload | ||
| ); | ||
|
|
||
| try { | ||
| const appName = buildInfo.productName; | ||
|
|
||
| const { appPath, uninstall } = install({ | ||
| appName, | ||
| filepath: releasepath, | ||
| destinationPath: context.sandboxPath, | ||
| }); | ||
|
|
||
| try { | ||
| runTest({ appName, appPath }); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again: This should actually see if you can update from this version. I'm just including it as a kind of sanity check that releasepath works. |
||
| } finally { | ||
| await uninstall(); | ||
| } | ||
| } finally { | ||
| console.log('Cleaning up sandbox'); | ||
| fs.rmSync(context.sandboxPath, { recursive: true }); | ||
| } | ||
| } | ||
|
|
||
| type RunTestOptions = { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.