-
Notifications
You must be signed in to change notification settings - Fork 453
Expand file tree
/
Copy pathautobuild.ts
More file actions
46 lines (40 loc) · 1.47 KB
/
autobuild.ts
File metadata and controls
46 lines (40 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { getCodeQL } from "./codeql";
import * as config_utils from "./config-utils";
import { Language, isTracedLanguage } from "./languages";
import { Logger } from "./logging";
export function determineAutobuildLanguage(
config: config_utils.Config,
logger: Logger
): Language | undefined {
// Attempt to find a language to autobuild
// We want pick the dominant language in the repo from the ones we're able to build
// The languages are sorted in order specified by user or by lines of code if we got
// them from the GitHub API, so try to build the first language on the list.
const autobuildLanguages = config.languages.filter(isTracedLanguage);
const language = autobuildLanguages[0];
if (!language) {
logger.info(
"None of the languages in this project require extra build steps"
);
return undefined;
}
logger.debug(`Detected dominant traced language: ${language}`);
if (autobuildLanguages.length > 1) {
logger.warning(
`We will only automatically build ${language} code. If you wish to scan ${autobuildLanguages
.slice(1)
.join(" and ")}, you must replace this call with custom build steps.`
);
}
return language;
}
export async function runAutobuild(
language: Language,
config: config_utils.Config,
logger: Logger
) {
logger.startGroup(`Attempting to automatically build ${language} code`);
const codeQL = getCodeQL(config.codeQLCmd);
await codeQL.runAutobuild(language);
logger.endGroup();
}