Skip to content

Allow synthetic variant analysis packs to handle ${workspace} #1774

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

Merged
merged 2 commits into from
Nov 18, 2022

Conversation

aeisenberg
Copy link
Contributor

@aeisenberg aeisenberg commented Nov 18, 2022

${workspace} references are new in CLI version 2.11.3. These mean that
the version depended upon in a pack must be the version available in the
current codeql workspace.

When generating a variant analysis pack, however, we copy the target
query and generate a synthetic pack with the original dependencies.
This breaks workspace references since the synthetic pack is no longer
in the same workspace.

A simple workaround is to replace ${workspace} with * references.

I wanted to ensure the tests exercise this feature, so I altered one of our test qlpacks to use the ${workspace} reference. This will work on CLI v2.11.3 and later. For earlier versions, I needed to change that reference to a * reference.

I also fixed a problem I was having locally where the CLI tests were timing out. By bumping the timeout to 20s in the testConfigHelper, I got around that error.

Checklist

  • [n/a] 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.
  • [n/a] [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.

Also, we're no longer using the rush package manager, so delete that
from gitignore.
@aeisenberg aeisenberg requested review from a team as code owners November 18, 2022 20:24
Copy link
Contributor

@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

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

Looks like a test is failing, but I'll be around to review any changes/release changes.

@aeisenberg
Copy link
Contributor Author

Of course...${workspace} is not recognized by CLI versions < 2.11.3.

@aeisenberg aeisenberg force-pushed the aeisenberg/fix-mrva-packs branch from 9129e05 to 647a718 Compare November 18, 2022 21:18
@aeisenberg aeisenberg force-pushed the aeisenberg/fix-mrva-packs branch 7 times, most recently from 8de6ae0 to 0f66afe Compare November 18, 2022 22:14
@aeisenberg
Copy link
Contributor Author

I think I found out why the CLI tests are failing locally. I made a change to https://github.com/aeisenberg/vscode-codeql/blob/aeisenberg/fix-mrva-packs/extensions/ql-vscode/src/vscode-tests/test-config.ts#L110 to add a timeout. Also, the github.vscode-pull-request-github extension was causing a 403 error. Disabling the extension seems to help.

@aeisenberg
Copy link
Contributor Author

@angelapwen would you mind taking another look? I think the tests are passing now. I had to do a bit of magic to get the tests working. I'll explain better in the PR description.

Copy link
Contributor

@angelapwen angelapwen 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 to me 👍 just some requests for code comments 😄

codeql/javascript-all: '*'
codeql/javascript-all: '${workspace}'
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know these tests well, but do you think you could add a comment here to explain that the '${workspace}' bit is important to ensure tests pass? Not sure that it's clear from the name of the test/directory.

@@ -122,3 +125,34 @@ export async function cleanDatabases(databaseManager: DatabaseManager) {
await commands.executeCommand("codeQLDatabases.removeDatabase", item);
}
}

export async function fixWorkspaceReferences(
Copy link
Contributor

Choose a reason for hiding this comment

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

Also wonder if you could add a comment here to describe why someone would use this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return undefined;
}

export async function restoreWorkspaceReferences(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above (comment description)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

`${workspace}` references are new in CLI version 2.11.3. These mean that
the version depended upon in a pack must be the version available in the
current codeql workspace.

When generating a variant analysis pack, however, we copy the target
query and generate a synthetic pack with the original dependencies.
This breaks workspace references since the synthetic pack is no longer
in the same workspace.

A simple workaround is to replace `${workspace}` with `*` references.
@aeisenberg aeisenberg force-pushed the aeisenberg/fix-mrva-packs branch from 0f66afe to 24bbd51 Compare November 18, 2022 22:47
@aeisenberg aeisenberg enabled auto-merge November 18, 2022 22:49
@aeisenberg aeisenberg merged commit e93d839 into main Nov 18, 2022
@aeisenberg aeisenberg deleted the aeisenberg/fix-mrva-packs branch November 18, 2022 23:00
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.

2 participants