-
Notifications
You must be signed in to change notification settings - Fork 751
feat(lsp): older and delisted versions of lsp are automatically removed #6409
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
Conversation
|
|
/runIntegrationTests |
| } | ||
| } | ||
|
|
||
| private async getDownloadedVersions(downloadDirectory: string): Promise<string[]> { |
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.
Can you pull this into a common location so the other language server can use it: https://github.com/aws/aws-toolkit-vscode/blob/feature/amazonqLSP/packages/amazonq/src/lsp/lspInstaller.ts
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.
I moved it to its own util.ts file to avoid circular dependency. Lmk if there is a better place.
| }> | ||
| ) { | ||
| this.versionRange = options?.versionRange ?? new Range(supportedLspServerVersions) | ||
| this.shouldCleanUp = options?.cleanUp ?? true |
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.
is there any case where we would make this false?
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.
I was using this to get greater control in the integ tests, but considering those tests aren't even running, it likely makes sense to remove this bloat for now.
| assert.ok(result.includes('1.1.1')) | ||
| }) | ||
|
|
||
| it('deletes delisted versions', async function () { |
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.
Maybe a couple more tests to make sure if we have < 2 versions that everything behaves correctly? I think in that case we would want to keep the latest 2 just in case one gets delisted and we can fall back to the other
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.
I added 3 new cases.
- if there are less than 2 remaining versions (after filtering for delisted), we should keep all of them.
- if there are less than 2 versions overall, we should keep all of the non-delisted ones.
- if all versions present are delisted, we still shouldn't download it.
Do you think that covers the edge cases with < 2 versions?
| if (!onMac) { | ||
| this.skip() | ||
| } | ||
| await fs.delete(LanguageServerResolver.defaultDir, { force: true, recursive: true }) |
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.
is there a way we can mock this path somehow we aren't nuking our language servers when we run this test
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.
I was trying to run them as e2e as possible, but I think for these integ tests the setup will take more work to get right. Right now, I deleted them, and we can re-add in a followup if it seems important.
| @@ -0,0 +1,10 @@ | |||
| /*! | |||
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.
These various fetch/download/lsp utils seem potentially applicable to both Toolkit and Q in the future. How much of these util modules are Q-specific? Can most of them live in /core/ ?
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.
All the logic for downloading/fetching etc is in core. The only thing that should be in the q lsp folder is the codewhisperer language server resolver and the codewhisperer language server activation
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.
oh right this is in core but the amazonq part of core... if it's not q-specific then it could live in shared.
| } | ||
| } | ||
|
|
||
| private isDelisted(manifestVersions: LspVersion[], targetVersion: string): boolean { |
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.
I think these are still missing from this file as well: https://github.com/aws/aws-toolkit-vscode/blob/feature/amazonqLSP/packages/amazonq/src/lsp/lspInstaller.ts#L21. Since this only does the cleanup for the workspace context language server and not the codewhisperer one
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.
Moved it to a general location in core to avoid duplicating.
|
non-web failing tests addressed in #6429 |
| isDelisted(manifestVersions, v) | ||
| ) | ||
| for (const v of delistedVersions) { | ||
| await fs.delete(path.join(downloadDirectory, v), { force: true, recursive: true }) |
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.
I guess force=true avoids any potential failures. So we don't need to use .catch() to continue the for-loop on failure.
justinmk3
left a comment
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.
Not a blocker for this PR, but it does look lilke the cleanup module + tests should live in shared/languageServer/ (which should be renamed to shared/lsp/)
5a69e8d to
5e47cb5
Compare
|
Updated it so that cleanup code lives in |
Problem
Solution
Implement the following heuristic:
Included in this change is a new utility function
partition.partitionis likefilter, but it produces both the positive and negative result in two separate sublists. See the tests for a simple example.feature/xbranches will not be squash-merged at release time.