Add build mode to configuration
This commit is contained in:
parent
401f9d6286
commit
0166a8a567
12 changed files with 27 additions and 6 deletions
6
lib/config-utils.js
generated
6
lib/config-utils.js
generated
|
|
@ -212,12 +212,13 @@ exports.getRawLanguages = getRawLanguages;
|
|||
/**
|
||||
* Get the default config for when the user has not supplied one.
|
||||
*/
|
||||
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, logger, }) {
|
||||
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, logger, }) {
|
||||
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||
return {
|
||||
languages,
|
||||
buildMode: buildModeInput,
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -245,7 +246,7 @@ async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logg
|
|||
/**
|
||||
* Load the config from the given file.
|
||||
*/
|
||||
async function loadConfig({ languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, logger, }) {
|
||||
async function loadConfig({ languagesInput, queriesInput, packsInput, buildModeInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, workspacePath, githubVersion, apiDetails, logger, }) {
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
// Treat the config file as relative to the workspace
|
||||
|
|
@ -260,6 +261,7 @@ async function loadConfig({ languagesInput, queriesInput, packsInput, configFile
|
|||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||
return {
|
||||
languages,
|
||||
buildMode: buildModeInput,
|
||||
originalUserInput: parsedYAML,
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
3
lib/config-utils.test.js
generated
3
lib/config-utils.test.js
generated
|
|
@ -50,6 +50,7 @@ function createTestInitConfigInputs(overrides) {
|
|||
configFile: undefined,
|
||||
dbLocation: undefined,
|
||||
configInput: undefined,
|
||||
buildModeInput: undefined,
|
||||
trapCachingEnabled: false,
|
||||
debugMode: false,
|
||||
debugArtifactName: "",
|
||||
|
|
@ -265,6 +266,7 @@ function mockListLanguages(languages) {
|
|||
// And the config we expect it to parse to
|
||||
const expectedConfig = {
|
||||
languages: [languages_1.Language.javascript],
|
||||
buildMode: "none",
|
||||
originalUserInput: {
|
||||
name: "my config",
|
||||
"disable-default-queries": true,
|
||||
|
|
@ -287,6 +289,7 @@ function mockListLanguages(languages) {
|
|||
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||
const actualConfig = await configUtils.initConfig(createTestInitConfigInputs({
|
||||
languagesInput,
|
||||
buildModeInput: "none",
|
||||
configFile: configFilePath,
|
||||
debugArtifactName: "my-artifact",
|
||||
debugDatabaseName: "my-db",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
lib/init-action.js
generated
1
lib/init-action.js
generated
|
|
@ -141,6 +141,7 @@ async function run() {
|
|||
languagesInput: (0, actions_util_1.getOptionalInput)("languages"),
|
||||
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
|
||||
packsInput: (0, actions_util_1.getOptionalInput)("packs"),
|
||||
buildModeInput: (0, actions_util_1.getOptionalInput)("build-mode"),
|
||||
configFile: (0, actions_util_1.getOptionalInput)("config-file"),
|
||||
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
||||
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
1
lib/testing-utils.js
generated
1
lib/testing-utils.js
generated
|
|
@ -244,6 +244,7 @@ exports.mockBundleDownloadApi = mockBundleDownloadApi;
|
|||
function createTestConfig(overrides) {
|
||||
return Object.assign({}, {
|
||||
languages: [],
|
||||
buildMode: undefined,
|
||||
originalUserInput: {},
|
||||
tempDir: "",
|
||||
codeQLCmd: "",
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -45,6 +45,7 @@ function createTestInitConfigInputs(
|
|||
configFile: undefined,
|
||||
dbLocation: undefined,
|
||||
configInput: undefined,
|
||||
buildModeInput: undefined,
|
||||
trapCachingEnabled: false,
|
||||
debugMode: false,
|
||||
debugArtifactName: "",
|
||||
|
|
@ -322,6 +323,7 @@ test("load non-empty input", async (t) => {
|
|||
// And the config we expect it to parse to
|
||||
const expectedConfig: configUtils.Config = {
|
||||
languages: [Language.javascript],
|
||||
buildMode: "none",
|
||||
originalUserInput: {
|
||||
name: "my config",
|
||||
"disable-default-queries": true,
|
||||
|
|
@ -347,6 +349,7 @@ test("load non-empty input", async (t) => {
|
|||
const actualConfig = await configUtils.initConfig(
|
||||
createTestInitConfigInputs({
|
||||
languagesInput,
|
||||
buildModeInput: "none",
|
||||
configFile: configFilePath,
|
||||
debugArtifactName: "my-artifact",
|
||||
debugDatabaseName: "my-db",
|
||||
|
|
|
|||
|
|
@ -80,6 +80,10 @@ export interface Config {
|
|||
* Set of languages to run analysis for.
|
||||
*/
|
||||
languages: Language[];
|
||||
/**
|
||||
* Build mode, if set. Currently only a single build mode is supported per job.
|
||||
*/
|
||||
buildMode: string | undefined;
|
||||
/**
|
||||
* A unaltered copy of the original user input.
|
||||
* Mainly intended to be used for status reporting.
|
||||
|
|
@ -399,6 +403,7 @@ export interface InitConfigInputs {
|
|||
configFile: string | undefined;
|
||||
dbLocation: string | undefined;
|
||||
configInput: string | undefined;
|
||||
buildModeInput: string | undefined;
|
||||
trapCachingEnabled: boolean;
|
||||
debugMode: boolean;
|
||||
debugArtifactName: string;
|
||||
|
|
@ -428,6 +433,7 @@ export async function getDefaultConfig({
|
|||
languagesInput,
|
||||
queriesInput,
|
||||
packsInput,
|
||||
buildModeInput,
|
||||
dbLocation,
|
||||
trapCachingEnabled,
|
||||
debugMode,
|
||||
|
|
@ -460,6 +466,7 @@ export async function getDefaultConfig({
|
|||
|
||||
return {
|
||||
languages,
|
||||
buildMode: buildModeInput,
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
@ -500,6 +507,7 @@ async function loadConfig({
|
|||
languagesInput,
|
||||
queriesInput,
|
||||
packsInput,
|
||||
buildModeInput,
|
||||
configFile,
|
||||
dbLocation,
|
||||
trapCachingEnabled,
|
||||
|
|
@ -546,6 +554,7 @@ async function loadConfig({
|
|||
|
||||
return {
|
||||
languages,
|
||||
buildMode: buildModeInput,
|
||||
originalUserInput: parsedYAML,
|
||||
tempDir,
|
||||
codeQLCmd: codeql.getPath(),
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ async function run() {
|
|||
languagesInput: getOptionalInput("languages"),
|
||||
queriesInput: getOptionalInput("queries"),
|
||||
packsInput: getOptionalInput("packs"),
|
||||
buildModeInput: getOptionalInput("build-mode"),
|
||||
configFile: getOptionalInput("config-file"),
|
||||
dbLocation: getOptionalInput("db-location"),
|
||||
configInput: getOptionalInput("config"),
|
||||
|
|
|
|||
|
|
@ -304,6 +304,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
|
|||
{},
|
||||
{
|
||||
languages: [],
|
||||
buildMode: undefined,
|
||||
originalUserInput: {},
|
||||
tempDir: "",
|
||||
codeQLCmd: "",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue