Skip to content

Commit e5a48fb

Browse files
authored
Merge pull request #2068 from github/koesie10/remove-run-remote-query
Remove code to start a remote query run
2 parents f7826c3 + 096e8f6 commit e5a48fb

File tree

6 files changed

+9
-293
lines changed

6 files changed

+9
-293
lines changed

extensions/ql-vscode/src/extension.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import {
3838
CliConfigListener,
3939
DistributionConfigListener,
4040
isCanary,
41-
isVariantAnalysisLiveResultsEnabled,
4241
joinOrderWarningThreshold,
4342
MAX_QUERIES,
4443
QueryHistoryConfigListener,
@@ -1112,19 +1111,11 @@ async function activateWithInstalledDistribution(
11121111
message: "Getting credentials",
11131112
});
11141113

1115-
if (isVariantAnalysisLiveResultsEnabled()) {
1116-
await variantAnalysisManager.runVariantAnalysis(
1117-
uri || window.activeTextEditor?.document.uri,
1118-
progress,
1119-
token,
1120-
);
1121-
} else {
1122-
await rqm.runRemoteQuery(
1123-
uri || window.activeTextEditor?.document.uri,
1124-
progress,
1125-
token,
1126-
);
1127-
}
1114+
await variantAnalysisManager.runVariantAnalysis(
1115+
uri || window.activeTextEditor?.document.uri,
1116+
progress,
1117+
token,
1118+
);
11281119
} else {
11291120
throw new Error(
11301121
"Variant analysis requires the CodeQL Canary version to run.",

extensions/ql-vscode/src/remote-queries/remote-queries-api.ts

Lines changed: 0 additions & 154 deletions
This file was deleted.

extensions/ql-vscode/src/remote-queries/remote-queries-manager.ts

Lines changed: 4 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,24 @@
11
import {
22
CancellationToken,
33
commands,
4+
env,
45
EventEmitter,
56
ExtensionContext,
6-
Uri,
7-
env,
87
} from "vscode";
9-
import { nanoid } from "nanoid";
108
import { join } from "path";
11-
import { writeFile, readFile, remove, pathExists } from "fs-extra";
9+
import { pathExists, readFile, remove, writeFile } from "fs-extra";
1210
import { EOL } from "os";
1311

1412
import { CodeQLCliServer } from "../cli";
15-
import { ProgressCallback } from "../commandRunner";
1613
import {
17-
createTimestampFile,
1814
showAndLogErrorMessage,
1915
showAndLogExceptionWithTelemetry,
2016
showAndLogInformationMessage,
2117
showInformationMessageWithAction,
2218
} from "../helpers";
2319
import { Logger } from "../common";
24-
import { prepareRemoteQueryRun } from "./run-remote-query";
2520
import { RemoteQueriesView } from "./remote-queries-view";
26-
import { buildRemoteQueryEntity, RemoteQuery } from "./remote-query";
21+
import { RemoteQuery } from "./remote-query";
2722
import { RemoteQueriesMonitor } from "./remote-queries-monitor";
2823
import {
2924
getRemoteQueryIndex,
@@ -41,7 +36,6 @@ import { asError, assertNever, getErrorMessage } from "../pure/helpers-pure";
4136
import { QueryStatus } from "../query-status";
4237
import { DisposableObject } from "../pure/disposable-object";
4338
import { AnalysisResults } from "./shared/analysis-result";
44-
import { runRemoteQueriesApiRequest } from "./remote-queries-api";
4539
import { App } from "../common/app";
4640
import { redactableError } from "../pure/errors";
4741

@@ -85,7 +79,7 @@ export class RemoteQueriesManager extends DisposableObject {
8579
constructor(
8680
ctx: ExtensionContext,
8781
private readonly app: App,
88-
private readonly cliServer: CodeQLCliServer,
82+
cliServer: CodeQLCliServer,
8983
private readonly storagePath: string,
9084
logger: Logger,
9185
) {
@@ -167,62 +161,6 @@ export class RemoteQueriesManager extends DisposableObject {
167161
}
168162
}
169163

170-
public async runRemoteQuery(
171-
uri: Uri | undefined,
172-
progress: ProgressCallback,
173-
token: CancellationToken,
174-
): Promise<void> {
175-
const {
176-
actionBranch,
177-
base64Pack,
178-
repoSelection,
179-
queryFile,
180-
queryMetadata,
181-
controllerRepo,
182-
queryStartTime,
183-
language,
184-
} = await prepareRemoteQueryRun(
185-
this.cliServer,
186-
this.app.credentials,
187-
uri,
188-
progress,
189-
token,
190-
);
191-
192-
const apiResponse = await runRemoteQueriesApiRequest(
193-
this.app.credentials,
194-
actionBranch,
195-
language,
196-
repoSelection,
197-
controllerRepo,
198-
base64Pack,
199-
);
200-
201-
if (!apiResponse) {
202-
return;
203-
}
204-
205-
const workflowRunId = apiResponse.workflow_run_id;
206-
const repositoryCount = apiResponse.repositories_queried.length;
207-
const query = await buildRemoteQueryEntity(
208-
queryFile,
209-
queryMetadata,
210-
controllerRepo,
211-
queryStartTime,
212-
workflowRunId,
213-
language,
214-
repositoryCount,
215-
);
216-
217-
const queryId = this.createQueryId();
218-
219-
await this.prepareStorageDirectory(queryId);
220-
await this.storeJsonFile(queryId, "query.json", query);
221-
222-
this.remoteQueryAddedEventEmitter.fire({ queryId, query });
223-
void commands.executeCommand("codeQL.monitorRemoteQuery", queryId, query);
224-
}
225-
226164
public async monitorRemoteQuery(
227165
queryId: string,
228166
remoteQuery: RemoteQuery,
@@ -389,25 +327,6 @@ export class RemoteQueriesManager extends DisposableObject {
389327
}
390328
}
391329

392-
/**
393-
* Generates a unique id for this query, suitable for determining the storage location for the downloaded query artifacts.
394-
* @returns A unique id for this query.
395-
*/
396-
private createQueryId(): string {
397-
return nanoid();
398-
}
399-
400-
/**
401-
* Prepares a directory for storing analysis results for a single query run.
402-
* This directory contains a timestamp file, which will be
403-
* used by the query history manager to determine when the directory
404-
* should be deleted.
405-
*
406-
*/
407-
private async prepareStorageDirectory(queryId: string): Promise<void> {
408-
await createTimestampFile(join(this.storagePath, queryId));
409-
}
410-
411330
private async getRemoteQueryResult(
412331
queryId: string,
413332
): Promise<RemoteQueryResult> {
Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import { readFile } from "fs-extra";
21
import { Repository as RemoteRepository } from "./repository";
3-
import { QueryMetadata } from "../pure/interface-types";
4-
import { getQueryName } from "./run-remote-query";
5-
import { Repository } from "./shared/repository";
62

73
export interface RemoteQuery {
84
queryName: string;
@@ -14,31 +10,3 @@ export interface RemoteQuery {
1410
actionsWorkflowRunId: number;
1511
repositoryCount: number;
1612
}
17-
18-
export async function buildRemoteQueryEntity(
19-
queryFilePath: string,
20-
queryMetadata: QueryMetadata | undefined,
21-
controllerRepo: Repository,
22-
queryStartTime: number,
23-
workflowRunId: number,
24-
language: string,
25-
repositoryCount: number,
26-
): Promise<RemoteQuery> {
27-
const queryName = getQueryName(queryMetadata, queryFilePath);
28-
const queryText = await readFile(queryFilePath, "utf8");
29-
const [owner, name] = controllerRepo.fullName.split("/");
30-
31-
return {
32-
queryName,
33-
queryFilePath,
34-
queryText,
35-
language,
36-
controllerRepository: {
37-
owner,
38-
name,
39-
},
40-
executionStartTime: queryStartTime,
41-
actionsWorkflowRunId: workflowRunId,
42-
repositoryCount,
43-
};
44-
}

extensions/ql-vscode/test/vscode-tests/cli-integration/remote-queries/variant-analysis-manager.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ describe("Variant Analysis Manager", () => {
7878

7979
beforeEach(async () => {
8080
jest.spyOn(extLogger, "log").mockResolvedValue(undefined);
81-
jest
82-
.spyOn(config, "isVariantAnalysisLiveResultsEnabled")
83-
.mockReturnValue(false);
8481

8582
cancellationTokenSource = new CancellationTokenSource();
8683

extensions/ql-vscode/test/vscode-tests/cli-integration/remote-queries/variant-analysis-monitor.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CancellationTokenSource, commands, extensions } from "vscode";
22
import { CodeQLExtensionInterface } from "../../../../src/extension";
3-
import * as config from "../../../../src/config";
43

54
import * as ghApiClient from "../../../../src/remote-queries/gh-api/gh-api-client";
65
import { VariantAnalysisMonitor } from "../../../../src/remote-queries/variant-analysis-monitor";
@@ -46,10 +45,6 @@ describe("Variant Analysis Monitor", () => {
4645
const onVariantAnalysisChangeSpy = jest.fn();
4746

4847
beforeEach(async () => {
49-
jest
50-
.spyOn(config, "isVariantAnalysisLiveResultsEnabled")
51-
.mockReturnValue(false);
52-
5348
cancellationTokenSource = new CancellationTokenSource();
5449

5550
variantAnalysis = createMockVariantAnalysis({});

0 commit comments

Comments
 (0)