Skip to content

Commit 110f5f9

Browse files
author
Dave Bartolomeo
committed
Merge remote-tracking branch 'origin/main' into dbartol/debug-context
2 parents 41e0702 + 8a4f283 commit 110f5f9

10 files changed

Lines changed: 60 additions & 63 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -67,49 +67,19 @@ jobs:
6767

6868
# TODO Run tests, or check that a test run on the same branch succeeded.
6969

70-
- name: Create release
71-
id: create-release
72-
uses: actions/create-release@v1.0.0
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
with:
76-
tag_name: ${{ github.ref }}
77-
release_name: Release ${{ github.ref }}
78-
# This gives us a chance to manually review the created release before publishing it,
79-
# as well as to test the release workflow by pushing temporary tags.
80-
# Once we have set all required release metadata in this step, we can set this to `false`.
81-
draft: true
82-
prerelease: false
83-
84-
- name: Upload release asset
85-
uses: actions/upload-release-asset@v1.0.1
86-
if: success()
87-
env:
88-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89-
with:
90-
# Get the `upload_url` from the `create-release` step above.
91-
upload_url: ${{ steps.create-release.outputs.upload_url }}
92-
# Get the `vsix_path` and `ref_name` from the `prepare-artifacts` step above.
93-
asset_path: ${{ steps.prepare-artifacts.outputs.vsix_path }}
94-
asset_name: ${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}
95-
asset_content_type: application/zip
96-
9770
- name: Create sourcemap ZIP file
9871
run: |
9972
cd dist/vscode-codeql/out
10073
zip -r ../../vscode-codeql-sourcemaps.zip *.map
10174
102-
- name: Upload sourcemap ZIP file
103-
uses: actions/upload-release-asset@v1.0.1
104-
if: success()
75+
- name: Create release
76+
id: create-release
77+
run: |
78+
gh release create ${{ github.ref_name }} --draft --title "Release ${{ github.ref_name }}" \
79+
'${{ steps.prepare-artifacts.outputs.vsix_path }}#${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}' \
80+
'dist/vscode-codeql-sourcemaps.zip#${{ format('vscode-codeql-sourcemaps-{0}.zip', steps.prepare-artifacts.outputs.ref_name) }}'
10581
env:
10682
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
11383

11484
###
11585
# Do Post release work: version bump and changelog PR
@@ -164,10 +134,7 @@ jobs:
164134

165135
- name: Publish to Registry
166136
run: |
167-
npx vsce publish -p $VSCE_TOKEN --packagePath *.vsix || \
168-
echo "Failed to publish to VS Code Marketplace. \
169-
If this was an authentication problem, please make sure the \
170-
auth token hasn't expired."
137+
npx vsce publish -p $VSCE_TOKEN --packagePath *.vsix
171138
172139
open-vsx-publish:
173140
name: Publish to Open VSX Registry

extensions/ql-vscode/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export async function prepareCodeTour(
304304
return;
305305
}
306306

307-
const tutorialWorkspaceUri = Uri.parse(tutorialWorkspacePath);
307+
const tutorialWorkspaceUri = Uri.file(tutorialWorkspacePath);
308308

309309
void extLogger.log(
310310
`In prepareCodeTour() method, going to open the tutorial workspace file: ${tutorialWorkspacePath}`,

extensions/ql-vscode/src/local-databases.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,15 @@ export class DatabaseManager extends DisposableObject {
10081008
});
10091009
}
10101010

1011+
public async removeAllDatabases(
1012+
progress: ProgressCallback,
1013+
token: vscode.CancellationToken,
1014+
) {
1015+
for (const item of this.databaseItems) {
1016+
await this.removeDatabaseItem(progress, token, item);
1017+
}
1018+
}
1019+
10111020
private async deregisterDatabase(
10121021
progress: ProgressCallback,
10131022
token: vscode.CancellationToken,

extensions/ql-vscode/src/variant-analysis/variant-analysis-monitor.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EventEmitter } from "vscode";
1+
import { env, EventEmitter } from "vscode";
22
import { getVariantAnalysis } from "./gh-api/gh-api-client";
33

44
import {
@@ -57,7 +57,11 @@ export class VariantAnalysisMonitor extends DisposableObject {
5757
);
5858
} catch (e) {
5959
void showAndLogWarningMessage(
60-
`Error while monitoring variant analysis: ${getErrorMessage(e)}`,
60+
`Error while monitoring variant analysis ${
61+
variantAnalysis.query.name
62+
} (${variantAnalysis.query.language}) [${new Date(
63+
variantAnalysis.executionStartTime,
64+
).toLocaleString(env.language)}]: ${getErrorMessage(e)}`,
6165
);
6266
continue;
6367
}

extensions/ql-vscode/test/vscode-tests/activated-extension/databases/db-panel.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, window } from "vscode";
1+
import { window } from "vscode";
22

33
import { readJson } from "fs-extra";
44
import * as path from "path";
@@ -15,11 +15,14 @@ import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases
1515
import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories";
1616
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
1717
import { getActivatedExtension } from "../../global.helper";
18+
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
19+
import { AllCommands } from "../../../../src/common/commands";
1820

