Autobuild Go in analyze step
This commit is contained in:
parent
d92a91c5c4
commit
215c3cb4bb
9 changed files with 67 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// We need to import `performance` on Node 12
|
||||
import * as fs from "fs";
|
||||
import { performance } from "perf_hooks";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
|
|
@ -13,10 +14,12 @@ import {
|
|||
runQueries,
|
||||
} from "./analyze";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { runAutobuild } from "./autobuild";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { uploadDatabases } from "./database-upload";
|
||||
import { GitHubFeatureFlags } from "./feature-flags";
|
||||
import { FeatureFlag, GitHubFeatureFlags } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import { getTotalCacheSize, uploadTrapCaches } from "./trap-caching";
|
||||
|
|
@ -97,6 +100,20 @@ function hasBadExpectErrorInput(): boolean {
|
|||
);
|
||||
}
|
||||
|
||||
// Check for any .trap[.gz] files under the db-go/ folder
|
||||
function didGolangExtraction(config: Config): boolean {
|
||||
const golangDbDirectory = util.getCodeQLDatabasePath(config, Language.go);
|
||||
const extractedFiles = fs
|
||||
.readdirSync(golangDbDirectory)
|
||||
.filter(
|
||||
(fileName) => fileName.endsWith(".trap") || fileName.endsWith(".trap.gz")
|
||||
);
|
||||
if (extractedFiles.length !== 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const startedAt = new Date();
|
||||
let uploadResult: UploadResult | undefined = undefined;
|
||||
|
|
@ -166,6 +183,21 @@ async function run() {
|
|||
logger
|
||||
);
|
||||
|
||||
if (
|
||||
await featureFlags.getValue(
|
||||
FeatureFlag.GolangExtractionReconciliationEnabled
|
||||
)
|
||||
) {
|
||||
// Run autobuilder for Go, unless it's already been run or user built manually
|
||||
if (
|
||||
Language.go in config.languages &&
|
||||
process.env["CODEQL_ACTION_DID_AUTOBUILD_GOLANG"] !== "true" &&
|
||||
!didGolangExtraction(config)
|
||||
) {
|
||||
await runAutobuild(Language.go, config, logger);
|
||||
}
|
||||
}
|
||||
|
||||
dbCreationTimings = await runFinalize(
|
||||
outputDir,
|
||||
threads,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ async function run() {
|
|||
process.chdir(workingDirectory);
|
||||
}
|
||||
await runAutobuild(language, config, logger);
|
||||
if (language === Language.go) {
|
||||
core.exportVariable("CODEQL_ACTION_DID_AUTOBUILD_GOLANG", "true");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
core.setFailed(
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ export enum FeatureFlag {
|
|||
LuaTracerConfigEnabled = "lua_tracer_config_enabled",
|
||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||
TrapCachingEnabled = "trap_caching_enabled",
|
||||
GolangExtractionReconciliationEnabled = "golang_extraction_reconciliation_enabled",
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue