From 71898ac4ce495ea4ae55f21c86447c34f692bffb Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Wed, 19 Feb 2020 08:45:10 -0500 Subject: [PATCH 01/11] Add command for restarting the query server. Include a convenience button to show the query server log in case the reason the user wants to restart the server is that it's acting unexpectedly and they want to investigate why. --- extensions/ql-vscode/CHANGELOG.md | 4 ++++ extensions/ql-vscode/package.json | 4 ++++ extensions/ql-vscode/src/extension.ts | 7 ++++++ extensions/ql-vscode/src/logging.ts | 9 ++++++++ .../ql-vscode/src/queryserver-client.ts | 12 +++++++--- .../ql-vscode/test/pure-tests/query-test.ts | 23 ++++++++++--------- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index d633c8600..cdac3a12d 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -1,5 +1,9 @@ # CodeQL for Visual Studio Code: Changelog +## 1.0.6 + +- Add command to restart query server. + ## 1.0.5 - 13 February 2020 - Add an icon next to any failed query runs in the query history diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 07b8faa72..612542ae2 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -206,6 +206,10 @@ { "command": "codeQLQueryHistory.setLabel", "title": "Set Label" + }, + { + "command": "codeQL.restartQueryServer", + "title": "CodeQL: Restart Query Server" } ], "menus": { diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index f4e4370c3..8387cff2d 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -308,6 +308,13 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu ctx.subscriptions.push(commands.registerCommand('codeQL.runQuery', async (uri: Uri | undefined) => await compileAndRunQuery(false, uri))); ctx.subscriptions.push(commands.registerCommand('codeQL.quickEval', async (uri: Uri | undefined) => await compileAndRunQuery(true, uri))); ctx.subscriptions.push(commands.registerCommand('codeQL.quickQuery', async () => displayQuickQuery(ctx, cliServer, databaseUI))); + ctx.subscriptions.push(commands.registerCommand('codeQL.restartQueryServer', async () => { + await qs.restartQueryServer(); + const response = await Window.showInformationMessage('CodeQL Query Server restarted', 'Ok', 'Show Log'); + if (response === 'Show Log') { + qs.showLog(); + } + })); ctx.subscriptions.push(client.start()); } diff --git a/extensions/ql-vscode/src/logging.ts b/extensions/ql-vscode/src/logging.ts index 142a501f9..73a12bb0c 100644 --- a/extensions/ql-vscode/src/logging.ts +++ b/extensions/ql-vscode/src/logging.ts @@ -6,6 +6,12 @@ export interface Logger { log(message: string): void; /** Writes the given log message, not followed by a newline. */ logWithoutTrailingNewline(message: string): void; + /** + * Reveal this channel in the UI. + * + * @param preserveFocus When `true` the channel will not take focus. + */ + show(preserveFocus?: boolean): void; } export type ProgressReporter = Progress<{ message: string }>; @@ -28,6 +34,9 @@ export class OutputChannelLogger extends DisposableObject implements Logger { this.outputChannel.append(message); } + show(preserveFocus?: boolean) { + this.outputChannel.show(preserveFocus); + } } /** The global logger for the extension. */ diff --git a/extensions/ql-vscode/src/queryserver-client.ts b/extensions/ql-vscode/src/queryserver-client.ts index 0ea420fa4..03dd4e281 100644 --- a/extensions/ql-vscode/src/queryserver-client.ts +++ b/extensions/ql-vscode/src/queryserver-client.ts @@ -56,7 +56,10 @@ export class QueryServerClient extends DisposableObject { super(); // When the query server configuration changes, restart the query server. if (config.onDidChangeQueryServerConfiguration !== undefined) { - this.push(config.onDidChangeQueryServerConfiguration(async () => await this.restartQueryServer(), this)); + this.push(config.onDidChangeQueryServerConfiguration(async () => { + this.logger.log('Restarting query server due to configuration changes...'); + await this.restartQueryServer(); + }, this)); } this.withProgressReporting = withProgressReporting; this.nextCallback = 0; @@ -77,12 +80,15 @@ export class QueryServerClient extends DisposableObject { } /** Restarts the query server by disposing of the current server process and then starting a new one. */ - private async restartQueryServer() { - this.logger.log('Restarting query server due to configuration changes...'); + async restartQueryServer() { this.stopQueryServer(); await this.startQueryServer(); } + async showLog() { + this.logger.show(); + } + /** Starts a new query server process, sending progress messages to the status bar. */ async startQueryServer() { // Use an arrow function to preserve the value of `this`. diff --git a/extensions/ql-vscode/test/pure-tests/query-test.ts b/extensions/ql-vscode/test/pure-tests/query-test.ts index 0b0b32a1d..af6ba4247 100644 --- a/extensions/ql-vscode/test/pure-tests/query-test.ts +++ b/extensions/ql-vscode/test/pure-tests/query-test.ts @@ -10,7 +10,7 @@ import { CancellationTokenSource } from 'vscode-jsonrpc'; import * as messages from '../../src/messages'; import * as qsClient from '../../src/queryserver-client'; import * as cli from '../../src/cli'; -import { ProgressReporter } from '../../src/logging'; +import { ProgressReporter, Logger } from '../../src/logging'; declare module "url" { @@ -75,8 +75,8 @@ const queryTestCases: QueryTestCase[] = [ } ]; -describe('using the query server', function () { - before(function () { +describe('using the query server', function() { + before(function() { if (process.env["CODEQL_PATH"] === undefined) { console.log('The environment variable CODEQL_PATH is not set. The query server tests, which require the CodeQL CLI, will be skipped.'); this.skip(); @@ -100,13 +100,14 @@ describe('using the query server', function () { } }); - it('should be able to start the query server', async function () { + it('should be able to start the query server', async function() { const consoleProgressReporter: ProgressReporter = { - report: (v: {message: string}) => console.log(`progress reporter says ${v.message}`) + report: (v: { message: string }) => console.log(`progress reporter says ${v.message}`) }; - const logger = { + const logger: Logger = { log: (s: string) => console.log('logger says', s), - logWithoutTrailingNewline: (s: string) => console.log('logger says', s) + logWithoutTrailingNewline: (s: string) => console.log('logger says', s), + show: () => { }, }; cliServer = new cli.CodeQLCliServer({ async getCodeQlPathWithoutVersionCheck(): Promise { @@ -137,7 +138,7 @@ describe('using the query server', function () { const evaluationSucceeded = new Checkpoint(); const parsedResults = new Checkpoint(); - it(`should be able to compile query ${queryName}`, async function () { + it(`should be able to compile query ${queryName}`, async function() { await queryServerStarted.done(); expect(fs.existsSync(queryTestCase.queryPath)).to.be.true; try { @@ -169,7 +170,7 @@ describe('using the query server', function () { } }); - it(`should be able to run query ${queryName}`, async function () { + it(`should be able to run query ${queryName}`, async function() { try { await compilationSucceeded.done(); const callbackId = qs.registerCallback(_res => { @@ -201,7 +202,7 @@ describe('using the query server', function () { }); const actualResultSets: ResultSets = {}; - it(`should be able to parse results of query ${queryName}`, async function () { + it(`should be able to parse results of query ${queryName}`, async function() { let fileReader: FileReader | undefined; try { await evaluationSucceeded.done(); @@ -222,7 +223,7 @@ describe('using the query server', function () { } }); - it(`should have correct results for query ${queryName}`, async function () { + it(`should have correct results for query ${queryName}`, async function() { await parsedResults.done(); expect(actualResultSets!).not.to.be.empty; expect(Object.keys(actualResultSets!).sort()).to.eql(Object.keys(queryTestCase.expectedResultSets).sort()); From 88033c12f1d228c392b282c37e5d5dfe32a89038 Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Thu, 20 Feb 2020 11:43:02 -0500 Subject: [PATCH 02/11] Use actions/checkout@v2 --- .github/workflows/main.yml | 4 ++-- .github/workflows/release.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d40d86775..088c5077d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 with: fetch-depth: 1 @@ -46,7 +46,7 @@ jobs: os: [ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 with: fetch-depth: 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9f6c7230..523d6cd6b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: # TODO Share steps with the main workflow. steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: From 7429af3e273de66b9ceec1c12a5142b403c3dae3 Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Fri, 21 Feb 2020 08:30:43 -0500 Subject: [PATCH 03/11] Fix create pull request step - Bump create-pull-request version - Actually checkout master branch --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 523d6cd6b..73d5a84d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,6 +38,7 @@ jobs: - name: Fetch master branch run: | git fetch --depth=1 origin master:master + git checkout master - name: Build run: | @@ -110,7 +111,7 @@ jobs: echo "::set-output name=next_version::$NEXT_VERSION" - name: Create version bump PR - uses: peter-evans/create-pull-request@c202684c928d4c9f18394b2ad11df905c5d8b40c # v2.1.2 + uses: peter-evans/create-pull-request@c7b64af0a489eae91f7890f2c1b63d13cc2d8ab7 # v2.4.2 if: success() with: token: ${{ secrets.GITHUB_TOKEN }} From ef0623c60598e4333939da4e0d8718d98a72c64f Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Mon, 24 Feb 2020 09:07:43 -0500 Subject: [PATCH 04/11] Switch to master branch just before version bump PR creation --- .github/workflows/release.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73d5a84d6..76d7de7a0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,13 +33,6 @@ jobs: with: node-version: '10.18.1' - # The checkout action does not fetch the master branch. - # Fetch the master branch so that we can base the version bump PR against master. - - name: Fetch master branch - run: | - git fetch --depth=1 origin master:master - git checkout master - - name: Build run: | cd build @@ -100,6 +93,13 @@ jobs: asset_name: ${{ format('vscode-codeql-{0}.vsix', steps.prepare-artifacts.outputs.ref_name) }} asset_content_type: application/zip + # The checkout action does not fetch the master branch. + # Fetch the master branch so that we can base the version bump PR against master. + - name: Fetch master branch + run: | + git fetch --depth=1 origin master:master + git checkout master + - name: Bump patch version id: bump-patch-version if: success() From 54039823d328cd09e09a8a5ca7df44e459b90ab4 Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Tue, 25 Feb 2020 09:11:50 -0500 Subject: [PATCH 05/11] Add restartQueryServer to activation events --- extensions/ql-vscode/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 612542ae2..ac1e34f13 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -28,6 +28,7 @@ "onCommand:codeQLDatabases.chooseDatabase", "onCommand:codeQLDatabases.setCurrentDatabase", "onCommand:codeQL.quickQuery", + "onCommand:codeQL.restartQueryServer", "onWebviewPanel:resultsView", "onFileSystem:codeql-zip-archive" ], From 9c129f53ea59bd7dd28bf9f48010858da68a325e Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Tue, 25 Feb 2020 09:26:08 -0500 Subject: [PATCH 06/11] Remove unnecessary dismiss button --- extensions/ql-vscode/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index 8387cff2d..d0ff0771f 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -310,7 +310,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu ctx.subscriptions.push(commands.registerCommand('codeQL.quickQuery', async () => displayQuickQuery(ctx, cliServer, databaseUI))); ctx.subscriptions.push(commands.registerCommand('codeQL.restartQueryServer', async () => { await qs.restartQueryServer(); - const response = await Window.showInformationMessage('CodeQL Query Server restarted', 'Ok', 'Show Log'); + const response = await Window.showInformationMessage('CodeQL Query Server restarted', 'Show Log'); if (response === 'Show Log') { qs.showLog(); } From 895398fe4044bcc6725726d60d278ab9dba07985 Mon Sep 17 00:00:00 2001 From: jcreedcmu Date: Tue, 25 Feb 2020 12:05:28 -0500 Subject: [PATCH 07/11] Update extensions/ql-vscode/src/extension.ts Co-Authored-By: Henry Mercer --- extensions/ql-vscode/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/src/extension.ts b/extensions/ql-vscode/src/extension.ts index d0ff0771f..a3c17c408 100644 --- a/extensions/ql-vscode/src/extension.ts +++ b/extensions/ql-vscode/src/extension.ts @@ -310,7 +310,7 @@ async function activateWithInstalledDistribution(ctx: ExtensionContext, distribu ctx.subscriptions.push(commands.registerCommand('codeQL.quickQuery', async () => displayQuickQuery(ctx, cliServer, databaseUI))); ctx.subscriptions.push(commands.registerCommand('codeQL.restartQueryServer', async () => { await qs.restartQueryServer(); - const response = await Window.showInformationMessage('CodeQL Query Server restarted', 'Show Log'); + const response = await Window.showInformationMessage('CodeQL Query Server restarted.', 'Show Log'); if (response === 'Show Log') { qs.showLog(); } From 585b694f5237d836afe3757c0f8b6cdece88f620 Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Thu, 27 Feb 2020 11:27:32 -0500 Subject: [PATCH 08/11] Relax version constraint to allow minor version increases --- extensions/ql-vscode/src/distribution.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/ql-vscode/src/distribution.ts b/extensions/ql-vscode/src/distribution.ts index 83bcbb508..c7482525e 100644 --- a/extensions/ql-vscode/src/distribution.ts +++ b/extensions/ql-vscode/src/distribution.ts @@ -39,9 +39,9 @@ const DEFAULT_DISTRIBUTION_REPOSITORY_NAME = "codeql-cli-binaries"; * This applies to both extension-managed and CLI distributions. */ export const DEFAULT_DISTRIBUTION_VERSION_CONSTRAINT: VersionConstraint = { - description: "2.0.*", + description: "2.*.*", isVersionCompatible: (v: Version) => { - return v.majorVersion === 2 && v.minorVersion === 0 + return v.majorVersion === 2 && v.minorVersion >= 0 } } From 233907a19fceb7305379b724fad1821c41b931ca Mon Sep 17 00:00:00 2001 From: Jason Reed Date: Fri, 28 Feb 2020 11:57:57 -0500 Subject: [PATCH 09/11] Update CHANGELOG --- extensions/ql-vscode/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index cdac3a12d..1f3c5fde1 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -1,8 +1,9 @@ # CodeQL for Visual Studio Code: Changelog -## 1.0.6 +## 1.0.6 - 28 February 2020 - Add command to restart query server. +- Improve cli upgrade versioning. ## 1.0.5 - 13 February 2020 From 7ba8aa81812c92ff6146bbd2dc22d53af7946714 Mon Sep 17 00:00:00 2001 From: jcreedcmu Date: Fri, 28 Feb 2020 12:14:08 -0500 Subject: [PATCH 10/11] Update extensions/ql-vscode/CHANGELOG.md Co-Authored-By: Henry Mercer --- extensions/ql-vscode/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 1f3c5fde1..3d0584ce1 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.0.6 - 28 February 2020 - Add command to restart query server. -- Improve cli upgrade versioning. +- Enables support for future minor upgrades to the CodeQL CLI. ## 1.0.5 - 13 February 2020 From bfb7d99c205340336a593de83f5f5001b1de08f0 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Fri, 28 Feb 2020 17:15:11 +0000 Subject: [PATCH 11/11] Update extensions/ql-vscode/CHANGELOG.md --- extensions/ql-vscode/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index 3d0584ce1..7df629fd5 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -3,7 +3,7 @@ ## 1.0.6 - 28 February 2020 - Add command to restart query server. -- Enables support for future minor upgrades to the CodeQL CLI. +- Enable support for future minor upgrades to the CodeQL CLI. ## 1.0.5 - 13 February 2020