Skip to content

Commit 3a188fa

Browse files
authored
Merge branch 'main' into koesie10/retry-tests
2 parents ce56e6f + b20aeb3 commit 3a188fa

File tree

104 files changed

+517
-8761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+517
-8761
lines changed

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,23 @@ jobs:
9494
asset_name: ${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}
9595
asset_content_type: application/zip
9696

97+
- name: Create sourcemap ZIP file
98+
run: |
99+
cd dist/vscode-codeql/out
100+
zip -r ../../vscode-codeql-sourcemaps.zip *.map
101+
102+
- name: Upload sourcemap ZIP file
103+
uses: actions/upload-release-asset@v1.0.1
104+
if: success()
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
# Get the `upload_url` from the `create-release` step above.
109+
upload_url: ${{ steps.create-release.outputs.upload_url }}
110+
asset_path: dist/vscode-codeql-sourcemaps.zip
111+
asset_name: ${{ format('vscode-codeql-sourcemaps-{0}.zip', steps.prepare-artifacts.outputs.ref_name) }}
112+
asset_content_type: application/zip
113+
97114
###
98115
# Do Post release work: version bump and changelog PR
99116
# Only do this if we are running from a PR (ie- this is part of the release process)

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
"env": {
4949
"LANG": "en-US",
5050
"TZ": "UTC",
51+
52+
// Uncomment to set a custom path to a CodeQL checkout.
53+
// "TEST_CODEQL_PATH": "../codeql",
54+
55+
// Uncomment to set a custom path to a CodeQL CLI executable.
56+
// This is the CodeQL version that will be used in the tests.
57+
// "CLI_PATH": "/path/to/customg/codeql",
58+
5159
// Uncomment to debug integration tests
5260
// "VSCODE_WAIT_FOR_DEBUGGER": "true",
5361
}

CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ We have several types of tests:
9999
* View tests: these live in `src/view/variant-analysis/__tests__/`
100100
* VSCode integration tests:
101101
* `test/vscode-tests/activated-extension` tests: These are intended to cover functionality that require the full extension to be activated but don't require the CLI. This suite is not run against multiple versions of the CLI in CI.
102-
* `test/vscode-tests/no-workspace` tests: These are intended to cover functionality that is meant to work before you even have a workspace open but don't require the extension to be activated.
102+
* `test/vscode-tests/no-workspace` tests: These are intended to cover functionality around not having a workspace. The extension is not activated in these tests.
103103
* `test/vscode-tests/minimal-workspace` tests: These are intended to cover functionality that need a workspace but don't require the full extension to be activated.
104104
* CLI integration tests: these live in `test/vscode-tests/cli-integration`
105-
* These tests are intended to be cover functionality that is related to the integration between the CodeQL CLI and the extension. These tests are run against all supported versions of the CLI in CI.
105+
* These tests are intended to cover functionality that is related to the integration between the CodeQL CLI and the extension. These tests are run against each supported versions of the CLI in CI.
106106

107107
The CLI integration tests require an instance of the CodeQL CLI to run so they will require some extra setup steps. When adding new tests to our test suite, please be mindful of whether they need to be in the cli-integration folder. If the tests don't depend on the CLI, they are better suited to being a VSCode integration test.
108108

@@ -229,6 +229,13 @@ Pre-recorded scenarios are stored in `./src/mocks/scenarios`. However, it's poss
229229
1. Double-check the `CHANGELOG.md` contains all desired change comments and has the version to be released with date at the top.
230230
* Go through all recent PRs and make sure they are properly accounted for.
231231
* Make sure all changelog entries have links back to their PR(s) if appropriate.
232+
* For picking the new version number, we default to increasing the patch version number, but make our own judgement about whether a change is big enough to warrant a minor version bump. Common reasons for a minor bump could include:
233+
* Making substantial new features available to all users. This can include lifting a feature flag.
234+
* Breakage in compatibility with recent versions of the CLI.
235+
* Minimum required version of VS Code is increased.
236+
* New telemetry events are added.
237+
* Deprecation or removal of commands.
238+
* Accumulation of many changes, none of which are individually big enough to warrant a minor bump, but which together are. This does not include changes which are purely internal to the extension, such as refactoring, or which are only available behind a feature flag.
232239
1. Double-check that the node version we're using matches the one used for VS Code. If it doesn't, you will then need to update the node version in the following files:
233240
* `.nvmrc` - this will enable `nvm` to automatically switch to the correct node version when you're in the project folder
234241
* `.github/workflows/main.yml` - all the "node-version: <version>" settings

