Skip to content

Commit

Permalink
Fix TRAP directory location
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed Aug 31, 2022
1 parent 5b4b44c commit b42a495
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 16 deletions.
20 changes: 16 additions & 4 deletions lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// We need to import `performance` on Node 12
import * as fs from "fs";
import path from "path";
// We need to import `performance` on Node 12
import { performance } from "perf_hooks";

import * as core from "@actions/core";
Expand Down Expand Up @@ -32,12 +33,12 @@ const pkg = require("../package.json");

interface AnalysisStatusReport
extends upload_lib.UploadStatusReport,
QueriesStatusReport { }
QueriesStatusReport {}

interface FinishStatusReport
extends actionsUtil.StatusReportBase,
actionsUtil.DatabaseCreationTimings,
AnalysisStatusReport { }
actionsUtil.DatabaseCreationTimings,
AnalysisStatusReport {}

interface FinishWithTrapUploadStatusReport extends FinishStatusReport {
/** Size of TRAP caches that we uploaded, in bytes. */
Expand Down Expand Up @@ -71,9 +72,9 @@ export async function sendStatusReport(
...statusReportBase,
...(config
? {
ml_powered_javascript_queries:
util.getMlPoweredJsQueriesStatus(config),
}
ml_powered_javascript_queries:
util.getMlPoweredJsQueriesStatus(config),
}
: {}),
...(stats || {}),
...(dbCreationTimings || {}),
Expand Down Expand Up @@ -101,15 +102,23 @@ function hasBadExpectErrorInput(): boolean {
}

/**
* Returns whether any `.trap[.gz]` files exist under the `db-go` folder,
* Returns whether any TRAP files exist under the `db-go` folder,
* indicating whether Go extraction has extracted at least one file.
*/
function doesGoExtractionOutputExist(config: Config): boolean {
const golangDbDirectory = util.getCodeQLDatabasePath(config, Language.go);
const trapDirectory = path.join(golangDbDirectory, "trap", Language.go);
return fs
.readdirSync(golangDbDirectory)
.some(
(fileName) => fileName.endsWith(".trap") || fileName.endsWith(".trap.gz")
.readdirSync(trapDirectory)
.some((fileName) =>
[
".trap",
".trap.gz",
".trap.br",
".trap.tar.gz",
".trap.tar.br",
".trap.tar",
].some((ext) => fileName.endsWith(ext))
);
}

Expand Down

0 comments on commit b42a495

Please sign in to comment.