Skip to content

Install dependencies for tutorial query in codespace#2090

Merged
elenatanasoiu merged 3 commits intomainfrom
elena/install-csv-depenedencies
Feb 27, 2023
Merged

Install dependencies for tutorial query in codespace#2090
elenatanasoiu merged 3 commits intomainfrom
elena/install-csv-depenedencies

Conversation

@elenatanasoiu
Copy link
Copy Markdown
Contributor

@elenatanasoiu elenatanasoiu commented Feb 16, 2023

Required by this PR: github/codespaces-codeql#6

When a user goes through the Code Tour, we select a dummy csv database
for them to get them up and running.

Once they complete the code tour and would like to continue writing
queries, they will need to add their own database.

After they do that, we check the language of their new database and
generate a skeleton QL pack for them so that they don't need to create
these files by hand. See 1 for details.

This skeleton pack folder will be called
codeql-custom-queries-<language> and it comes with its own example
query: example.ql.

When we try to run this example query, the query gets confused about
which dbscheme to pick, as it sees a qlpack.yml file in the new
skeleton pack folder, as well as one in the existing tutorial-lib
folder.

So we'll need to get rid of the tutorial-lib folder in order to make room
for new queries to be run once the tour is complete.

This PR introduces a handleTourDependencies step which will trigger a
codeql pack install command in order to install real library dependencies
for tutorial-queries, since we no longer have the dummy library in
tutorial-lib.

@elenatanasoiu elenatanasoiu force-pushed the elena/install-csv-depenedencies branch 5 times, most recently from 92943cd to 2503b87 Compare February 21, 2023 18:53
@elenatanasoiu elenatanasoiu changed the title Add command to install tour dependencies @elenatanasoiu Install dependencies for tutorial query in codespace Feb 21, 2023
@elenatanasoiu elenatanasoiu changed the title @elenatanasoiu Install dependencies for tutorial query in codespace Install dependencies for tutorial query in codespace Feb 21, 2023
@elenatanasoiu elenatanasoiu changed the base branch from main to elena/fix-unhandled-arguments February 21, 2023 18:59
@elenatanasoiu elenatanasoiu marked this pull request as ready for review February 21, 2023 18:59
@elenatanasoiu elenatanasoiu requested a review from a team as a code owner February 21, 2023 18:59
@elenatanasoiu elenatanasoiu requested a review from a team February 21, 2023 19:10
@elenatanasoiu elenatanasoiu force-pushed the elena/fix-unhandled-arguments branch from ddf2abf to 5269e0b Compare February 21, 2023 19:16
@elenatanasoiu elenatanasoiu force-pushed the elena/install-csv-depenedencies branch from 2503b87 to 6a2bb63 Compare February 21, 2023 19:20
Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

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

What you have now is probably fine, just I think it's a little simpler to avoid re-parsing the URI.

@elenatanasoiu elenatanasoiu changed the base branch from elena/fix-unhandled-arguments to main February 22, 2023 11:00
@elenatanasoiu elenatanasoiu force-pushed the elena/install-csv-depenedencies branch from 6a2bb63 to 7a94d00 Compare February 22, 2023 11:48
@elenatanasoiu elenatanasoiu force-pushed the elena/install-csv-depenedencies branch from b24013c to e176861 Compare February 22, 2023 18:37
@adityasharad
Copy link
Copy Markdown
Contributor

This looks reasonable, but it makes me wonder why we need the separate command. Could the tour call the existing CodeQL: Install Pack Dependencies command and specify tutorial-queries as the query pack whose dependencies we want to install?

@elenatanasoiu
Copy link
Copy Markdown
Contributor Author

@adityasharad Thanks. You're right, we don't need to do this in the extension since the tutorial folder is only present in the codespace.

I've opened a new PR to run the install command: github/codespaces-codeql#10

@elenatanasoiu elenatanasoiu deleted the elena/install-csv-depenedencies branch February 23, 2023 15:50
@elenatanasoiu elenatanasoiu restored the elena/install-csv-depenedencies branch February 27, 2023 20:07
@elenatanasoiu elenatanasoiu reopened this Feb 27, 2023
@elenatanasoiu
Copy link
Copy Markdown
Contributor Author

elenatanasoiu commented Feb 27, 2023

the other PR to work with running the packInstall command in the code tour: github/codespaces-codeql#10

So I'm reopening this PR. We know this works so we can merge this and spend time separately thinking about how to run parameterised commands in the tour extension.

When a user goes through the Code Tour, we select a dummy `csv` database
for them to get them up and running.

Once they complete the code tour and would like to continue writing
queries, they will need to add their own database.

After they do that, we check the language of their new database and
generate a skeleton QL pack for them so that they don't need to create
these files by hand. See [1] for details.

This skeleton pack folder will be called
`codeql-custom-queries-<language>` and it comes with its own example
query: `example.ql`.

When we try to run this example query, the query gets confused about
which `dbscheme` to pick, as it sees a `qlpack.yml` file in the new
skeleton pack folder, as well as one in the existing `tutorial-lib`
folder.

So we'll need to get rid of the `tutorial-lib` folder in order to make room
for new queries to be run once the tour is complete.

This commit introduces a `handleTourDependencies` step which will
trigger a `codeql pack install` command in order to install real library
dependencies for `tutorial-queries`, since we no longer have the dummy
library in `tutorial-lib`.
I was initially trying to understand why this method was failing due
to an unrelated error [1] so I ended up over-engineering the path
parsing.

We can use the path from the first workspace folder, like we do in
other places in the extension.

[1]: #2104
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
@elenatanasoiu elenatanasoiu force-pushed the elena/install-csv-depenedencies branch from e176861 to 1f4790b Compare February 27, 2023 20:09
Copy link
Copy Markdown
Contributor

@adityasharad adityasharad left a comment

Choose a reason for hiding this comment

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

Approving as a temporary strategy, until we figure out how to pass directory URIs to commands via CodeTour.

@elenatanasoiu elenatanasoiu merged commit 2f92ea3 into main Feb 27, 2023
@elenatanasoiu elenatanasoiu deleted the elena/install-csv-depenedencies branch February 27, 2023 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants