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.
|
* 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 languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||||
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
const augmentationProperties = calculateAugmentation(packsInput, queriesInput, languages);
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
|
buildMode: buildModeInput,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeql.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
|
|
@ -245,7 +246,7 @@ async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logg
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* 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;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
// Treat the config file as relative to the workspace
|
// 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);
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
|
buildMode: buildModeInput,
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeql.getPath(),
|
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,
|
configFile: undefined,
|
||||||
dbLocation: undefined,
|
dbLocation: undefined,
|
||||||
configInput: undefined,
|
configInput: undefined,
|
||||||
|
buildModeInput: undefined,
|
||||||
trapCachingEnabled: false,
|
trapCachingEnabled: false,
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "",
|
debugArtifactName: "",
|
||||||
|
|
@ -265,6 +266,7 @@ function mockListLanguages(languages) {
|
||||||
// And the config we expect it to parse to
|
// And the config we expect it to parse to
|
||||||
const expectedConfig = {
|
const expectedConfig = {
|
||||||
languages: [languages_1.Language.javascript],
|
languages: [languages_1.Language.javascript],
|
||||||
|
buildMode: "none",
|
||||||
originalUserInput: {
|
originalUserInput: {
|
||||||
name: "my config",
|
name: "my config",
|
||||||
"disable-default-queries": true,
|
"disable-default-queries": true,
|
||||||
|
|
@ -287,6 +289,7 @@ function mockListLanguages(languages) {
|
||||||
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
const actualConfig = await configUtils.initConfig(createTestInitConfigInputs({
|
const actualConfig = await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
languagesInput,
|
languagesInput,
|
||||||
|
buildModeInput: "none",
|
||||||
configFile: configFilePath,
|
configFile: configFilePath,
|
||||||
debugArtifactName: "my-artifact",
|
debugArtifactName: "my-artifact",
|
||||||
debugDatabaseName: "my-db",
|
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"),
|
languagesInput: (0, actions_util_1.getOptionalInput)("languages"),
|
||||||
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
|
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
|
||||||
packsInput: (0, actions_util_1.getOptionalInput)("packs"),
|
packsInput: (0, actions_util_1.getOptionalInput)("packs"),
|
||||||
|
buildModeInput: (0, actions_util_1.getOptionalInput)("build-mode"),
|
||||||
configFile: (0, actions_util_1.getOptionalInput)("config-file"),
|
configFile: (0, actions_util_1.getOptionalInput)("config-file"),
|
||||||
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
||||||
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
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) {
|
function createTestConfig(overrides) {
|
||||||
return Object.assign({}, {
|
return Object.assign({}, {
|
||||||
languages: [],
|
languages: [],
|
||||||
|
buildMode: undefined,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: "",
|
tempDir: "",
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -45,6 +45,7 @@ function createTestInitConfigInputs(
|
||||||
configFile: undefined,
|
configFile: undefined,
|
||||||
dbLocation: undefined,
|
dbLocation: undefined,
|
||||||
configInput: undefined,
|
configInput: undefined,
|
||||||
|
buildModeInput: undefined,
|
||||||
trapCachingEnabled: false,
|
trapCachingEnabled: false,
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "",
|
debugArtifactName: "",
|
||||||
|
|
@ -322,6 +323,7 @@ test("load non-empty input", async (t) => {
|
||||||
// And the config we expect it to parse to
|
// And the config we expect it to parse to
|
||||||
const expectedConfig: configUtils.Config = {
|
const expectedConfig: configUtils.Config = {
|
||||||
languages: [Language.javascript],
|
languages: [Language.javascript],
|
||||||
|
buildMode: "none",
|
||||||
originalUserInput: {
|
originalUserInput: {
|
||||||
name: "my config",
|
name: "my config",
|
||||||
"disable-default-queries": true,
|
"disable-default-queries": true,
|
||||||
|
|
@ -347,6 +349,7 @@ test("load non-empty input", async (t) => {
|
||||||
const actualConfig = await configUtils.initConfig(
|
const actualConfig = await configUtils.initConfig(
|
||||||
createTestInitConfigInputs({
|
createTestInitConfigInputs({
|
||||||
languagesInput,
|
languagesInput,
|
||||||
|
buildModeInput: "none",
|
||||||
configFile: configFilePath,
|
configFile: configFilePath,
|
||||||
debugArtifactName: "my-artifact",
|
debugArtifactName: "my-artifact",
|
||||||
debugDatabaseName: "my-db",
|
debugDatabaseName: "my-db",
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,10 @@ export interface Config {
|
||||||
* Set of languages to run analysis for.
|
* Set of languages to run analysis for.
|
||||||
*/
|
*/
|
||||||
languages: Language[];
|
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.
|
* A unaltered copy of the original user input.
|
||||||
* Mainly intended to be used for status reporting.
|
* Mainly intended to be used for status reporting.
|
||||||
|
|
@ -399,6 +403,7 @@ export interface InitConfigInputs {
|
||||||
configFile: string | undefined;
|
configFile: string | undefined;
|
||||||
dbLocation: string | undefined;
|
dbLocation: string | undefined;
|
||||||
configInput: string | undefined;
|
configInput: string | undefined;
|
||||||
|
buildModeInput: string | undefined;
|
||||||
trapCachingEnabled: boolean;
|
trapCachingEnabled: boolean;
|
||||||
debugMode: boolean;
|
debugMode: boolean;
|
||||||
debugArtifactName: string;
|
debugArtifactName: string;
|
||||||
|
|
@ -428,6 +433,7 @@ export async function getDefaultConfig({
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
packsInput,
|
packsInput,
|
||||||
|
buildModeInput,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
debugMode,
|
debugMode,
|
||||||
|
|
@ -460,6 +466,7 @@ export async function getDefaultConfig({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
|
buildMode: buildModeInput,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeql.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
|
|
@ -500,6 +507,7 @@ async function loadConfig({
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
packsInput,
|
packsInput,
|
||||||
|
buildModeInput,
|
||||||
configFile,
|
configFile,
|
||||||
dbLocation,
|
dbLocation,
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
|
|
@ -546,6 +554,7 @@ async function loadConfig({
|
||||||
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
|
buildMode: buildModeInput,
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeql.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,7 @@ async function run() {
|
||||||
languagesInput: getOptionalInput("languages"),
|
languagesInput: getOptionalInput("languages"),
|
||||||
queriesInput: getOptionalInput("queries"),
|
queriesInput: getOptionalInput("queries"),
|
||||||
packsInput: getOptionalInput("packs"),
|
packsInput: getOptionalInput("packs"),
|
||||||
|
buildModeInput: getOptionalInput("build-mode"),
|
||||||
configFile: getOptionalInput("config-file"),
|
configFile: getOptionalInput("config-file"),
|
||||||
dbLocation: getOptionalInput("db-location"),
|
dbLocation: getOptionalInput("db-location"),
|
||||||
configInput: getOptionalInput("config"),
|
configInput: getOptionalInput("config"),
|
||||||
|
|
|
||||||
|
|
@ -304,6 +304,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
languages: [],
|
languages: [],
|
||||||
|
buildMode: undefined,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: "",
|
tempDir: "",
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue