Skip to content

feat(smoke-tests): test auto-updating from the version of Compass that was just packaged COMPASS-8536 #6629

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

Merged
merged 14 commits into from
Jan 30, 2025

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Jan 17, 2025

Replaces #6608

This changes the smoketest script's interface slightly. There is now a --tests parameter so you can tell it which smoketest you want to run. Options are currently 'time-to-first-query' and 'auto-update-from'. Soon we'll add 'auto-update-to'. An 'install-only' might be useful too for when you're just working on an installer.

The benefit here is that we can control the exception where mac doesn't auto-update (just run a different test) from CI while still testing it locally.

So you can run it like:

npm run start -- --package=osx_dmg --tests auto-update-from

We now also use the real compass-mongodb-com update server. In CI it gets checked out next to compass. This is likely where you'd have it during development anyway. We npm link it into the codebase (it is an optional peer dependency) and then dynamically import it if you run the auto-update server. The import error is caught, it logs a helpful hint that you need to npm link it and rethrows the error. Since it is a dynamic import you only need this if you're running the 'auto-update-from' test.

@lerouxb lerouxb added the no release notes Fix or feature not for release notes label Jan 17, 2025
@github-actions github-actions bot added the feat label Jan 17, 2025
"lib": ["ES2021"],
"module": "NodeNext",
"paths": {
"compass-mongodb-com": ["./src/compass-mongodb-com.d.ts"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -3,7 +3,11 @@
"compilerOptions": {
"noEmit": true,
"types": ["node"],
"lib": ["ES2021"]
"lib": ["ES2021"],
"module": "NodeNext",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed so that typescript doesn't compile the dynamic import to a require and then complain that we're require()-ing an ES module.

}

// run the app and wait for it to auto-update
console.log('starting compass the first time');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have another branch open where I'm switching from console.log to debug. I don't want to conflict with that now, so will fix all these together in a future PR.

@lerouxb lerouxb requested a review from kraenhansen January 30, 2025 13:56
@@ -24,7 +24,7 @@
"eslint": "eslint",
"prettier": "prettier",
"lint": "npm run eslint . && npm run prettier -- --check .",
"depcheck": "compass-scripts check-peer-deps && depcheck",
"depcheck": "depcheck",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 If this doesn't handle optionalDependencies, we should probably add a ticket tracking a fix for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's for compass plugins, though. Which is probably why it is a separate script and not part of depcheck.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll ask @gribnoysup what he thinks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking this rather than npm link, removing it as a peer dep.
5926b93

try {
return (await import('compass-mongodb-com')).default;
} catch (err: unknown) {
console.log('Remember to npm link compass-mongodb-com');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you really want to ... you could throw a new Error and pass err as a cause in the second argument of the Error constructor, but ... then we would have to update the logic printing the error to print any cause as well 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm good :)

Copy link
Contributor

@kraenhansen kraenhansen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful 🦋

@lerouxb lerouxb merged commit 139fa5d into main Jan 30, 2025
33 checks passed
@lerouxb lerouxb deleted the autoupdate-from3 branch January 30, 2025 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants