Fix TRAP directory location

This commit is contained in:
Henry Mercer 2022-08-31 11:51:08 +01:00
parent 5b4b44c9d6
commit b42a495e8a
3 changed files with 37 additions and 16 deletions

20
lib/analyze-action.js generated
View file

@ -18,10 +18,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runPromise = exports.sendStatusReport = void 0;
// We need to import `performance` on Node 12
const fs = __importStar(require("fs"));
const path_1 = __importDefault(require("path"));
// We need to import `performance` on Node 12
const perf_hooks_1 = require("perf_hooks");
const core = __importStar(require("@actions/core"));
const actionsUtil = __importStar(require("./actions-util"));
@ -72,14 +76,22 @@ function hasBadExpectErrorInput() {
!util.isInTestMode());
}
/**
* 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) {
const golangDbDirectory = util.getCodeQLDatabasePath(config, languages_1.Language.go);
const trapDirectory = path_1.default.join(golangDbDirectory, "trap", languages_1.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)));
}
async function run() {
const startedAt = new Date();

File diff suppressed because one or more lines are too long

View file

@ -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";
@ -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. */
@ -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 || {}),
@ -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))
);
}