Skip to content

Commit

Permalink
Merge pull request #3622 from github/nickrolfe/eval-log-progress
Browse files Browse the repository at this point in the history
Report progress for post-evaluation actions
  • Loading branch information
nickrolfe authored May 28, 2024
2 parents d7a82cc + b43b1d4 commit 83df05e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions extensions/ql-vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [UNRELEASED]

- Fix a bug when re-importing test databases that erroneously showed old source code. [#3616](https://github.com/github/vscode-codeql/pull/3616)
- Update the progress window with details on potentially long-running post-processing steps after running a query. [#3622](https://github.com/github/vscode-codeql/pull/3622)

## 1.13.0 - 1 May 2024

Expand Down
8 changes: 8 additions & 0 deletions extensions/ql-vscode/src/common/vscode/progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export interface ProgressUpdate {
message: string;
}

export function progressUpdate(
step: number,
maxStep: number,
message: string,
): ProgressUpdate {
return { step, maxStep, message };
}

export type ProgressCallback = (p: ProgressUpdate) => void;

// Make certain properties within a type optional
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/debugger/debugger-ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class QLDebugAdapterTracker
): Promise<void> {
if (this.localQueryRun !== undefined) {
const results: CoreQueryResults = body;
await this.localQueryRun.complete(results);
await this.localQueryRun.complete(results, (_) => {});
this.localQueryRun = undefined;
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/ql-vscode/src/local-queries/local-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export class LocalQueries extends DisposableObject {
localQueryRun.logger,
);

await localQueryRun.complete(results);
await localQueryRun.complete(results, progress);

return results;
} catch (e) {
Expand Down
15 changes: 14 additions & 1 deletion extensions/ql-vscode/src/local-queries/local-query-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import type { LocalQueries } from "./local-queries";
import { tryGetQueryMetadata } from "../codeql-cli/query-metadata";
import { telemetryListener } from "../common/vscode/telemetry";
import type { Disposable } from "../common/disposable-object";
import type { ProgressCallback } from "../common/vscode/progress";
import { progressUpdate } from "../common/vscode/progress";

function formatResultMessage(result: CoreQueryResults): string {
switch (result.resultType) {
Expand Down Expand Up @@ -79,23 +81,31 @@ export class LocalQueryRun {
* This function must be called when the evaluation completes, whether the evaluation was
* successful or not.
* */
public async complete(results: CoreQueryResults): Promise<void> {
public async complete(
results: CoreQueryResults,
progress: ProgressCallback,
): Promise<void> {
const evalLogPaths = await this.summarizeEvalLog(
results.resultType,
this.outputDir,
this.logger,
progress,
);
if (evalLogPaths !== undefined) {
this.queryInfo.setEvaluatorLogPaths(evalLogPaths);
}
progress(progressUpdate(1, 4, "Getting completed query info"));
const queryWithResults = await this.getCompletedQueryInfo(results);
progress(progressUpdate(2, 4, "Updating query history"));
this.queryHistoryManager.completeQuery(this.queryInfo, queryWithResults);
progress(progressUpdate(3, 4, "Showing results"));
await this.localQueries.showResultsForCompletedQuery(
this.queryInfo as CompletedLocalQueryInfo,
WebviewReveal.Forced,
);
// Note we must update the query history view after showing results as the
// display and sorting might depend on the number of results
progress(progressUpdate(4, 4, "Updating query history"));
await this.queryHistoryManager.refreshTreeView();

this.logger.dispose();
Expand All @@ -109,6 +119,7 @@ export class LocalQueryRun {
QueryResultType.OTHER_ERROR,
this.outputDir,
this.logger,
(_) => {},
);
if (evalLogPaths !== undefined) {
this.queryInfo.setEvaluatorLogPaths(evalLogPaths);
Expand All @@ -128,10 +139,12 @@ export class LocalQueryRun {
resultType: QueryResultType,
outputDir: QueryOutputDir,
logger: BaseLogger,
progress: ProgressCallback,
): Promise<EvaluatorLogPaths | undefined> {
const evalLogPaths = await generateEvalLogSummaries(
this.cliServer,
outputDir,
progress,
);
if (evalLogPaths !== undefined) {
if (evalLogPaths.endSummary !== undefined) {
Expand Down
6 changes: 6 additions & 0 deletions extensions/ql-vscode/src/run-queries-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import { generateSummarySymbolsFile } from "./log-insights/summary-parser";
import { getErrorMessage } from "./common/helpers-pure";
import { createHash } from "crypto";
import { QueryOutputDir } from "./local-queries/query-output-dir";
import { progressUpdate } from "./common/vscode/progress";
import type { ProgressCallback } from "./common/vscode/progress";

/**
* run-queries.ts
Expand Down Expand Up @@ -519,6 +521,7 @@ export async function createInitialQueryInfo(
export async function generateEvalLogSummaries(
cliServer: CodeQLCliServer,
outputDir: QueryOutputDir,
progress: ProgressCallback,
): Promise<EvaluatorLogPaths | undefined> {
const log = outputDir.evalLogPath;
if (!(await pathExists(log))) {
Expand All @@ -527,6 +530,7 @@ export async function generateEvalLogSummaries(
}
let humanReadableSummary: string | undefined = undefined;
let endSummary: string | undefined = undefined;
progress(progressUpdate(1, 3, "Generating evaluator log summary"));
if (await generateHumanReadableLogSummary(cliServer, outputDir)) {
humanReadableSummary = outputDir.evalLogSummaryPath;
endSummary = outputDir.evalLogEndSummaryPath;
Expand All @@ -535,10 +539,12 @@ export async function generateEvalLogSummaries(
let summarySymbols: string | undefined = undefined;
if (isCanary()) {
// Generate JSON summary for viewer.
progress(progressUpdate(2, 3, "Generating JSON log summary"));
jsonSummary = outputDir.jsonEvalLogSummaryPath;
await cliServer.generateJsonLogSummary(log, jsonSummary);

if (humanReadableSummary !== undefined) {
progress(progressUpdate(3, 3, "Generating summary symbols file"));
summarySymbols = outputDir.evalLogSummarySymbolsPath;
await generateSummarySymbolsFile(humanReadableSummary, summarySymbols);
}
Expand Down

0 comments on commit 83df05e

Please sign in to comment.