-
Notifications
You must be signed in to change notification settings - Fork 229
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ce72c8b
download and test with the latest release
lerouxb c07abf3
Update packages/compass-smoke-tests/src/build-info.ts
lerouxb 9488ffd
Update packages/compass-smoke-tests/src/build-info.ts
lerouxb 866c367
different cast
lerouxb 07c5ad0
no need to fret about the correct filename
lerouxb 1782287
Merge branch 'main' into download-released-compass
lerouxb e5ff953
use debug, not console.log
lerouxb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import path from 'node:path'; | |
import yargs from 'yargs'; | ||
import { hideBin } from 'yargs/helpers'; | ||
import { pick } from 'lodash'; | ||
import createDebug from 'debug'; | ||
import { execute } from './execute'; | ||
import { | ||
type PackageDetails, | ||
|
@@ -15,12 +16,15 @@ import { | |
import { createSandbox } from './directories'; | ||
import { downloadFile } from './downloads'; | ||
import { type PackageKind, SUPPORTED_PACKAGES } from './packages'; | ||
import { getLatestRelease } from './releases'; | ||
import { type SmokeTestsContext } from './context'; | ||
|
||
import { installMacDMG } from './installers/mac-dmg'; | ||
import { installMacZIP } from './installers/mac-zip'; | ||
import { installWindowsZIP } from './installers/windows-zip'; | ||
|
||
const debug = createDebug('compass-smoke-tests'); | ||
|
||
const SUPPORTED_PLATFORMS = ['win32', 'darwin', 'linux'] as const; | ||
const SUPPORTED_ARCHS = ['x64', 'arm64'] as const; | ||
|
||
|
@@ -165,9 +169,9 @@ async function run() { | |
sandboxPath: createSandbox(), | ||
}; | ||
|
||
console.log(`Running tests in ${context.sandboxPath}`); | ||
debug(`Running tests in ${context.sandboxPath}`); | ||
|
||
console.log( | ||
debug( | ||
'context', | ||
pick(context, [ | ||
'forceDownload', | ||
|
@@ -179,7 +183,7 @@ async function run() { | |
]) | ||
); | ||
|
||
const { kind, filepath, appName } = await getTestSubject(context); | ||
const { kind, filepath, buildInfo, appName } = await getTestSubject(context); | ||
const install = getInstaller(kind); | ||
|
||
try { | ||
|
@@ -195,7 +199,34 @@ async function run() { | |
await uninstall(); | ||
} | ||
} finally { | ||
console.log('Cleaning up sandbox'); | ||
debug('Cleaning up sandbox'); | ||
fs.rmSync(context.sandboxPath, { recursive: true }); | ||
} | ||
|
||
debug('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 }); | ||
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 { | ||
debug('Cleaning up sandbox'); | ||
fs.rmSync(context.sandboxPath, { recursive: true }); | ||
} | ||
} | ||
|
@@ -231,7 +262,7 @@ function runTest({ appName, appPath }: RunTestOptions) { | |
|
||
run() | ||
.then(function () { | ||
console.log('done'); | ||
debug('done'); | ||
}) | ||
.catch(function (err) { | ||
console.error(err.stack); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { downloadFile } from './downloads'; | ||
import { type PackageKind } from './packages'; | ||
|
||
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}`); | ||
} | ||
|
||
type PlatformExtension = 'dmg' | 'exe' | 'deb' | 'rpm'; | ||
|
||
function getPlatformExtension( | ||
arch: Arch, | ||
kind: PackageKind | ||
): PlatformExtension { | ||
if (arch === 'arm64') { | ||
if (kind === 'osx_dmg' || kind === 'osx_zip') { | ||
return 'dmg'; | ||
} | ||
} | ||
if (arch === 'x64') { | ||
if (kind === 'osx_dmg' || kind === 'osx_zip') { | ||
return 'dmg'; | ||
} | ||
if ( | ||
kind === 'windows_setup' || | ||
kind === 'windows_msi' || | ||
kind === 'windows_zip' | ||
) { | ||
return 'exe'; | ||
} | ||
if (kind === 'linux_deb' || kind === 'linux_tar') { | ||
return 'deb'; | ||
} | ||
if (kind === 'linux_rpm' || kind === 'rhel_tar') { | ||
return 'rpm'; | ||
} | ||
} | ||
|
||
throw new Error(`Unsupported arch/kind combo: ${arch}/${kind}`); | ||
} | ||
|
||
export async function getLatestRelease( | ||
channel: 'dev' | 'beta' | 'stable', | ||
arch: Arch, | ||
kind: PackageKind, | ||
forceDownload?: boolean | ||
): Promise<string> { | ||
const shortName = getPlatformShortName(arch, kind); | ||
const extension = getPlatformExtension(arch, kind); | ||
|
||
return await downloadFile({ | ||
url: `http://compass.mongodb.com/api/v2/download/latest/compass/${channel}/${shortName}`, | ||
targetFilename: `latest-${channel}.${extension}`, | ||
clearCache: forceDownload, | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.