1921
jest.setTimeout(60_000);
2022

2123
describe("Db panel UI commands", () => {
2224
let storagePath: string;
25+
const commandManager = createVSCodeCommandManager<AllCommands>();
2326

2427
beforeEach(async () => {
2528
const extension = await getActivatedExtension();
@@ -31,7 +34,7 @@ describe("Db panel UI commands", () => {
3134
it("should add new remote db list", async () => {
3235
// Add db list
3336
jest.spyOn(window, "showInputBox").mockResolvedValue("my-list-1");
34-
await commands.executeCommand(
37+
await commandManager.execute(
3538
"codeQLVariantAnalysisRepositories.addNewList",
3639
);
3740

@@ -53,7 +56,7 @@ describe("Db panel UI commands", () => {
5356
kind: DbListKind.Local,
5457
} as AddListQuickPickItem);
5558
jest.spyOn(window, "showInputBox").mockResolvedValue("my-list-1");
56-
await commands.executeCommand(
59+
await commandManager.execute(
5760
"codeQLVariantAnalysisRepositories.addNewList",
5861
);
5962

@@ -74,7 +77,7 @@ describe("Db panel UI commands", () => {
7477
} as RemoteDatabaseQuickPickItem);
7578

7679
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1/repo1");
77-
await commands.executeCommand(
80+
await commandManager.execute(
7881
"codeQLVariantAnalysisRepositories.addNewDatabase",
7982
);
8083

@@ -97,7 +100,7 @@ describe("Db panel UI commands", () => {
97100
} as RemoteDatabaseQuickPickItem);
98101

99102
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1");
100-
await commands.executeCommand(
103+
await commandManager.execute(
101104
"codeQLVariantAnalysisRepositories.addNewDatabase",
102105
);
103106

@@ -119,7 +122,7 @@ describe("Db panel UI commands", () => {
119122
"tooltip",
120123
);
121124

122-
await commands.executeCommand(
125+
await commandManager.execute(
123126
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu",
124127
treeViewItem,
125128
);

extensions/ql-vscode/test/vscode-tests/cli-integration/queries.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CancellationToken, commands, ExtensionContext, Uri } from "vscode";
1+
import { CancellationToken, ExtensionContext, Uri } from "vscode";
22
import { join, dirname } from "path";
33
import {
44
pathExistsSync,
@@ -24,6 +24,8 @@ import { SELECT_QUERY_NAME } from "../../../src/contextual/locationFinder";
2424
import { createMockCommandManager } from "../../__mocks__/commandsMock";
2525
import { LocalQueries } from "../../../src/local-queries";
2626
import { QueryResultType } from "../../../src/pure/new-messages";
27+
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
28+
import { AllCommands, QueryServerCommands } from "../../../src/common/commands";
2729

2830
jest.setTimeout(20_000);
2931

@@ -39,6 +41,9 @@ describeWithCodeQL()("Queries", () => {
3941
const progress = jest.fn();
4042
let token: CancellationToken;
4143
let ctx: ExtensionContext;
44+
const appCommandManager = createVSCodeCommandManager<AllCommands>();
45+
const queryServerCommandManager =
46+
createVSCodeCommandManager<QueryServerCommands>();
4247

4348
let qlpackFile: string;
4449
let qlpackLockFile: string;
@@ -181,7 +186,7 @@ describeWithCodeQL()("Queries", () => {
181186

182187
// Asserts a fix for bug https://github.com/github/vscode-codeql/issues/733
183188
it("should restart the database and run a query", async () => {
184-
await commands.executeCommand("codeQL.restartQueryServer");
189+
await appCommandManager.execute("codeQL.restartQueryServer");
185190
const queryPath = join(__dirname, "data", "simple-query.ql");
186191
const result = await localQueries.compileAndRunQueryInternal(
187192
false,
@@ -196,7 +201,7 @@ describeWithCodeQL()("Queries", () => {
196201
});
197202

198203
it("should create a quick query", async () => {
199-
await commands.executeCommand("codeQL.quickQuery");
204+
await queryServerCommandManager.execute("codeQL.quickQuery");
200205

201206
// should have created the quick query file and query pack file
202207
expect(pathExistsSync(qlFile)).toBe(true);
@@ -229,7 +234,7 @@ describeWithCodeQL()("Queries", () => {
229234
}),
230235
);
231236
writeFileSync(qlFile, "xxx");
232-
await commands.executeCommand("codeQL.quickQuery");
237+
await queryServerCommandManager.execute("codeQL.quickQuery");
233238

234239
// should not have created the quick query file because database schema hasn't changed
235240
expect(readFileSync(qlFile, "utf8")).toBe("xxx");

extensions/ql-vscode/test/vscode-tests/cli-integration/sourcemap.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import { commands, Selection, window, workspace } from "vscode";
1+
import { Selection, window, workspace } from "vscode";
22
import { join, basename } from "path";
33
import { tmpDir } from "../../../src/helpers";
44
import { readFile, writeFile, ensureDir, copy } from "fs-extra";
5+
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
6+
import { AllCommands } from "../../../src/common/commands";
57

68
jest.setTimeout(20_000);
79

810
/**
911
* Integration tests for queries
1012
*/
1113
describe("SourceMap", () => {
14+
const commandManager = createVSCodeCommandManager<AllCommands>();
15+
1216
it("should jump to QL code", async () => {
1317
const root = workspace.workspaceFolders![0].uri.fsPath;
1418
const srcFiles = {
@@ -32,7 +36,7 @@ describe("SourceMap", () => {
3236
expect(summaryDocument.languageId).toBe("ql-summary");
3337
const summaryEditor = await window.showTextDocument(summaryDocument);
3438
summaryEditor.selection = new Selection(356, 10, 356, 10);
35-
await commands.executeCommand("codeQL.gotoQL");
39+
await commandManager.execute("codeQL.gotoQL");
3640

3741
const newEditor = window.activeTextEditor;
3842
expect(newEditor).toBeDefined();

extensions/ql-vscode/test/vscode-tests/cli-integration/variant-analysis/variant-analysis-submission-integration.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { MockGitHubApiServer } from "../../../../src/mocks/mock-gh-api-server";
1212
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
1313
import { setRemoteControllerRepo } from "../../../../src/config";
1414
import { getActivatedExtension } from "../../global.helper";
15+
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
16+
import { AllCommands } from "../../../../src/common/commands";
1517

1618
jest.setTimeout(30_000);
1719

@@ -29,6 +31,7 @@ async function showQlDocument(name: string): Promise<TextDocument> {
2931
}
3032

3133
describe("Variant Analysis Submission Integration", () => {
34+
const commandManager = createVSCodeCommandManager<AllCommands>();
3235
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
3336
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
3437
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
@@ -68,7 +71,7 @@ describe("Variant Analysis Submission Integration", () => {
6871
// Select target language for your query
6972
quickPickSpy.mockResolvedValueOnce(mockedQuickPickItem("javascript"));
7073

71-
await commands.executeCommand("codeQL.runVariantAnalysis");
74+
await commandManager.execute("codeQL.runVariantAnalysis");
7275

7376
expect(executeCommandSpy).toHaveBeenCalledWith(
7477
"codeQL.openVariantAnalysisView",
@@ -85,7 +88,7 @@ describe("Variant Analysis Submission Integration", () => {
8588
it("shows the error message", async () => {
8689
await showQlDocument("query.ql");
8790

88-
await commands.executeCommand("codeQL.runVariantAnalysis");
91+
await commandManager.execute("codeQL.runVariantAnalysis");
8992

9093
expect(showErrorMessageSpy).toHaveBeenCalledWith(
9194
expect.stringContaining(
@@ -107,7 +110,7 @@ describe("Variant Analysis Submission Integration", () => {
107110
// Select target language for your query
108111
quickPickSpy.mockResolvedValueOnce(mockedQuickPickItem("javascript"));
109112

110-
await commands.executeCommand("codeQL.runVariantAnalysis");
113+
await commandManager.execute("codeQL.runVariantAnalysis");
111114

112115
expect(showErrorMessageSpy).toHaveBeenCalledWith(
113116
expect.stringContaining(

extensions/ql-vscode/test/vscode-tests/global.helper.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { join } from "path";
22
import { load, dump } from "js-yaml";
33
import { realpathSync, readFileSync, writeFileSync } from "fs-extra";
4-
import { commands, extensions } from "vscode";
4+
import { CancellationToken, extensions } from "vscode";
55
import { DatabaseManager } from "../../src/local-databases";
66
import { CodeQLCliServer } from "../../src/cli";
77
import { removeWorkspaceRefs } from "../../src/variant-analysis/run-remote-query";
88
import { CodeQLExtensionInterface } from "../../src/extension";
9+
import { ProgressCallback } from "../../src/progress";
910

1011
// This file contains helpers shared between tests that work with an activated extension.
1112

@@ -37,9 +38,10 @@ export async function getActivatedExtension(): Promise<CodeQLExtensionInterface>
3738
}
3839

3940
export async function cleanDatabases(databaseManager: DatabaseManager) {
40-
for (const item of databaseManager.databaseItems) {
41-
await commands.executeCommand("codeQLDatabases.removeDatabase", item);
42-
}
41+
await databaseManager.removeAllDatabases(
42+
{} as ProgressCallback,
43+
{} as CancellationToken,
44+
);
4345
}
4446

4547
/**

extensions/ql-vscode/test/vscode-tests/no-workspace/helpers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ describe("prepareCodeTour", () => {
619619
expect(executeCommand).toHaveBeenCalledWith(
620620
"vscode.openFolder",
621621
expect.objectContaining({
622-
path: Uri.parse(tutorialWorkspacePath).fsPath,
622+
path: expect.stringMatching(/tutorial.code-workspace$/),
623623
}),
624624
);
625625
});

0 commit comments

Comments
 (0)