Merge branch 'main' into dbartol/local-queries-commands
This commit is contained in:
47
.github/workflows/release.yml
vendored
47
.github/workflows/release.yml
vendored
@@ -67,49 +67,19 @@ jobs:
|
||||
|
||||
# TODO Run tests, or check that a test run on the same branch succeeded.
|
||||
|
||||
- name: Create release
|
||||
id: create-release
|
||||
uses: actions/create-release@v1.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
# This gives us a chance to manually review the created release before publishing it,
|
||||
# as well as to test the release workflow by pushing temporary tags.
|
||||
# Once we have set all required release metadata in this step, we can set this to `false`.
|
||||
draft: true
|
||||
prerelease: false
|
||||
|
||||
- name: Upload release asset
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
if: success()
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
# Get the `upload_url` from the `create-release` step above.
|
||||
upload_url: ${{ steps.create-release.outputs.upload_url }}
|
||||
# Get the `vsix_path` and `ref_name` from the `prepare-artifacts` step above.
|
||||
asset_path: ${{ steps.prepare-artifacts.outputs.vsix_path }}
|
||||
asset_name: ${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}
|
||||
asset_content_type: application/zip
|
||||
|
||||
- name: Create sourcemap ZIP file
|
||||
run: |
|
||||
cd dist/vscode-codeql/out
|
||||
zip -r ../../vscode-codeql-sourcemaps.zip *.map
|
||||
|
||||
- name: Upload sourcemap ZIP file
|
||||
uses: actions/upload-release-asset@v1.0.1
|
||||
if: success()
|
||||
- name: Create release
|
||||
id: create-release
|
||||
run: |
|
||||
gh release create ${{ github.ref_name }} --draft --title "Release ${{ github.ref_name }}" \
|
||||
'${{ steps.prepare-artifacts.outputs.vsix_path }}#${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }}' \
|
||||
'dist/vscode-codeql-sourcemaps.zip#${{ format('vscode-codeql-sourcemaps-{0}.zip', steps.prepare-artifacts.outputs.ref_name) }}'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
# Get the `upload_url` from the `create-release` step above.
|
||||
upload_url: ${{ steps.create-release.outputs.upload_url }}
|
||||
asset_path: dist/vscode-codeql-sourcemaps.zip
|
||||
asset_name: ${{ format('vscode-codeql-sourcemaps-{0}.zip', steps.prepare-artifacts.outputs.ref_name) }}
|
||||
asset_content_type: application/zip
|
||||
|
||||
###
|
||||
# Do Post release work: version bump and changelog PR
|
||||
@@ -164,10 +134,7 @@ jobs:
|
||||
|
||||
- name: Publish to Registry
|
||||
run: |
|
||||
npx vsce publish -p $VSCE_TOKEN --packagePath *.vsix || \
|
||||
echo "Failed to publish to VS Code Marketplace. \
|
||||
If this was an authentication problem, please make sure the \
|
||||
auth token hasn't expired."
|
||||
npx vsce publish -p $VSCE_TOKEN --packagePath *.vsix
|
||||
|
||||
open-vsx-publish:
|
||||
name: Publish to Open VSX Registry
|
||||
|
||||
@@ -304,7 +304,7 @@ export async function prepareCodeTour(
|
||||
return;
|
||||
}
|
||||
|
||||
const tutorialWorkspaceUri = Uri.parse(tutorialWorkspacePath);
|
||||
const tutorialWorkspaceUri = Uri.file(tutorialWorkspacePath);
|
||||
|
||||
void extLogger.log(
|
||||
`In prepareCodeTour() method, going to open the tutorial workspace file: ${tutorialWorkspacePath}`,
|
||||
|
||||
@@ -1008,6 +1008,15 @@ export class DatabaseManager extends DisposableObject {
|
||||
});
|
||||
}
|
||||
|
||||
public async removeAllDatabases(
|
||||
progress: ProgressCallback,
|
||||
token: vscode.CancellationToken,
|
||||
) {
|
||||
for (const item of this.databaseItems) {
|
||||
await this.removeDatabaseItem(progress, token, item);
|
||||
}
|
||||
}
|
||||
|
||||
private async deregisterDatabase(
|
||||
progress: ProgressCallback,
|
||||
token: vscode.CancellationToken,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EventEmitter } from "vscode";
|
||||
import { env, EventEmitter } from "vscode";
|
||||
import { getVariantAnalysis } from "./gh-api/gh-api-client";
|
||||
|
||||
import {
|
||||
@@ -57,7 +57,11 @@ export class VariantAnalysisMonitor extends DisposableObject {
|
||||
);
|
||||
} catch (e) {
|
||||
void showAndLogWarningMessage(
|
||||
`Error while monitoring variant analysis: ${getErrorMessage(e)}`,
|
||||
`Error while monitoring variant analysis ${
|
||||
variantAnalysis.query.name
|
||||
} (${variantAnalysis.query.language}) [${new Date(
|
||||
variantAnalysis.executionStartTime,
|
||||
).toLocaleString(env.language)}]: ${getErrorMessage(e)}`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { commands, window } from "vscode";
|
||||
import { window } from "vscode";
|
||||
|
||||
import { readJson } from "fs-extra";
|
||||
import * as path from "path";
|
||||
@@ -15,11 +15,14 @@ import { createDbTreeViewItemSystemDefinedList } from "../../../../src/databases
|
||||
import { createRemoteSystemDefinedListDbItem } from "../../../factories/db-item-factories";
|
||||
import { DbConfigStore } from "../../../../src/databases/config/db-config-store";
|
||||
import { getActivatedExtension } from "../../global.helper";
|
||||
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
|
||||
import { AllCommands } from "../../../../src/common/commands";
|
||||
|
||||
jest.setTimeout(60_000);
|
||||
|
||||
describe("Db panel UI commands", () => {
|
||||
let storagePath: string;
|
||||
const commandManager = createVSCodeCommandManager<AllCommands>();
|
||||
|
||||
beforeEach(async () => {
|
||||
const extension = await getActivatedExtension();
|
||||
@@ -31,7 +34,7 @@ describe("Db panel UI commands", () => {
|
||||
it("should add new remote db list", async () => {
|
||||
// Add db list
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("my-list-1");
|
||||
await commands.executeCommand(
|
||||
await commandManager.execute(
|
||||
"codeQLVariantAnalysisRepositories.addNewList",
|
||||
);
|
||||
|
||||
@@ -53,7 +56,7 @@ describe("Db panel UI commands", () => {
|
||||
kind: DbListKind.Local,
|
||||
} as AddListQuickPickItem);
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("my-list-1");
|
||||
await commands.executeCommand(
|
||||
await commandManager.execute(
|
||||
"codeQLVariantAnalysisRepositories.addNewList",
|
||||
);
|
||||
|
||||
@@ -74,7 +77,7 @@ describe("Db panel UI commands", () => {
|
||||
} as RemoteDatabaseQuickPickItem);
|
||||
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1/repo1");
|
||||
await commands.executeCommand(
|
||||
await commandManager.execute(
|
||||
"codeQLVariantAnalysisRepositories.addNewDatabase",
|
||||
);
|
||||
|
||||
@@ -97,7 +100,7 @@ describe("Db panel UI commands", () => {
|
||||
} as RemoteDatabaseQuickPickItem);
|
||||
|
||||
jest.spyOn(window, "showInputBox").mockResolvedValue("owner1");
|
||||
await commands.executeCommand(
|
||||
await commandManager.execute(
|
||||
"codeQLVariantAnalysisRepositories.addNewDatabase",
|
||||
);
|
||||
|
||||
@@ -119,7 +122,7 @@ describe("Db panel UI commands", () => {
|
||||
"tooltip",
|
||||
);
|
||||
|
||||
await commands.executeCommand(
|
||||
await commandManager.execute(
|
||||
"codeQLVariantAnalysisRepositories.setSelectedItemContextMenu",
|
||||
treeViewItem,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CancellationToken, commands, ExtensionContext, Uri } from "vscode";
|
||||
import { CancellationToken, ExtensionContext, Uri } from "vscode";
|
||||
import { join, dirname } from "path";
|
||||
import {
|
||||
pathExistsSync,
|
||||
@@ -24,6 +24,8 @@ import { SELECT_QUERY_NAME } from "../../../src/contextual/locationFinder";
|
||||
import { createMockCommandManager } from "../../__mocks__/commandsMock";
|
||||
import { LocalQueries } from "../../../src/local-queries";
|
||||
import { QueryResultType } from "../../../src/pure/new-messages";
|
||||
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
|
||||
import { AllCommands, QueryServerCommands } from "../../../src/common/commands";
|
||||
|
||||
jest.setTimeout(20_000);
|
||||
|
||||
@@ -39,6 +41,9 @@ describeWithCodeQL()("Queries", () => {
|
||||
const progress = jest.fn();
|
||||
let token: CancellationToken;
|
||||
let ctx: ExtensionContext;
|
||||
const appCommandManager = createVSCodeCommandManager<AllCommands>();
|
||||
const queryServerCommandManager =
|
||||
createVSCodeCommandManager<QueryServerCommands>();
|
||||
|
||||
let qlpackFile: string;
|
||||
let qlpackLockFile: string;
|
||||
@@ -181,7 +186,7 @@ describeWithCodeQL()("Queries", () => {
|
||||
|
||||
// Asserts a fix for bug https://github.com/github/vscode-codeql/issues/733
|
||||
it("should restart the database and run a query", async () => {
|
||||
await commands.executeCommand("codeQL.restartQueryServer");
|
||||
await appCommandManager.execute("codeQL.restartQueryServer");
|
||||
const queryPath = join(__dirname, "data", "simple-query.ql");
|
||||
const result = await localQueries.compileAndRunQueryInternal(
|
||||
false,
|
||||
@@ -196,7 +201,7 @@ describeWithCodeQL()("Queries", () => {
|
||||
});
|
||||
|
||||
it("should create a quick query", async () => {
|
||||
await commands.executeCommand("codeQL.quickQuery");
|
||||
await queryServerCommandManager.execute("codeQL.quickQuery");
|
||||
|
||||
// should have created the quick query file and query pack file
|
||||
expect(pathExistsSync(qlFile)).toBe(true);
|
||||
@@ -229,7 +234,7 @@ describeWithCodeQL()("Queries", () => {
|
||||
}),
|
||||
);
|
||||
writeFileSync(qlFile, "xxx");
|
||||
await commands.executeCommand("codeQL.quickQuery");
|
||||
await queryServerCommandManager.execute("codeQL.quickQuery");
|
||||
|
||||
// should not have created the quick query file because database schema hasn't changed
|
||||
expect(readFileSync(qlFile, "utf8")).toBe("xxx");
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { commands, Selection, window, workspace } from "vscode";
|
||||
import { Selection, window, workspace } from "vscode";
|
||||
import { join, basename } from "path";
|
||||
import { tmpDir } from "../../../src/helpers";
|
||||
import { readFile, writeFile, ensureDir, copy } from "fs-extra";
|
||||
import { createVSCodeCommandManager } from "../../../src/common/vscode/commands";
|
||||
import { AllCommands } from "../../../src/common/commands";
|
||||
|
||||
jest.setTimeout(20_000);
|
||||
|
||||
@@ -9,6 +11,8 @@ jest.setTimeout(20_000);
|
||||
* Integration tests for queries
|
||||
*/
|
||||
describe("SourceMap", () => {
|
||||
const commandManager = createVSCodeCommandManager<AllCommands>();
|
||||
|
||||
it("should jump to QL code", async () => {
|
||||
const root = workspace.workspaceFolders![0].uri.fsPath;
|
||||
const srcFiles = {
|
||||
@@ -32,7 +36,7 @@ describe("SourceMap", () => {
|
||||
expect(summaryDocument.languageId).toBe("ql-summary");
|
||||
const summaryEditor = await window.showTextDocument(summaryDocument);
|
||||
summaryEditor.selection = new Selection(356, 10, 356, 10);
|
||||
await commands.executeCommand("codeQL.gotoQL");
|
||||
await commandManager.execute("codeQL.gotoQL");
|
||||
|
||||
const newEditor = window.activeTextEditor;
|
||||
expect(newEditor).toBeDefined();
|
||||
|
||||
@@ -12,6 +12,8 @@ import { MockGitHubApiServer } from "../../../../src/mocks/mock-gh-api-server";
|
||||
import { mockedQuickPickItem } from "../../utils/mocking.helpers";
|
||||
import { setRemoteControllerRepo } from "../../../../src/config";
|
||||
import { getActivatedExtension } from "../../global.helper";
|
||||
import { createVSCodeCommandManager } from "../../../../src/common/vscode/commands";
|
||||
import { AllCommands } from "../../../../src/common/commands";
|
||||
|
||||
jest.setTimeout(30_000);
|
||||
|
||||
@@ -29,6 +31,7 @@ async function showQlDocument(name: string): Promise<TextDocument> {
|
||||
}
|
||||
|
||||
describe("Variant Analysis Submission Integration", () => {
|
||||
const commandManager = createVSCodeCommandManager<AllCommands>();
|
||||
let quickPickSpy: jest.SpiedFunction<typeof window.showQuickPick>;
|
||||
let executeCommandSpy: jest.SpiedFunction<typeof commands.executeCommand>;
|
||||
let showErrorMessageSpy: jest.SpiedFunction<typeof window.showErrorMessage>;
|
||||
@@ -68,7 +71,7 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
// Select target language for your query
|
||||
quickPickSpy.mockResolvedValueOnce(mockedQuickPickItem("javascript"));
|
||||
|
||||
await commands.executeCommand("codeQL.runVariantAnalysis");
|
||||
await commandManager.execute("codeQL.runVariantAnalysis");
|
||||
|
||||
expect(executeCommandSpy).toHaveBeenCalledWith(
|
||||
"codeQL.openVariantAnalysisView",
|
||||
@@ -85,7 +88,7 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
it("shows the error message", async () => {
|
||||
await showQlDocument("query.ql");
|
||||
|
||||
await commands.executeCommand("codeQL.runVariantAnalysis");
|
||||
await commandManager.execute("codeQL.runVariantAnalysis");
|
||||
|
||||
expect(showErrorMessageSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
@@ -107,7 +110,7 @@ describe("Variant Analysis Submission Integration", () => {
|
||||
// Select target language for your query
|
||||
quickPickSpy.mockResolvedValueOnce(mockedQuickPickItem("javascript"));
|
||||
|
||||
await commands.executeCommand("codeQL.runVariantAnalysis");
|
||||
await commandManager.execute("codeQL.runVariantAnalysis");
|
||||
|
||||
expect(showErrorMessageSpy).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { join } from "path";
|
||||
import { load, dump } from "js-yaml";
|
||||
import { realpathSync, readFileSync, writeFileSync } from "fs-extra";
|
||||
import { commands, extensions } from "vscode";
|
||||
import { CancellationToken, extensions } from "vscode";
|
||||
import { DatabaseManager } from "../../src/local-databases";
|
||||
import { CodeQLCliServer } from "../../src/cli";
|
||||
import { removeWorkspaceRefs } from "../../src/variant-analysis/run-remote-query";
|
||||
import { CodeQLExtensionInterface } from "../../src/extension";
|
||||
import { ProgressCallback } from "../../src/progress";
|
||||
|
||||
// This file contains helpers shared between tests that work with an activated extension.
|
||||
|
||||
@@ -37,9 +38,10 @@ export async function getActivatedExtension(): Promise<CodeQLExtensionInterface>
|
||||
}
|
||||
|
||||
export async function cleanDatabases(databaseManager: DatabaseManager) {
|
||||
for (const item of databaseManager.databaseItems) {
|
||||
await commands.executeCommand("codeQLDatabases.removeDatabase", item);
|
||||
}
|
||||
await databaseManager.removeAllDatabases(
|
||||
{} as ProgressCallback,
|
||||
{} as CancellationToken,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -619,7 +619,7 @@ describe("prepareCodeTour", () => {
|
||||
expect(executeCommand).toHaveBeenCalledWith(
|
||||
"vscode.openFolder",
|
||||
expect.objectContaining({
|
||||
path: Uri.parse(tutorialWorkspacePath).fsPath,
|
||||
path: expect.stringMatching(/tutorial.code-workspace$/),
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user