extensions/ql-vscode/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,8 @@
364364
},
365365
{
366366
"command": "codeQLVariantAnalysisRepositories.openConfigFile",
367-
"title": "Open Database Configuration File",
368-
"icon": "$(edit)"
367+
"title": "Open database configuration file",
368+
"icon": "$(json)"
369369
},
370370
{
371371
"command": "codeQLVariantAnalysisRepositories.addNewDatabase",
@@ -379,7 +379,7 @@
379379
},
380380
{
381381
"command": "codeQLVariantAnalysisRepositories.setSelectedItem",
382-
"title": ""
382+
"title": "Select"
383383
},
384384
{
385385
"command": "codeQLVariantAnalysisRepositories.setSelectedItemContextMenu",
@@ -463,7 +463,7 @@
463463
},
464464
{
465465
"command": "codeQLDatabases.setCurrentDatabase",
466-
"title": "Set Current Database"
466+
"title": "Select"
467467
},
468468
{
469469
"command": "codeQLDatabases.removeDatabase",
@@ -822,7 +822,7 @@
822822
},
823823
{
824824
"command": "codeQLVariantAnalysisRepositories.setSelectedItem",
825-
"when": "view == codeQLVariantAnalysisRepositories && viewItem =~ /canBeSelected/ && false",
825+
"when": "view == codeQLVariantAnalysisRepositories && viewItem =~ /canBeSelected/",
826826
"group": "inline"
827827
},
828828
{
@@ -1326,7 +1326,7 @@
13261326
"scripts": {
13271327
"build": "gulp",
13281328
"watch": "gulp watch",
1329-
"test": "npm-run-all -p test:*",
1329+
"test": "npm-run-all test:*",
13301330
"test:unit": "cross-env TZ=UTC LANG=en-US jest --projects test/unit-tests",
13311331
"test:view": "jest --projects src/view",
13321332
"test:vscode-integration": "npm-run-all test:vscode-integration:*",

extensions/ql-vscode/scripts/source-map.ts

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { spawnSync } from "child_process";
2020
import { basename, resolve } from "path";
2121
import { pathExists, readJSON } from "fs-extra";
2222
import { RawSourceMap, SourceMapConsumer } from "source-map";
23+
import { Open } from "unzipper";
2324

2425
if (process.argv.length !== 4) {
2526
console.error(
@@ -36,6 +37,12 @@ const versionNumber = process.argv[2].startsWith("v")
3637
const stacktrace = process.argv[3];
3738

3839
async function extractSourceMap() {
40+
const releaseAssetsDirectory = resolve(
41+
__dirname,
42+
"..",
43+
"release-assets",
44+
versionNumber,
45+
);
3946
const sourceMapsDirectory = resolve(
4047
__dirname,
4148
"..",
@@ -47,34 +54,64 @@ async function extractSourceMap() {
4754
if (!(await pathExists(sourceMapsDirectory))) {
4855
console.log("Downloading source maps...");
4956

50-
const workflowRuns = runGhJSON<WorkflowRunListItem[]>([
51-
"run",
52-
"list",
53-
"--workflow",
54-
"release.yml",
55-
"--branch",
57+
const release = runGhJSON<Release>([
58+
"release",
59+
"view",
5660
versionNumber,
5761
"--json",
58-
"databaseId,number",
62+
"id,name,assets",
5963
]);
6064

61-
if (workflowRuns.length !== 1) {
62-
throw new Error(
63-
`Expected exactly one workflow run for ${versionNumber}, got ${workflowRuns.length}`,
65+
const sourcemapAsset = release.assets.find(
66+
(asset) => asset.name === `vscode-codeql-sourcemaps-${versionNumber}.zip`,
67+
);
68+
69+
if (sourcemapAsset) {
70+
// This downloads a ZIP file of the source maps
71+
runGh([
72+
"release",
73+
"download",
74+
versionNumber,
75+
"--pattern",
76+
sourcemapAsset.name,
77+
"--dir",
78+
releaseAssetsDirectory,
79+
]);
80+
81+
const file = await Open.file(
82+
resolve(releaseAssetsDirectory, sourcemapAsset.name),
6483
);
84+
await file.extract({ path: sourceMapsDirectory });
85+
} else {
86+
const workflowRuns = runGhJSON<WorkflowRunListItem[]>([
87+
"run",
88+
"list",
89+
"--workflow",
90+
"release.yml",
91+
"--branch",
92+
versionNumber,
93+
"--json",
94+
"databaseId,number",
95+
]);
96+
97+
if (workflowRuns.length !== 1) {
98+
throw new Error(
99+
`Expected exactly one workflow run for ${versionNumber}, got ${workflowRuns.length}`,
100+
);
101+
}
102+
103+
const workflowRun = workflowRuns[0];
104+
105+
runGh([
106+
"run",
107+
"download",
108+
workflowRun.databaseId.toString(),
109+
"--name",
110+
"vscode-codeql-sourcemaps",
111+
"--dir",
112+
sourceMapsDirectory,
113+
]);
65114
}
66-
67-
const workflowRun = workflowRuns[0];
68-
69-
runGh([
70-
"run",
71-
"download",
72-
workflowRun.databaseId.toString(),
73-
"--name",
74-
"vscode-codeql-sourcemaps",
75-
"--dir",
76-
sourceMapsDirectory,
77-
]);
78115
}
79116

80117
if (stacktrace.includes("at")) {
@@ -172,6 +209,17 @@ function runGhJSON<T>(args: readonly string[]): T {
172209
return JSON.parse(runGh(args));
173210
}
174211

212+
type ReleaseAsset = {
213+
id: string;
214+
name: string;
215+
};
216+
217+
type Release = {
218+
id: string;
219+
name: string;
220+
assets: ReleaseAsset[];
221+
};
222+
175223
type WorkflowRunListItem = {
176224
databaseId: number;
177225
number: number;

extensions/ql-vscode/src/contextual/queryResolver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { CancellationToken, Uri } from "vscode";
1919
import { ProgressCallback } from "../commandRunner";
2020
import { QueryRunner } from "../queryRunner";
2121
import { redactableError } from "../pure/errors";
22+
import { QLPACK_FILENAMES } from "../pure/ql";
2223

2324
export async function qlpackOfDatabase(
2425
cli: CodeQLCliServer,
@@ -113,7 +114,7 @@ async function resolveContextualQuery(
113114
// Work out the enclosing pack.
114115
const packContents = await cli.packPacklist(query, false);
115116
const packFilePath = packContents.find((p) =>
116-
["codeql-pack.yml", "qlpack.yml"].includes(basename(p)),
117+
QLPACK_FILENAMES.includes(basename(p)),
117118
);
118119
if (packFilePath === undefined) {
119120
// Should not happen; we already resolved this query.

extensions/ql-vscode/src/databases/ui/db-panel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ export class DbPanel extends DisposableObject {
254254
"Not a selectable database item. Please select a valid item.",
255255
);
256256
}
257+
258+
// Optimistically update the UI to select the item that the user
259+
// selected to avoid delay in the UI.
260+
this.dataProvider.updateSelectedItem(treeViewItem);
261+
257262
await this.dbManager.setSelectedDbItem(treeViewItem.dbItem);
258263
}
259264

extensions/ql-vscode/src/databases/ui/db-tree-data-provider.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ export class DbTreeDataProvider
4848
});
4949
}
5050

51+
/**
52+
* Updates the selected item and re-renders the tree.
53+
* @param selectedItem The item to select.
54+
*/
55+
public updateSelectedItem(selectedItem: DbTreeViewItem): void {
56+
// Unselect all items
57+
for (const item of this.dbTreeItems) {
58+
item.setAsUnselected();
59+
}
60+
61+
// Select the new item
62+
selectedItem.setAsSelected();
63+
64+
// Re-render the tree
65+
this._onDidChangeTreeData.fire(undefined);
66+
}
67+
5168
/**
5269
* Called when expanding a node (including the root node).
5370
* @param node The node to expand.

extensions/ql-vscode/src/databases/ui/db-tree-view-item.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,19 @@ export class DbTreeViewItem extends vscode.TreeItem {
3636
if (dbItem) {
3737
this.contextValue = getContextValue(dbItem);
3838
if (isSelectableDbItem(dbItem) && dbItem.selected) {
39-
// Define the resource id to drive the UI to render this item as selected.
40-
this.resourceUri = vscode.Uri.parse(SELECTED_DB_ITEM_RESOURCE_URI);
39+
this.setAsSelected();
4140
}
4241
}
4342
}
43+
44+
public setAsSelected(): void {
45+
// Define the resource id to drive the UI to render this item as selected.
46+
this.resourceUri = vscode.Uri.parse(SELECTED_DB_ITEM_RESOURCE_URI);
47+
}
48+
49+
public setAsUnselected(): void {
50+
this.resourceUri = undefined;
51+
}
4452
}
4553

4654
function getContextValue(dbItem: DbItem): string | undefined {

0 commit comments

Comments
 (0)