Add ability to run query with data extensions#2065
Conversation
- 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.
194c28c to
6f43530
Compare
robertbrignull
left a comment
There was a problem hiding this comment.
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.
| describe("extension packs", () => { | ||
| skipIfTrue(qs.cliServer.cliConstraints.supportsQlpacksKind()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Hmmm...I will have to rework this. Good catch.
| @@ -1142,19 +1142,26 @@ export class CodeQLCliServer implements Disposable { | |||
| * the default CLI search path is used. | |||
There was a problem hiding this comment.
Docs for this method are now outdated
Also, update jsdoc for `resolveQlpacks`.
|
Hmmm...linting is no longer working in the editor, so I keep missing linting errors. Ah...It was a configuration problem. Working now. |
072646f to
39e6b27
Compare
| @@ -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`. | |||
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Should be
| 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Actually, I don't think the function is really doing much. I'm moving to vanilla beforeEach...pending.
…-all-data-extensions
208bd1e to
a35c92f
Compare
Also, add a comment to the vscode settings file and describe how to use it.
a35c92f to
256b806
Compare
|
OK...all tests are passing, but the new cli integration test is not running since it relies on CLI version 2.12.3. |
|
v2.11.3 is now available. I am taking this PR out of draft. @robertbrignull, would you be able to take another look? |
robertbrignull
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Robert <robertbrignull@github.com>
|
Thanks for the review. Since we will be releasing the extension tomorrow, I will hold off on merging this PR until after the release. |
2d577de to
0ecde78
Compare
|
@robertbrignull now that the MRVA release is out, can you take another look? I'm hoping to merge this soon. |
codeql resolve qlpackscommand with the new--kindoption. This will return a list of extension packs in the workspace.Note that the new integration tests will be skipped until 2.12.3 is released.
Checklist
ready-for-doc-reviewlabel there.