Skip to content

Add ability to run query with data extensions#2065

Merged
aeisenberg merged 9 commits intomainfrom
aeisenberg/run-with-all-data-extensions
Mar 10, 2023
Merged

Add ability to run query with data extensions#2065
aeisenberg merged 9 commits intomainfrom
aeisenberg/run-with-all-data-extensions

Conversation

@aeisenberg
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg commented Feb 10, 2023

  • Add a new config that toggles between using all data extensions or none.
  • If using all data extensions, then before a query evaluation, run a codeql resolve qlpacks command with the new --kind option. This will return a list of extension packs in the workspace.
  • Pass these packs to the cli before evaluation/
  • This will only work with CLI v2.12.3 (not yet released) or later.
  • Also include some CLI tests to ensure this works.

Note that the new integration tests will be skipped until 2.12.3 is released.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@aeisenberg aeisenberg requested a review from a team as a code owner February 10, 2023 23:38
@aeisenberg aeisenberg marked this pull request as draft February 10, 2023 23:38
- Add a new config that toggles between using all data extensions or
  none.
- If using all data extensions, then before a query evaluation, run a
  `codeql resolve qlpacks` command with the new `--kind` option. This
  will return a list of extension packs in the workspace.
- Pass these packs to the cli before evaluation/
- This will only work with CLI v2.12.3 (not yet released) or later.
- Also include some CLI tests to ensure this works.
@aeisenberg aeisenberg force-pushed the aeisenberg/run-with-all-data-extensions branch from 194c28c to 6f43530 Compare February 10, 2023 23:51
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

I have a couple of comments, but these changes make sense to me. I'm mostly reviewing this in isolation and I don't have much context yet of the whole data extensions work.

Comment on lines +101 to +102
describe("extension packs", () => {
skipIfTrue(qs.cliServer.cliConstraints.supportsQlpacksKind());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm unfortunately not sure this use of async code is safe.

This is calling beforeEach to add a skip, but what guarantees it does this before the its are called to add tests. I'm guessing that Jest waits for the full describe block to finish executing before it starts running any tests, but I'm not sure it has any way to know that this async code is running in the background. To the best of my knowledge, the block passed to describe must not be async.

Could you also link to docs about how beforeEach.skip(() => {}) works? I'm trying to understand it but the docs I can find don't include any examples like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmmm...I will have to rework this. Good catch.

Comment thread extensions/ql-vscode/src/cli.ts Outdated
@@ -1142,19 +1142,26 @@ export class CodeQLCliServer implements Disposable {
* the default CLI search path is used.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Docs for this method are now outdated

Comment thread extensions/ql-vscode/src/cli.ts
Also, update jsdoc for `resolveQlpacks`.
@aeisenberg
Copy link
Copy Markdown
Contributor Author

aeisenberg commented Feb 14, 2023

Hmmm...linting is no longer working in the editor, so I keep missing linting errors. Ah...It was a configuration problem. Working now.

@aeisenberg aeisenberg force-pushed the aeisenberg/run-with-all-data-extensions branch from 072646f to 39e6b27 Compare February 14, 2023 05:11
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

A couple more tiny points but then this looks good to me. Thanks for explaining bits. The use of the CLI now makes sense to me.

Comment thread extensions/ql-vscode/src/cli.ts Outdated
@@ -1138,23 +1138,31 @@ export class CodeQLCliServer implements Disposable {
/**
* Gets information about available qlpacks
* @param additionalPacks A list of directories to search for qlpacks before searching in `searchPath`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for updating the doc comment. Sorry but seachPath is also mentioned in this line.


export function skipIfTrue(condition: () => Thenable<boolean>) {
return beforeEach(async () => {
if (await condition) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should be

Suggested change
if (await condition) {
if (await condition()) {

as otherwise this will always be true, assuming a function object is truthy.

Or convert condition back into a Thenable<boolean>. I don't think the extra layer of being function is necessary to make this work.

As an extra side point, what benefit does using Thenable give over using Promise? I'm curious to know which one we should use in general.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no reason I used Thenable<boolean> instead of Promise, other than I was just looking at the typings of beforeEach and copying that. I can change it to Promise.

I've fixed the implementation and it is working locally now in various forms.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually, I don't think the function is really doing much. I'm moving to vanilla beforeEach...pending.

@aeisenberg aeisenberg force-pushed the aeisenberg/run-with-all-data-extensions branch from 208bd1e to a35c92f Compare February 14, 2023 21:36
Also, add a comment to the vscode settings file and describe how to use
it.
@aeisenberg aeisenberg force-pushed the aeisenberg/run-with-all-data-extensions branch from a35c92f to 256b806 Compare February 14, 2023 22:47
@aeisenberg
Copy link
Copy Markdown
Contributor Author

OK...all tests are passing, but the new cli integration test is not running since it relies on CLI version 2.12.3.

@aeisenberg aeisenberg marked this pull request as ready for review February 28, 2023 04:04
@aeisenberg
Copy link
Copy Markdown
Contributor Author

v2.11.3 is now available. I am taking this PR out of draft. @robertbrignull, would you be able to take another look?

@aeisenberg aeisenberg enabled auto-merge February 28, 2023 04:19
Copy link
Copy Markdown
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

One final comment. Sorry I think it was missed last time.

Other than that this look good to me. I've done a quick test too that everything still works as before when the config option is not set and this won't change behaviour for users that don't opt-in.

Comment thread extensions/ql-vscode/src/cli.ts Outdated
Co-authored-by: Robert <robertbrignull@github.com>
@aeisenberg
Copy link
Copy Markdown
Contributor Author

Thanks for the review. Since we will be releasing the extension tomorrow, I will hold off on merging this PR until after the release.

@aeisenberg aeisenberg force-pushed the aeisenberg/run-with-all-data-extensions branch from 2d577de to 0ecde78 Compare March 7, 2023 02:07
@aeisenberg aeisenberg disabled auto-merge March 9, 2023 17:41
@aeisenberg
Copy link
Copy Markdown
Contributor Author

@robertbrignull now that the MRVA release is out, can you take another look? I'm hoping to merge this soon.

@aeisenberg aeisenberg merged commit 0d8df9a into main Mar 10, 2023
@aeisenberg aeisenberg deleted the aeisenberg/run-with-all-data-extensions branch March 10, 2023 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants