Skip to content

Conversation

@elenatanasoiu
Copy link
Contributor

@elenatanasoiu elenatanasoiu commented Jan 31, 2023

Makes this possible: github/codespaces-codeql#4

We have a codespace template which houses our CodeQL tour: https://github.com/github/codespaces-codeql

This contains a repo with a default databases already loaded for the user so that they can start writing queries more quickly.

At the moment we're asking the user to manually right click on the database folder (codeql-tutorial-database) and set it as the current database.

We can take this one step further by defining a command that gets triggered when we arrive at the step for setting up the database.

The command (codeQL.setDefaultTourDatabase) will build the URI pointing to our preloaded database and set it as the current one.

We initially considered whether we can re-use the setCurrentDatabase command and pass the URI of the database from the codespace itself, but the URI would be hardcoded as:

file://0-62/workspaces/codespaces-codeql/codeql-tutorial-database

as we can only pass the codeTour extension a command and string parameters.

This would have been brittle as the filepath for a codespace might change in the future.

Instead we can define a custom tour command (setDefaultTourDatabase) to look at the current workspace folder and build the path to the database in the CodeQL extension.

We've made the command publicly visible so that we can execute it from our code tour.

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.

@elenatanasoiu elenatanasoiu force-pushed the elena/select-db-in-codespace branch from d38017a to 1fe410f Compare January 31, 2023 13:35
@elenatanasoiu elenatanasoiu marked this pull request as ready for review January 31, 2023 14:08
@elenatanasoiu elenatanasoiu requested a review from a team as a code owner January 31, 2023 14:08
@elenatanasoiu elenatanasoiu requested review from a team and adityasharad January 31, 2023 14:08
Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

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

Looks good, but then we paired on this, so I'm happy for another pair of eyes 😅 👀

@shati-patel
Copy link
Contributor

[As discussed offline too]
Latest commit (e2c37c5) removes our new command from the package.json file. We don't want anyone to call codeQL.setDefaultTourDatabase manually, and I've double-checked that the code tour can still use it, so no need to define it "publicly"!

elenatanasoiu and others added 4 commits February 2, 2023 10:27
We have a codespace template which houses our CodeQL tour:
https://github.com/github/codespaces-codeql

This contains a repo with a default databases already loaded
for the user so that they can start writing queries more quickly.

At the moment we're asking the user to manually right click on
the database folder ('codeql-tutorial-database') and set it as
the current database.

We can take this one step further by defining a command that gets
triggered when we arrive at the step for setting up the database.

The command ("codeQL.setDefaultTourDatabase") will build the URI
pointing to our preloaded database and set it as the current one.

We initially considered whether we can re-use the setCurrentDatabase
command and pass the URI of the database from the codespace itself,
but the URI would be hardcoded as:

```
file://0-62/workspaces/codespaces-codeql/codeql-tutorial-database
```

as we can only pass the codeTour extension a command and string
parameters.

This would have been brittle as the filepath for a codespace might
change in the future.

Instead we can define a custom tour command ("setDefaultTourDatabase")
to look at the current workspace folder and build the path to the
database in the CodeQL extension.

Co-authored-by: Shati Patel <shati-patel@github.com>
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
@elenatanasoiu elenatanasoiu force-pushed the elena/select-db-in-codespace branch from 6eaad25 to 99d794c Compare February 2, 2023 10:30
Copy link
Contributor

@shati-patel shati-patel left a comment

Choose a reason for hiding this comment

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

All comments addressed, thanks!

@elenatanasoiu elenatanasoiu merged commit c493425 into main Feb 2, 2023
@elenatanasoiu elenatanasoiu deleted the elena/select-db-in-codespace branch February 2, 2023 12:05
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.

5 participants