Merge pull request #2107 from github/henrymercer/refactor-config
Refactoring: Simplify adding new configuration properties
This commit is contained in:
commit
e34513334c
30 changed files with 606 additions and 731 deletions
18
lib/analyze.test.js
generated
18
lib/analyze.test.js
generated
|
|
@ -95,25 +95,11 @@ const util = __importStar(require("./util"));
|
||||||
},
|
},
|
||||||
databasePrintBaseline: async () => "",
|
databasePrintBaseline: async () => "",
|
||||||
});
|
});
|
||||||
const config = {
|
const config = (0, testing_utils_1.createTestConfig)({
|
||||||
languages: [language],
|
languages: [language],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
},
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
debugMode: false,
|
});
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"analyze.test.js","sourceRoot":"","sources":["../src/analyze.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AACvB,6CAA+B;AAE/B,uCAAuC;AACvC,qCAAqC;AAErC,mDAA0C;AAC1C,2CAAuC;AACvC,uCAA4C;AAC5C,mDA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Ac,EAAC,CAAC,uBAAO,CAAC,kBAAkB,CAAC,CAAC,CAC7C,CAAC;YACF,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC5C,2BAA2B,QAAQ,cAAc;gBACjD,eAAe;gBACf,qBAAqB,QAAQ,cAAc;aAC5C,CAAC,CAAC;YACH,KAAK,MAAM,WAAW,IAAI,YAAY,CAAC,aAAc,EAAE,CAAC;gBACtD,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,mCAAmC,CAAC,CAAC;gBACpE,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,WAAW,CAAC,CAAC;gBACpC,CAAC,CAAC,IAAI,CAAC,aAAa,IAAI,WAAW,CAAC,UAAW,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
20
lib/codeql.test.js
generated
20
lib/codeql.test.js
generated
|
|
@ -49,25 +49,9 @@ const util_1 = require("./util");
|
||||||
let stubConfig;
|
let stubConfig;
|
||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
(0, util_1.initializeEnvironment)("1.2.3");
|
(0, util_1.initializeEnvironment)("1.2.3");
|
||||||
stubConfig = {
|
stubConfig = (0, testing_utils_1.createTestConfig)({
|
||||||
languages: [languages_1.Language.cpp],
|
languages: [languages_1.Language.cpp],
|
||||||
originalUserInput: {},
|
});
|
||||||
tempDir: "",
|
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
},
|
|
||||||
dbLocation: "",
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
async function installIntoToolcache({ apiDetails = testing_utils_1.SAMPLE_DOTCOM_API_DETAILS, cliVersion, isPinned, tagName, tmpDir, }) {
|
async function installIntoToolcache({ apiDetails = testing_utils_1.SAMPLE_DOTCOM_API_DETAILS, cliVersion, isPinned, tagName, tmpDir, }) {
|
||||||
const url = (0, testing_utils_1.mockBundleDownloadApi)({ apiDetails, isPinned, tagName });
|
const url = (0, testing_utils_1.mockBundleDownloadApi)({ apiDetails, isPinned, tagName });
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
44
lib/config-utils.js
generated
44
lib/config-utils.js
generated
|
|
@ -212,16 +212,16 @@ 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, rawQueriesInput, rawPacksInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, gitHubVersion, logger) {
|
async function getDefaultConfig({ languagesInput, queriesInput, packsInput, 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(rawPacksInput, rawQueriesInput, 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,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
|
|
@ -245,7 +245,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, rawQueriesInput, rawPacksInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig({ languagesInput, queriesInput, packsInput, 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
|
||||||
|
|
@ -255,15 +255,15 @@ async function loadConfig(languagesInput, rawQueriesInput, rawPacksInput, config
|
||||||
else {
|
else {
|
||||||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
||||||
}
|
}
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, logger);
|
const languages = await getLanguages(codeql, languagesInput, repository, logger);
|
||||||
const augmentationProperties = calculateAugmentation(rawPacksInput, rawQueriesInput, 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,
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
|
|
@ -452,24 +452,26 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, configInput, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(inputs) {
|
||||||
let config;
|
let config;
|
||||||
|
const { logger, workspacePath } = inputs;
|
||||||
// if configInput is set, it takes precedence over configFile
|
// if configInput is set, it takes precedence over configFile
|
||||||
if (configInput) {
|
if (inputs.configInput) {
|
||||||
if (configFile) {
|
if (inputs.configFile) {
|
||||||
logger.warning(`Both a config file and config input were provided. Ignoring config file.`);
|
logger.warning(`Both a config file and config input were provided. Ignoring config file.`);
|
||||||
}
|
}
|
||||||
configFile = path.resolve(workspacePath, "user-config-from-action.yml");
|
inputs.configFile = path.resolve(workspacePath, "user-config-from-action.yml");
|
||||||
fs.writeFileSync(configFile, configInput);
|
fs.writeFileSync(inputs.configFile, inputs.configInput);
|
||||||
logger.debug(`Using config from action input: ${configFile}`);
|
logger.debug(`Using config from action input: ${inputs.configFile}`);
|
||||||
}
|
}
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!inputs.configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, gitHubVersion, logger);
|
config = await getDefaultConfig(inputs);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
// Convince the type checker that inputs.configFile is defined.
|
||||||
|
config = await loadConfig({ ...inputs, configFile: inputs.configFile });
|
||||||
}
|
}
|
||||||
// Save the config so we can easily access it again in the future
|
// Save the config so we can easily access it again in the future
|
||||||
await saveConfig(config, logger);
|
await saveConfig(config, logger);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
217
lib/config-utils.test.js
generated
217
lib/config-utils.test.js
generated
|
|
@ -41,14 +41,34 @@ const repository_1 = require("./repository");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
const sampleApiDetails = {
|
const githubVersion = { type: util_1.GitHubVariant.DOTCOM };
|
||||||
auth: "token",
|
function createTestInitConfigInputs(overrides) {
|
||||||
externalRepoAuth: "token",
|
return Object.assign({}, {
|
||||||
url: "https://github.example.com",
|
languagesInput: undefined,
|
||||||
apiURL: undefined,
|
queriesInput: undefined,
|
||||||
registriesAuthTokens: undefined,
|
packsInput: undefined,
|
||||||
};
|
configFile: undefined,
|
||||||
const gitHubVersion = { type: util_1.GitHubVariant.DOTCOM };
|
dbLocation: undefined,
|
||||||
|
configInput: undefined,
|
||||||
|
trapCachingEnabled: false,
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: "",
|
||||||
|
debugDatabaseName: "",
|
||||||
|
repository: { owner: "github", repo: "example" },
|
||||||
|
tempDir: "",
|
||||||
|
codeql: {},
|
||||||
|
workspacePath: "",
|
||||||
|
githubVersion,
|
||||||
|
apiDetails: {
|
||||||
|
auth: "token",
|
||||||
|
externalRepoAuth: "token",
|
||||||
|
url: "https://github.example.com",
|
||||||
|
apiURL: undefined,
|
||||||
|
registriesAuthTokens: undefined,
|
||||||
|
},
|
||||||
|
logger: (0, logging_1.getRunnerLogger)(true),
|
||||||
|
}, overrides);
|
||||||
|
}
|
||||||
// Returns the filepath of the newly-created file
|
// Returns the filepath of the newly-created file
|
||||||
function createConfigFile(inputFileContents, tmpDir) {
|
function createConfigFile(inputFileContents, tmpDir) {
|
||||||
const configFilePath = path.join(tmpDir, "input");
|
const configFilePath = path.join(tmpDir, "input");
|
||||||
|
|
@ -83,10 +103,10 @@ function mockListLanguages(languages) {
|
||||||
sinon.stub(api, "getApiClient").value(() => client);
|
sinon.stub(api, "getApiClient").value(() => client);
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("load empty config", async (t) => {
|
(0, ava_1.default)("load empty config", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const logger = (0, logging_1.getRunnerLogger)(true);
|
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||||
const languages = "javascript,python";
|
const languages = "javascript,python";
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -101,14 +121,25 @@ function mockListLanguages(languages) {
|
||||||
return { packs: [] };
|
return { packs: [] };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config = await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, gitHubVersion, logger));
|
languagesInput: languages,
|
||||||
|
repository: { owner: "github", repo: "example" },
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
}));
|
||||||
|
t.deepEqual(config, await configUtils.getDefaultConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput: languages,
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
logger,
|
||||||
|
})));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("loading config saves config", async (t) => {
|
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const logger = (0, logging_1.getRunnerLogger)(true);
|
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -124,14 +155,20 @@ function mockListLanguages(languages) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// Sanity check the saved config file does not already exist
|
// Sanity check the saved config file does not already exist
|
||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tempDir, logger), undefined);
|
||||||
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config1 = await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput: "javascript,python",
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
workspacePath: tempDir,
|
||||||
|
logger,
|
||||||
|
}));
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
const config2 = await configUtils.getConfig(tmpDir, logger);
|
const config2 = await configUtils.getConfig(tempDir, logger);
|
||||||
t.not(config2, undefined);
|
t.not(config2, undefined);
|
||||||
if (config2 !== undefined) {
|
if (config2 !== undefined) {
|
||||||
// removes properties assigned to undefined.
|
// removes properties assigned to undefined.
|
||||||
|
|
@ -141,22 +178,32 @@ function mockListLanguages(languages) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
configFile: "../input",
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
t.deepEqual(err, new util_1.UserError(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tmpDir, "../input"))));
|
t.deepEqual(err, new util_1.UserError(configUtils.getConfigFileOutsideWorkspaceErrorMessage(path.join(tempDir, "../input"))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("load non-local input with invalid repo syntax", async (t) => {
|
(0, ava_1.default)("load non-local input with invalid repo syntax", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
configFile,
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -165,22 +212,28 @@ function mockListLanguages(languages) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("load non-existent input", async (t) => {
|
(0, ava_1.default)("load non-existent input", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tempDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput,
|
||||||
|
configFile,
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
t.deepEqual(err, new util_1.UserError(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tmpDir, "input"))));
|
t.deepEqual(err, new util_1.UserError(configUtils.getConfigFileDoesNotExistErrorMessage(path.join(tempDir, "input"))));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("load non-empty input", async (t) => {
|
(0, ava_1.default)("load non-empty input", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -208,7 +261,7 @@ function mockListLanguages(languages) {
|
||||||
- b
|
- b
|
||||||
paths:
|
paths:
|
||||||
- c/d`;
|
- c/d`;
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||||
// 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],
|
||||||
|
|
@ -219,10 +272,10 @@ function mockListLanguages(languages) {
|
||||||
"paths-ignore": ["a", "b"],
|
"paths-ignore": ["a", "b"],
|
||||||
paths: ["c/d"],
|
paths: ["c/d"],
|
||||||
},
|
},
|
||||||
tempDir: tmpDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "my-artifact",
|
debugArtifactName: "my-artifact",
|
||||||
debugDatabaseName: "my-db",
|
debugDatabaseName: "my-db",
|
||||||
|
|
@ -230,9 +283,17 @@ function mockListLanguages(languages) {
|
||||||
trapCaches: {},
|
trapCaches: {},
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, undefined, false, false, "my-artifact", "my-db", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const actualConfig = await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput,
|
||||||
|
configFile: configFilePath,
|
||||||
|
debugArtifactName: "my-artifact",
|
||||||
|
debugDatabaseName: "my-db",
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
|
|
@ -256,14 +317,14 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("Using config input and file together, config input should be used.", async (t) => {
|
(0, ava_1.default)("Using config input and file together, config input should be used.", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tempDir;
|
||||||
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
process.env["GITHUB_WORKSPACE"] = tempDir;
|
||||||
const inputFileContents = `
|
const inputFileContents = `
|
||||||
name: my config
|
name: my config
|
||||||
queries:
|
queries:
|
||||||
- uses: ./foo_file`;
|
- uses: ./foo_file`;
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
const configInput = `
|
const configInput = `
|
||||||
name: my config
|
name: my config
|
||||||
queries:
|
queries:
|
||||||
|
|
@ -274,9 +335,9 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
python:
|
python:
|
||||||
- c/d@1.2.3
|
- c/d@1.2.3
|
||||||
`;
|
`;
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return queriesToResolvedQueryForm(queries);
|
||||||
|
|
@ -286,14 +347,21 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// Only JS, python packs will be ignored
|
// Only JS, python packs will be ignored
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, configFilePath, configInput, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput,
|
||||||
|
configFile: configFilePath,
|
||||||
|
configInput,
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
t.deepEqual(config.originalUserInput, yaml.load(configInput));
|
t.deepEqual(config.originalUserInput, yaml.load(configInput));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("API client used when reading remote config", async (t) => {
|
(0, ava_1.default)("API client used when reading remote config", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -326,20 +394,31 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
};
|
};
|
||||||
const spyGetContents = mockGetContents(dummyResponse);
|
const spyGetContents = mockGetContents(dummyResponse);
|
||||||
// Create checkout directory for remote queries repository
|
// Create checkout directory for remote queries repository
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tempDir, "foo/bar/dev"), { recursive: true });
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput,
|
||||||
|
configFile,
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Remote config handles the case where a directory is provided", async (t) => {
|
(0, ava_1.default)("Remote config handles the case where a directory is provided", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const dummyResponse = []; // directories are returned as arrays
|
const dummyResponse = []; // directories are returned as arrays
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
configFile: repoReference,
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -348,14 +427,19 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Invalid format of remote config handled correctly", async (t) => {
|
(0, ava_1.default)("Invalid format of remote config handled correctly", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const dummyResponse = {
|
const dummyResponse = {
|
||||||
// note no "content" property here
|
// note no "content" property here
|
||||||
};
|
};
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
configFile: repoReference,
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -364,9 +448,9 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("No detected languages", async (t) => {
|
(0, ava_1.default)("No detected languages", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
const codeQL = (0, codeql_1.setCodeQL)({
|
const codeql = (0, codeql_1.setCodeQL)({
|
||||||
async resolveLanguages() {
|
async resolveLanguages() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
@ -375,7 +459,11 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
tempDir,
|
||||||
|
codeql,
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -384,10 +472,15 @@ function queriesToResolvedQueryForm(queries) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Unknown languages", async (t) => {
|
(0, ava_1.default)("Unknown languages", async (t) => {
|
||||||
return await (0, util_1.withTmpDir)(async (tmpDir) => {
|
return await (0, util_1.withTmpDir)(async (tempDir) => {
|
||||||
const languages = "rubbish,english";
|
const languagesInput = "rubbish,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, undefined, false, false, "", "", { owner: "github", repo: "example" }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(createTestInitConfigInputs({
|
||||||
|
languagesInput,
|
||||||
|
tempDir,
|
||||||
|
codeql: (0, codeql_1.getCachedCodeQL)(),
|
||||||
|
workspacePath: tempDir,
|
||||||
|
}));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
15
lib/database-upload.test.js
generated
15
lib/database-upload.test.js
generated
|
|
@ -33,7 +33,6 @@ const sinon = __importStar(require("sinon"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const apiClient = __importStar(require("./api-client"));
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
|
@ -49,20 +48,10 @@ const testApiDetails = {
|
||||||
apiURL: undefined,
|
apiURL: undefined,
|
||||||
};
|
};
|
||||||
function getTestConfig(tmpDir) {
|
function getTestConfig(tmpDir) {
|
||||||
return {
|
return (0, testing_utils_1.createTestConfig)({
|
||||||
languages: [languages_1.Language.javascript],
|
languages: [languages_1.Language.javascript],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: tmpDir,
|
|
||||||
codeQLCmd: "foo",
|
|
||||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
|
||||||
dbLocation: tmpDir,
|
dbLocation: tmpDir,
|
||||||
debugMode: false,
|
});
|
||||||
debugArtifactName: util_1.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util_1.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: config_utils_1.defaultAugmentationProperties,
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
async function mockHttpRequests(databaseUploadStatusCode) {
|
async function mockHttpRequests(databaseUploadStatusCode) {
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
// Passing an auth token is required, so we just use a dummy value
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
29
lib/init-action.js
generated
29
lib/init-action.js
generated
|
|
@ -137,12 +137,29 @@ async function run() {
|
||||||
logger.info("Detected no issues with the code scanning workflow.");
|
logger.info("Detected no issues with the code scanning workflow.");
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, actions_util_1.getOptionalInput)("config"), getTrapCachingEnabled(),
|
config = await (0, init_1.initConfig)({
|
||||||
// Debug mode is enabled if:
|
languagesInput: (0, actions_util_1.getOptionalInput)("languages"),
|
||||||
// - The `init` Action is passed `debug: true`.
|
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
|
||||||
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
packsInput: (0, actions_util_1.getOptionalInput)("packs"),
|
||||||
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
|
configFile: (0, actions_util_1.getOptionalInput)("config-file"),
|
||||||
(0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(), (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
dbLocation: (0, actions_util_1.getOptionalInput)("db-location"),
|
||||||
|
configInput: (0, actions_util_1.getOptionalInput)("config"),
|
||||||
|
trapCachingEnabled: getTrapCachingEnabled(),
|
||||||
|
// Debug mode is enabled if:
|
||||||
|
// - The `init` Action is passed `debug: true`.
|
||||||
|
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
||||||
|
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
|
||||||
|
debugMode: (0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(),
|
||||||
|
debugArtifactName: (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
repository: repositoryNwo,
|
||||||
|
tempDir: (0, actions_util_1.getTemporaryDirectory)(),
|
||||||
|
codeql,
|
||||||
|
workspacePath: (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"),
|
||||||
|
githubVersion: gitHubVersion,
|
||||||
|
apiDetails,
|
||||||
|
logger,
|
||||||
|
});
|
||||||
await (0, init_1.checkInstallPython311)(config.languages, codeql);
|
await (0, init_1.checkInstallPython311)(config.languages, codeql);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
5
lib/init.js
generated
5
lib/init.js
generated
|
|
@ -41,9 +41,10 @@ async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVe
|
||||||
return { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
return { codeql, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, configInput, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(inputs) {
|
||||||
|
const logger = inputs.logger;
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, configInput, trapCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(inputs);
|
||||||
printPathFiltersWarning(config, logger);
|
printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAGpD,qCAA+C;AAC/C,4DAA8C;AAE9C,2CAA0D;AAI1D,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,UAA8B,EAC9B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,iBAA2C,EAC3C,MAAc;IAOd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,uBAAuB,EAAE,WAAW,EAAE,YAAY,EAAE,GAClE,MAAM,IAAA,oBAAW,EACf,UAAU,EACV,UAAU,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,MAAM,EACN,IAAI,CACL,CAAC;IACJ,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC;AACxE,CAAC;AA3BD,gCA2BC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC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AI,EAAE,CAAC;QACX,CAAC;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;QACZ,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}
|
||||||
28
lib/testing-utils.js
generated
28
lib/testing-utils.js
generated
|
|
@ -26,14 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionInfo = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
|
exports.createTestConfig = exports.mockBundleDownloadApi = exports.createFeatures = exports.mockCodeQLVersion = exports.makeVersionInfo = exports.mockLanguagesInRepo = exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = exports.SAMPLE_DEFAULT_CLI_VERSION = exports.SAMPLE_DOTCOM_API_DETAILS = void 0;
|
||||||
const node_util_1 = require("node:util");
|
const node_util_1 = require("node:util");
|
||||||
const path_1 = __importDefault(require("path"));
|
const path_1 = __importDefault(require("path"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const nock_1 = __importDefault(require("nock"));
|
const nock_1 = __importDefault(require("nock"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const apiClient = __importStar(require("./api-client"));
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const CodeQL = __importStar(require("./codeql"));
|
const codeql = __importStar(require("./codeql"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
exports.SAMPLE_DOTCOM_API_DETAILS = {
|
exports.SAMPLE_DOTCOM_API_DETAILS = {
|
||||||
auth: "token",
|
auth: "token",
|
||||||
|
|
@ -74,7 +74,7 @@ function setupTests(test) {
|
||||||
typedTest.beforeEach((t) => {
|
typedTest.beforeEach((t) => {
|
||||||
// Set an empty CodeQL object so that all method calls will fail
|
// Set an empty CodeQL object so that all method calls will fail
|
||||||
// unless the test explicitly sets one up.
|
// unless the test explicitly sets one up.
|
||||||
CodeQL.setCodeQL({});
|
codeql.setCodeQL({});
|
||||||
// Replace stdout and stderr so we can record output during tests
|
// Replace stdout and stderr so we can record output during tests
|
||||||
t.context.testOutput = "";
|
t.context.testOutput = "";
|
||||||
const processStdoutWrite = process.stdout.write.bind(process.stdout);
|
const processStdoutWrite = process.stdout.write.bind(process.stdout);
|
||||||
|
|
@ -241,4 +241,26 @@ function mockBundleDownloadApi({ apiDetails = exports.SAMPLE_DOTCOM_API_DETAILS,
|
||||||
return `${baseUrl}${relativeUrl}`;
|
return `${baseUrl}${relativeUrl}`;
|
||||||
}
|
}
|
||||||
exports.mockBundleDownloadApi = mockBundleDownloadApi;
|
exports.mockBundleDownloadApi = mockBundleDownloadApi;
|
||||||
|
function createTestConfig(overrides) {
|
||||||
|
return Object.assign({}, {
|
||||||
|
languages: [],
|
||||||
|
originalUserInput: {},
|
||||||
|
tempDir: "",
|
||||||
|
codeQLCmd: "",
|
||||||
|
gitHubVersion: {
|
||||||
|
type: util_1.GitHubVariant.DOTCOM,
|
||||||
|
},
|
||||||
|
dbLocation: "",
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util_1.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: util_1.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
augmentationProperties: {
|
||||||
|
packsInputCombines: false,
|
||||||
|
queriesInputCombines: false,
|
||||||
|
},
|
||||||
|
trapCaches: {},
|
||||||
|
trapCacheDownloadTime: 0,
|
||||||
|
}, overrides);
|
||||||
|
}
|
||||||
|
exports.createTestConfig = createTestConfig;
|
||||||
//# sourceMappingURL=testing-utils.js.map
|
//# sourceMappingURL=testing-utils.js.map
|
||||||
File diff suppressed because one or more lines are too long
20
lib/tracer-config.test.js
generated
20
lib/tracer-config.test.js
generated
|
|
@ -29,27 +29,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const tracer_config_1 = require("./tracer-config");
|
const tracer_config_1 = require("./tracer-config");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
function getTestConfig(tmpDir) {
|
function getTestConfig(tempDir) {
|
||||||
return {
|
return (0, testing_utils_1.createTestConfig)({
|
||||||
languages: [languages_1.Language.java],
|
languages: [languages_1.Language.java],
|
||||||
originalUserInput: {},
|
tempDir,
|
||||||
tempDir: tmpDir,
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
codeQLCmd: "",
|
});
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: configUtils.defaultAugmentationProperties,
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
(0, ava_1.default)("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"tracer-config.test.js","sourceRoot":"","sources":["../src/tracer-config.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAA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AAI,CACrC,MAAM,CAAC,UAAU,EACjB,MAAM,EACN,oBAAoB,CACrB,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,qBAAqB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAChC,qBAAqB,EACrB,oBAAoB,CACrB,CAAC;QACF,EAAE,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAAC;QAEpE,MAAM,MAAM,GAAG,MAAM,IAAA,uCAAuB,EAC1C,IAAA,+BAAe,EAAC,OAAO,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,EAC1D,MAAM,CACP,CAAC;QACF,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QAElC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
44
lib/trap-caching.test.js
generated
44
lib/trap-caching.test.js
generated
|
|
@ -78,48 +78,22 @@ const stubCodeql = (0, codeql_1.setCodeQL)({
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const testConfigWithoutTmpDir = {
|
const testConfigWithoutTmpDir = (0, testing_utils_1.createTestConfig)({
|
||||||
languages: [languages_1.Language.javascript, languages_1.Language.cpp],
|
languages: [languages_1.Language.javascript, languages_1.Language.cpp],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: "",
|
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
},
|
|
||||||
dbLocation: "",
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {
|
trapCaches: {
|
||||||
javascript: "/some/cache/dir",
|
javascript: "/some/cache/dir",
|
||||||
},
|
},
|
||||||
trapCacheDownloadTime: 0,
|
});
|
||||||
};
|
function getTestConfigWithTempDir(tempDir) {
|
||||||
function getTestConfigWithTempDir(tmpDir) {
|
return (0, testing_utils_1.createTestConfig)({
|
||||||
return {
|
|
||||||
languages: [languages_1.Language.javascript, languages_1.Language.ruby],
|
languages: [languages_1.Language.javascript, languages_1.Language.ruby],
|
||||||
originalUserInput: {},
|
tempDir,
|
||||||
tempDir: tmpDir,
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {
|
trapCaches: {
|
||||||
javascript: path.resolve(tmpDir, "jsCache"),
|
javascript: path.resolve(tempDir, "jsCache"),
|
||||||
ruby: path.resolve(tmpDir, "rubyCache"),
|
ruby: path.resolve(tempDir, "rubyCache"),
|
||||||
},
|
},
|
||||||
trapCacheDownloadTime: 0,
|
});
|
||||||
};
|
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("check flags for JS, analyzing default branch", async (t) => {
|
(0, ava_1.default)("check flags for JS, analyzing default branch", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -6,11 +6,15 @@ import * as sinon from "sinon";
|
||||||
|
|
||||||
import { runQueries } from "./analyze";
|
import { runQueries } from "./analyze";
|
||||||
import { setCodeQL } from "./codeql";
|
import { setCodeQL } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
|
||||||
import { Feature } from "./feature-flags";
|
import { Feature } from "./feature-flags";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { setupTests, setupActionsVars, createFeatures } from "./testing-utils";
|
import {
|
||||||
|
setupTests,
|
||||||
|
setupActionsVars,
|
||||||
|
createFeatures,
|
||||||
|
createTestConfig,
|
||||||
|
} from "./testing-utils";
|
||||||
import * as uploadLib from "./upload-lib";
|
import * as uploadLib from "./upload-lib";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
|
|
@ -82,25 +86,11 @@ test("status report fields", async (t) => {
|
||||||
databasePrintBaseline: async () => "",
|
databasePrintBaseline: async () => "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const config: Config = {
|
const config = createTestConfig({
|
||||||
languages: [language],
|
languages: [language],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
} as util.GitHubVersion,
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
debugMode: false,
|
});
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ import {
|
||||||
SAMPLE_DEFAULT_CLI_VERSION,
|
SAMPLE_DEFAULT_CLI_VERSION,
|
||||||
mockBundleDownloadApi,
|
mockBundleDownloadApi,
|
||||||
makeVersionInfo,
|
makeVersionInfo,
|
||||||
|
createTestConfig,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { initializeEnvironment } from "./util";
|
import { initializeEnvironment } from "./util";
|
||||||
|
|
@ -37,25 +38,9 @@ let stubConfig: Config;
|
||||||
test.beforeEach(() => {
|
test.beforeEach(() => {
|
||||||
initializeEnvironment("1.2.3");
|
initializeEnvironment("1.2.3");
|
||||||
|
|
||||||
stubConfig = {
|
stubConfig = createTestConfig({
|
||||||
languages: [Language.cpp],
|
languages: [Language.cpp],
|
||||||
originalUserInput: {},
|
});
|
||||||
tempDir: "",
|
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
} as util.GitHubVersion,
|
|
||||||
dbLocation: "",
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function installIntoToolcache({
|
async function installIntoToolcache({
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,12 @@ import * as yaml from "js-yaml";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import { getCachedCodeQL, PackDownloadOutput, setCodeQL } from "./codeql";
|
import {
|
||||||
|
CodeQL,
|
||||||
|
getCachedCodeQL,
|
||||||
|
PackDownloadOutput,
|
||||||
|
setCodeQL,
|
||||||
|
} from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
|
|
@ -26,15 +31,41 @@ import {
|
||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
const sampleApiDetails = {
|
const githubVersion = { type: GitHubVariant.DOTCOM } as GitHubVersion;
|
||||||
auth: "token",
|
|
||||||
externalRepoAuth: "token",
|
|
||||||
url: "https://github.example.com",
|
|
||||||
apiURL: undefined,
|
|
||||||
registriesAuthTokens: undefined,
|
|
||||||
};
|
|
||||||
|
|
||||||
const gitHubVersion = { type: GitHubVariant.DOTCOM } as GitHubVersion;
|
function createTestInitConfigInputs(
|
||||||
|
overrides: Partial<configUtils.InitConfigInputs>,
|
||||||
|
): configUtils.InitConfigInputs {
|
||||||
|
return Object.assign(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
languagesInput: undefined,
|
||||||
|
queriesInput: undefined,
|
||||||
|
packsInput: undefined,
|
||||||
|
configFile: undefined,
|
||||||
|
dbLocation: undefined,
|
||||||
|
configInput: undefined,
|
||||||
|
trapCachingEnabled: false,
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: "",
|
||||||
|
debugDatabaseName: "",
|
||||||
|
repository: { owner: "github", repo: "example" },
|
||||||
|
tempDir: "",
|
||||||
|
codeql: {} as CodeQL,
|
||||||
|
workspacePath: "",
|
||||||
|
githubVersion,
|
||||||
|
apiDetails: {
|
||||||
|
auth: "token",
|
||||||
|
externalRepoAuth: "token",
|
||||||
|
url: "https://github.example.com",
|
||||||
|
apiURL: undefined,
|
||||||
|
registriesAuthTokens: undefined,
|
||||||
|
},
|
||||||
|
logger: getRunnerLogger(true),
|
||||||
|
},
|
||||||
|
overrides,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the filepath of the newly-created file
|
// Returns the filepath of the newly-created file
|
||||||
function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
function createConfigFile(inputFileContents: string, tmpDir: string): string {
|
||||||
|
|
@ -77,11 +108,11 @@ function mockListLanguages(languages: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
test("load empty config", async (t) => {
|
test("load empty config", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const logger = getRunnerLogger(true);
|
const logger = getRunnerLogger(true);
|
||||||
const languages = "javascript,python";
|
const languages = "javascript,python";
|
||||||
|
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -98,51 +129,34 @@ test("load empty config", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput: languages,
|
||||||
undefined,
|
repository: { owner: "github", repo: "example" },
|
||||||
undefined,
|
tempDir,
|
||||||
undefined,
|
codeql,
|
||||||
undefined,
|
logger,
|
||||||
false,
|
}),
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
logger,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(
|
t.deepEqual(
|
||||||
config,
|
config,
|
||||||
await configUtils.getDefaultConfig(
|
await configUtils.getDefaultConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput: languages,
|
||||||
undefined,
|
tempDir,
|
||||||
undefined,
|
codeql,
|
||||||
false,
|
logger,
|
||||||
false,
|
}),
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
gitHubVersion,
|
|
||||||
logger,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("loading config saves config", async (t) => {
|
test("loading config saves config", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const logger = getRunnerLogger(true);
|
const logger = getRunnerLogger(true);
|
||||||
|
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -159,36 +173,26 @@ test("loading config saves config", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Sanity check the saved config file does not already exist
|
// Sanity check the saved config file does not already exist
|
||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
|
||||||
|
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tempDir, logger), undefined);
|
||||||
|
|
||||||
const config1 = await configUtils.initConfig(
|
const config1 = await configUtils.initConfig(
|
||||||
"javascript,python",
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput: "javascript,python",
|
||||||
undefined,
|
tempDir,
|
||||||
undefined,
|
codeql,
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
logger,
|
||||||
false,
|
}),
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
logger,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
|
||||||
|
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
const config2 = await configUtils.getConfig(tmpDir, logger);
|
const config2 = await configUtils.getConfig(tempDir, logger);
|
||||||
t.not(config2, undefined);
|
t.not(config2, undefined);
|
||||||
if (config2 !== undefined) {
|
if (config2 !== undefined) {
|
||||||
// removes properties assigned to undefined.
|
// removes properties assigned to undefined.
|
||||||
|
|
@ -199,26 +203,15 @@ test("loading config saves config", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("load input outside of workspace", async (t) => {
|
test("load input outside of workspace", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
undefined,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
configFile: "../input",
|
||||||
undefined,
|
tempDir,
|
||||||
"../input",
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -226,7 +219,7 @@ test("load input outside of workspace", async (t) => {
|
||||||
err,
|
err,
|
||||||
new UserError(
|
new UserError(
|
||||||
configUtils.getConfigFileOutsideWorkspaceErrorMessage(
|
configUtils.getConfigFileOutsideWorkspaceErrorMessage(
|
||||||
path.join(tmpDir, "../input"),
|
path.join(tempDir, "../input"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -235,29 +228,18 @@ test("load input outside of workspace", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("load non-local input with invalid repo syntax", async (t) => {
|
test("load non-local input with invalid repo syntax", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
undefined,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
configFile,
|
||||||
undefined,
|
tempDir,
|
||||||
configFile,
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -274,30 +256,20 @@ test("load non-local input with invalid repo syntax", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("load non-existent input", async (t) => {
|
test("load non-existent input", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tempDir, configFile)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput,
|
||||||
undefined,
|
configFile,
|
||||||
configFile,
|
tempDir,
|
||||||
undefined,
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
false,
|
}),
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -305,7 +277,7 @@ test("load non-existent input", async (t) => {
|
||||||
err,
|
err,
|
||||||
new UserError(
|
new UserError(
|
||||||
configUtils.getConfigFileDoesNotExistErrorMessage(
|
configUtils.getConfigFileDoesNotExistErrorMessage(
|
||||||
path.join(tmpDir, "input"),
|
path.join(tempDir, "input"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -314,8 +286,8 @@ test("load non-existent input", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("load non-empty input", async (t) => {
|
test("load non-empty input", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -345,7 +317,7 @@ test("load non-empty input", async (t) => {
|
||||||
paths:
|
paths:
|
||||||
- c/d`;
|
- c/d`;
|
||||||
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||||
|
|
||||||
// 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 = {
|
||||||
|
|
@ -357,10 +329,10 @@ test("load non-empty input", async (t) => {
|
||||||
"paths-ignore": ["a", "b"],
|
"paths-ignore": ["a", "b"],
|
||||||
paths: ["c/d"],
|
paths: ["c/d"],
|
||||||
},
|
},
|
||||||
tempDir: tmpDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
debugMode: false,
|
debugMode: false,
|
||||||
debugArtifactName: "my-artifact",
|
debugArtifactName: "my-artifact",
|
||||||
debugDatabaseName: "my-db",
|
debugDatabaseName: "my-db",
|
||||||
|
|
@ -369,27 +341,19 @@ test("load non-empty input", async (t) => {
|
||||||
trapCacheDownloadTime: 0,
|
trapCacheDownloadTime: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
|
|
||||||
const actualConfig = await configUtils.initConfig(
|
const actualConfig = await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput,
|
||||||
undefined,
|
configFile: configFilePath,
|
||||||
configFilePath,
|
debugArtifactName: "my-artifact",
|
||||||
undefined,
|
debugDatabaseName: "my-db",
|
||||||
undefined,
|
tempDir,
|
||||||
false,
|
codeql,
|
||||||
false,
|
workspacePath: tempDir,
|
||||||
"my-artifact",
|
}),
|
||||||
"my-db",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
|
|
@ -417,15 +381,15 @@ function queriesToResolvedQueryForm(queries: string[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
test("Using config input and file together, config input should be used.", async (t) => {
|
test("Using config input and file together, config input should be used.", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tempDir;
|
||||||
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
process.env["GITHUB_WORKSPACE"] = tempDir;
|
||||||
|
|
||||||
const inputFileContents = `
|
const inputFileContents = `
|
||||||
name: my config
|
name: my config
|
||||||
queries:
|
queries:
|
||||||
- uses: ./foo_file`;
|
- uses: ./foo_file`;
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tempDir);
|
||||||
|
|
||||||
const configInput = `
|
const configInput = `
|
||||||
name: my config
|
name: my config
|
||||||
|
|
@ -438,13 +402,13 @@ test("Using config input and file together, config input should be used.", async
|
||||||
- c/d@1.2.3
|
- c/d@1.2.3
|
||||||
`;
|
`;
|
||||||
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||||
|
|
||||||
const resolveQueriesArgs: Array<{
|
const resolveQueriesArgs: Array<{
|
||||||
queries: string[];
|
queries: string[];
|
||||||
extraSearchPath: string | undefined;
|
extraSearchPath: string | undefined;
|
||||||
}> = [];
|
}> = [];
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveQueries(
|
async resolveQueries(
|
||||||
queries: string[],
|
queries: string[],
|
||||||
extraSearchPath: string | undefined,
|
extraSearchPath: string | undefined,
|
||||||
|
|
@ -458,26 +422,17 @@ test("Using config input and file together, config input should be used.", async
|
||||||
});
|
});
|
||||||
|
|
||||||
// Only JS, python packs will be ignored
|
// Only JS, python packs will be ignored
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
|
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput,
|
||||||
undefined,
|
configFile: configFilePath,
|
||||||
undefined,
|
configInput,
|
||||||
configFilePath,
|
tempDir,
|
||||||
configInput,
|
codeql,
|
||||||
false,
|
workspacePath: tempDir,
|
||||||
false,
|
}),
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
t.deepEqual(config.originalUserInput, yaml.load(configInput));
|
t.deepEqual(config.originalUserInput, yaml.load(configInput));
|
||||||
|
|
@ -485,8 +440,8 @@ test("Using config input and file together, config input should be used.", async
|
||||||
});
|
});
|
||||||
|
|
||||||
test("API client used when reading remote config", async (t) => {
|
test("API client used when reading remote config", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
|
|
@ -521,59 +476,38 @@ test("API client used when reading remote config", async (t) => {
|
||||||
const spyGetContents = mockGetContents(dummyResponse);
|
const spyGetContents = mockGetContents(dummyResponse);
|
||||||
|
|
||||||
// Create checkout directory for remote queries repository
|
// Create checkout directory for remote queries repository
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tempDir, "foo/bar/dev"), { recursive: true });
|
||||||
|
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languagesInput = "javascript";
|
||||||
|
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput,
|
||||||
undefined,
|
configFile,
|
||||||
configFile,
|
tempDir,
|
||||||
undefined,
|
codeql,
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
false,
|
}),
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Remote config handles the case where a directory is provided", async (t) => {
|
test("Remote config handles the case where a directory is provided", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const dummyResponse = []; // directories are returned as arrays
|
const dummyResponse = []; // directories are returned as arrays
|
||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
|
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
undefined,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
configFile: repoReference,
|
||||||
undefined,
|
tempDir,
|
||||||
repoReference,
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -588,7 +522,7 @@ test("Remote config handles the case where a directory is provided", async (t) =
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Invalid format of remote config handled correctly", async (t) => {
|
test("Invalid format of remote config handled correctly", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const dummyResponse = {
|
const dummyResponse = {
|
||||||
// note no "content" property here
|
// note no "content" property here
|
||||||
};
|
};
|
||||||
|
|
@ -597,23 +531,12 @@ test("Invalid format of remote config handled correctly", async (t) => {
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
undefined,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
configFile: repoReference,
|
||||||
undefined,
|
tempDir,
|
||||||
repoReference,
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -628,9 +551,9 @@ test("Invalid format of remote config handled correctly", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("No detected languages", async (t) => {
|
test("No detected languages", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
const codeQL = setCodeQL({
|
const codeql = setCodeQL({
|
||||||
async resolveLanguages() {
|
async resolveLanguages() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
|
|
@ -641,23 +564,11 @@ test("No detected languages", async (t) => {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
undefined,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
tempDir,
|
||||||
undefined,
|
codeql,
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
undefined,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
codeQL,
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
@ -667,28 +578,17 @@ test("No detected languages", async (t) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Unknown languages", async (t) => {
|
test("Unknown languages", async (t) => {
|
||||||
return await withTmpDir(async (tmpDir) => {
|
return await withTmpDir(async (tempDir) => {
|
||||||
const languages = "rubbish,english";
|
const languagesInput = "rubbish,english";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(
|
await configUtils.initConfig(
|
||||||
languages,
|
createTestInitConfigInputs({
|
||||||
undefined,
|
languagesInput,
|
||||||
undefined,
|
tempDir,
|
||||||
undefined,
|
codeql: getCachedCodeQL(),
|
||||||
undefined,
|
workspacePath: tempDir,
|
||||||
undefined,
|
}),
|
||||||
false,
|
|
||||||
false,
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
{ owner: "github", repo: "example" },
|
|
||||||
tmpDir,
|
|
||||||
getCachedCodeQL(),
|
|
||||||
tmpDir,
|
|
||||||
gitHubVersion,
|
|
||||||
sampleApiDetails,
|
|
||||||
getRunnerLogger(true),
|
|
||||||
);
|
);
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
|
|
@ -391,39 +391,69 @@ export async function getRawLanguages(
|
||||||
return { rawLanguages, autodetected };
|
return { rawLanguages, autodetected };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Inputs required to initialize a configuration. */
|
||||||
|
export interface InitConfigInputs {
|
||||||
|
languagesInput: string | undefined;
|
||||||
|
queriesInput: string | undefined;
|
||||||
|
packsInput: string | undefined;
|
||||||
|
configFile: string | undefined;
|
||||||
|
dbLocation: string | undefined;
|
||||||
|
configInput: string | undefined;
|
||||||
|
trapCachingEnabled: boolean;
|
||||||
|
debugMode: boolean;
|
||||||
|
debugArtifactName: string;
|
||||||
|
debugDatabaseName: string;
|
||||||
|
repository: RepositoryNwo;
|
||||||
|
tempDir: string;
|
||||||
|
codeql: CodeQL;
|
||||||
|
workspacePath: string;
|
||||||
|
githubVersion: GitHubVersion;
|
||||||
|
apiDetails: api.GitHubApiCombinedDetails;
|
||||||
|
logger: Logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetDefaultConfigInputs = Omit<
|
||||||
|
InitConfigInputs,
|
||||||
|
"configFile" | "configInput"
|
||||||
|
>;
|
||||||
|
|
||||||
|
type LoadConfigInputs = Omit<InitConfigInputs, "configInput"> & {
|
||||||
|
configFile: string;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
export async function getDefaultConfig(
|
export async function getDefaultConfig({
|
||||||
languagesInput: string | undefined,
|
languagesInput,
|
||||||
rawQueriesInput: string | undefined,
|
queriesInput,
|
||||||
rawPacksInput: string | undefined,
|
packsInput,
|
||||||
dbLocation: string | undefined,
|
dbLocation,
|
||||||
trapCachingEnabled: boolean,
|
trapCachingEnabled,
|
||||||
debugMode: boolean,
|
debugMode,
|
||||||
debugArtifactName: string,
|
debugArtifactName,
|
||||||
debugDatabaseName: string,
|
debugDatabaseName,
|
||||||
repository: RepositoryNwo,
|
repository,
|
||||||
tempDir: string,
|
tempDir,
|
||||||
codeQL: CodeQL,
|
codeql,
|
||||||
gitHubVersion: GitHubVersion,
|
githubVersion,
|
||||||
logger: Logger,
|
logger,
|
||||||
): Promise<Config> {
|
}: GetDefaultConfigInputs): Promise<Config> {
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
codeQL,
|
codeql,
|
||||||
languagesInput,
|
languagesInput,
|
||||||
repository,
|
repository,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
const augmentationProperties = calculateAugmentation(
|
const augmentationProperties = calculateAugmentation(
|
||||||
rawPacksInput,
|
packsInput,
|
||||||
rawQueriesInput,
|
queriesInput,
|
||||||
languages,
|
languages,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
codeQL,
|
codeql,
|
||||||
languages,
|
languages,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
@ -432,8 +462,8 @@ export async function getDefaultConfig(
|
||||||
languages,
|
languages,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
|
|
@ -466,24 +496,24 @@ async function downloadCacheWithTime(
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(
|
async function loadConfig({
|
||||||
languagesInput: string | undefined,
|
languagesInput,
|
||||||
rawQueriesInput: string | undefined,
|
queriesInput,
|
||||||
rawPacksInput: string | undefined,
|
packsInput,
|
||||||
configFile: string,
|
configFile,
|
||||||
dbLocation: string | undefined,
|
dbLocation,
|
||||||
trapCachingEnabled: boolean,
|
trapCachingEnabled,
|
||||||
debugMode: boolean,
|
debugMode,
|
||||||
debugArtifactName: string,
|
debugArtifactName,
|
||||||
debugDatabaseName: string,
|
debugDatabaseName,
|
||||||
repository: RepositoryNwo,
|
repository,
|
||||||
tempDir: string,
|
tempDir,
|
||||||
codeQL: CodeQL,
|
codeql,
|
||||||
workspacePath: string,
|
workspacePath,
|
||||||
gitHubVersion: GitHubVersion,
|
githubVersion,
|
||||||
apiDetails: api.GitHubApiCombinedDetails,
|
apiDetails,
|
||||||
logger: Logger,
|
logger,
|
||||||
): Promise<Config> {
|
}: LoadConfigInputs): Promise<Config> {
|
||||||
let parsedYAML: UserConfig;
|
let parsedYAML: UserConfig;
|
||||||
|
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
|
|
@ -495,21 +525,21 @@ async function loadConfig(
|
||||||
}
|
}
|
||||||
|
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
codeQL,
|
codeql,
|
||||||
languagesInput,
|
languagesInput,
|
||||||
repository,
|
repository,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
const augmentationProperties = calculateAugmentation(
|
const augmentationProperties = calculateAugmentation(
|
||||||
rawPacksInput,
|
packsInput,
|
||||||
rawQueriesInput,
|
queriesInput,
|
||||||
languages,
|
languages,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(
|
||||||
trapCachingEnabled,
|
trapCachingEnabled,
|
||||||
codeQL,
|
codeql,
|
||||||
languages,
|
languages,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
@ -518,8 +548,8 @@ async function loadConfig(
|
||||||
languages,
|
languages,
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeql.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion: githubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
debugMode,
|
||||||
debugArtifactName,
|
debugArtifactName,
|
||||||
|
|
@ -765,76 +795,33 @@ function dbLocationOrDefault(
|
||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
export async function initConfig(
|
export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
|
||||||
languagesInput: string | undefined,
|
|
||||||
queriesInput: string | undefined,
|
|
||||||
packsInput: string | undefined,
|
|
||||||
configFile: string | undefined,
|
|
||||||
dbLocation: string | undefined,
|
|
||||||
configInput: string | undefined,
|
|
||||||
trapCachingEnabled: boolean,
|
|
||||||
debugMode: boolean,
|
|
||||||
debugArtifactName: string,
|
|
||||||
debugDatabaseName: string,
|
|
||||||
repository: RepositoryNwo,
|
|
||||||
tempDir: string,
|
|
||||||
codeQL: CodeQL,
|
|
||||||
workspacePath: string,
|
|
||||||
gitHubVersion: GitHubVersion,
|
|
||||||
apiDetails: api.GitHubApiCombinedDetails,
|
|
||||||
logger: Logger,
|
|
||||||
): Promise<Config> {
|
|
||||||
let config: Config;
|
let config: Config;
|
||||||
|
|
||||||
|
const { logger, workspacePath } = inputs;
|
||||||
|
|
||||||
// if configInput is set, it takes precedence over configFile
|
// if configInput is set, it takes precedence over configFile
|
||||||
if (configInput) {
|
if (inputs.configInput) {
|
||||||
if (configFile) {
|
if (inputs.configFile) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
`Both a config file and config input were provided. Ignoring config file.`,
|
`Both a config file and config input were provided. Ignoring config file.`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
configFile = path.resolve(workspacePath, "user-config-from-action.yml");
|
inputs.configFile = path.resolve(
|
||||||
fs.writeFileSync(configFile, configInput);
|
workspacePath,
|
||||||
logger.debug(`Using config from action input: ${configFile}`);
|
"user-config-from-action.yml",
|
||||||
|
);
|
||||||
|
fs.writeFileSync(inputs.configFile, inputs.configInput);
|
||||||
|
logger.debug(`Using config from action input: ${inputs.configFile}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!inputs.configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(
|
config = await getDefaultConfig(inputs);
|
||||||
languagesInput,
|
|
||||||
queriesInput,
|
|
||||||
packsInput,
|
|
||||||
dbLocation,
|
|
||||||
trapCachingEnabled,
|
|
||||||
debugMode,
|
|
||||||
debugArtifactName,
|
|
||||||
debugDatabaseName,
|
|
||||||
repository,
|
|
||||||
tempDir,
|
|
||||||
codeQL,
|
|
||||||
gitHubVersion,
|
|
||||||
logger,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
config = await loadConfig(
|
// Convince the type checker that inputs.configFile is defined.
|
||||||
languagesInput,
|
config = await loadConfig({ ...inputs, configFile: inputs.configFile });
|
||||||
queriesInput,
|
|
||||||
packsInput,
|
|
||||||
configFile,
|
|
||||||
dbLocation,
|
|
||||||
trapCachingEnabled,
|
|
||||||
debugMode,
|
|
||||||
debugArtifactName,
|
|
||||||
debugDatabaseName,
|
|
||||||
repository,
|
|
||||||
tempDir,
|
|
||||||
codeQL,
|
|
||||||
workspacePath,
|
|
||||||
gitHubVersion,
|
|
||||||
apiDetails,
|
|
||||||
logger,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the config so we can easily access it again in the future
|
// Save the config so we can easily access it again in the future
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,18 @@ import * as actionsUtil from "./actions-util";
|
||||||
import { GitHubApiDetails } from "./api-client";
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import * as apiClient from "./api-client";
|
import * as apiClient from "./api-client";
|
||||||
import { setCodeQL } from "./codeql";
|
import { setCodeQL } from "./codeql";
|
||||||
import { Config, defaultAugmentationProperties } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { uploadDatabases } from "./database-upload";
|
import { uploadDatabases } from "./database-upload";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { RepositoryNwo } from "./repository";
|
import { RepositoryNwo } from "./repository";
|
||||||
import {
|
import {
|
||||||
|
createTestConfig,
|
||||||
getRecordingLogger,
|
getRecordingLogger,
|
||||||
LoggedMessage,
|
LoggedMessage,
|
||||||
setupActionsVars,
|
setupActionsVars,
|
||||||
setupTests,
|
setupTests,
|
||||||
} from "./testing-utils";
|
} from "./testing-utils";
|
||||||
import {
|
import {
|
||||||
DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
GitHubVariant,
|
GitHubVariant,
|
||||||
HTTPError,
|
HTTPError,
|
||||||
initializeEnvironment,
|
initializeEnvironment,
|
||||||
|
|
@ -41,20 +40,10 @@ const testApiDetails: GitHubApiDetails = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function getTestConfig(tmpDir: string): Config {
|
function getTestConfig(tmpDir: string): Config {
|
||||||
return {
|
return createTestConfig({
|
||||||
languages: [Language.javascript],
|
languages: [Language.javascript],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: tmpDir,
|
|
||||||
codeQLCmd: "foo",
|
|
||||||
gitHubVersion: { type: GitHubVariant.DOTCOM },
|
|
||||||
dbLocation: tmpDir,
|
dbLocation: tmpDir,
|
||||||
debugMode: false,
|
});
|
||||||
debugArtifactName: DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: defaultAugmentationProperties,
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mockHttpRequests(databaseUploadStatusCode: number) {
|
async function mockHttpRequests(databaseUploadStatusCode: number) {
|
||||||
|
|
|
||||||
|
|
@ -265,29 +265,31 @@ async function run() {
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
|
|
||||||
config = await initConfig(
|
config = await initConfig({
|
||||||
getOptionalInput("languages"),
|
languagesInput: getOptionalInput("languages"),
|
||||||
getOptionalInput("queries"),
|
queriesInput: getOptionalInput("queries"),
|
||||||
getOptionalInput("packs"),
|
packsInput: getOptionalInput("packs"),
|
||||||
getOptionalInput("config-file"),
|
configFile: getOptionalInput("config-file"),
|
||||||
getOptionalInput("db-location"),
|
dbLocation: getOptionalInput("db-location"),
|
||||||
getOptionalInput("config"),
|
configInput: getOptionalInput("config"),
|
||||||
getTrapCachingEnabled(),
|
trapCachingEnabled: getTrapCachingEnabled(),
|
||||||
// Debug mode is enabled if:
|
// Debug mode is enabled if:
|
||||||
// - The `init` Action is passed `debug: true`.
|
// - The `init` Action is passed `debug: true`.
|
||||||
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
||||||
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
|
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
|
||||||
getOptionalInput("debug") === "true" || core.isDebug(),
|
debugMode: getOptionalInput("debug") === "true" || core.isDebug(),
|
||||||
getOptionalInput("debug-artifact-name") || DEFAULT_DEBUG_ARTIFACT_NAME,
|
debugArtifactName:
|
||||||
getOptionalInput("debug-database-name") || DEFAULT_DEBUG_DATABASE_NAME,
|
getOptionalInput("debug-artifact-name") || DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
repositoryNwo,
|
debugDatabaseName:
|
||||||
getTemporaryDirectory(),
|
getOptionalInput("debug-database-name") || DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
repository: repositoryNwo,
|
||||||
|
tempDir: getTemporaryDirectory(),
|
||||||
codeql,
|
codeql,
|
||||||
getRequiredEnvParam("GITHUB_WORKSPACE"),
|
workspacePath: getRequiredEnvParam("GITHUB_WORKSPACE"),
|
||||||
gitHubVersion,
|
githubVersion: gitHubVersion,
|
||||||
apiDetails,
|
apiDetails,
|
||||||
logger,
|
logger,
|
||||||
);
|
});
|
||||||
|
|
||||||
await checkInstallPython311(config.languages, codeql);
|
await checkInstallPython311(config.languages, codeql);
|
||||||
|
|
||||||
|
|
|
||||||
40
src/init.ts
40
src/init.ts
|
|
@ -10,7 +10,6 @@ import * as configUtils from "./config-utils";
|
||||||
import { CodeQLDefaultVersionInfo } from "./feature-flags";
|
import { CodeQLDefaultVersionInfo } from "./feature-flags";
|
||||||
import { Language, isScannedLanguage } from "./languages";
|
import { Language, isScannedLanguage } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { RepositoryNwo } from "./repository";
|
|
||||||
import { ToolsSource } from "./setup-codeql";
|
import { ToolsSource } from "./setup-codeql";
|
||||||
import { TracerConfig, getCombinedTracerConfig } from "./tracer-config";
|
import { TracerConfig, getCombinedTracerConfig } from "./tracer-config";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
@ -45,44 +44,11 @@ export async function initCodeQL(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function initConfig(
|
export async function initConfig(
|
||||||
languagesInput: string | undefined,
|
inputs: configUtils.InitConfigInputs,
|
||||||
queriesInput: string | undefined,
|
|
||||||
packsInput: string | undefined,
|
|
||||||
configFile: string | undefined,
|
|
||||||
dbLocation: string | undefined,
|
|
||||||
configInput: string | undefined,
|
|
||||||
trapCachingEnabled: boolean,
|
|
||||||
debugMode: boolean,
|
|
||||||
debugArtifactName: string,
|
|
||||||
debugDatabaseName: string,
|
|
||||||
repository: RepositoryNwo,
|
|
||||||
tempDir: string,
|
|
||||||
codeQL: CodeQL,
|
|
||||||
workspacePath: string,
|
|
||||||
gitHubVersion: util.GitHubVersion,
|
|
||||||
apiDetails: GitHubApiCombinedDetails,
|
|
||||||
logger: Logger,
|
|
||||||
): Promise<configUtils.Config> {
|
): Promise<configUtils.Config> {
|
||||||
|
const logger = inputs.logger;
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(
|
const config = await configUtils.initConfig(inputs);
|
||||||
languagesInput,
|
|
||||||
queriesInput,
|
|
||||||
packsInput,
|
|
||||||
configFile,
|
|
||||||
dbLocation,
|
|
||||||
configInput,
|
|
||||||
trapCachingEnabled,
|
|
||||||
debugMode,
|
|
||||||
debugArtifactName,
|
|
||||||
debugDatabaseName,
|
|
||||||
repository,
|
|
||||||
tempDir,
|
|
||||||
codeQL,
|
|
||||||
workspacePath,
|
|
||||||
gitHubVersion,
|
|
||||||
apiDetails,
|
|
||||||
logger,
|
|
||||||
);
|
|
||||||
printPathFiltersWarning(config, logger);
|
printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,21 @@ import * as sinon from "sinon";
|
||||||
|
|
||||||
import * as apiClient from "./api-client";
|
import * as apiClient from "./api-client";
|
||||||
import { GitHubApiDetails } from "./api-client";
|
import { GitHubApiDetails } from "./api-client";
|
||||||
import * as CodeQL from "./codeql";
|
import * as codeql from "./codeql";
|
||||||
|
import { Config } from "./config-utils";
|
||||||
import {
|
import {
|
||||||
CodeQLDefaultVersionInfo,
|
CodeQLDefaultVersionInfo,
|
||||||
Feature,
|
Feature,
|
||||||
FeatureEnablement,
|
FeatureEnablement,
|
||||||
} from "./feature-flags";
|
} from "./feature-flags";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { HTTPError } from "./util";
|
import {
|
||||||
|
DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
GitHubVariant,
|
||||||
|
GitHubVersion,
|
||||||
|
HTTPError,
|
||||||
|
} from "./util";
|
||||||
|
|
||||||
export const SAMPLE_DOTCOM_API_DETAILS = {
|
export const SAMPLE_DOTCOM_API_DETAILS = {
|
||||||
auth: "token",
|
auth: "token",
|
||||||
|
|
@ -73,7 +80,7 @@ export function setupTests(test: TestFn<any>) {
|
||||||
typedTest.beforeEach((t) => {
|
typedTest.beforeEach((t) => {
|
||||||
// Set an empty CodeQL object so that all method calls will fail
|
// Set an empty CodeQL object so that all method calls will fail
|
||||||
// unless the test explicitly sets one up.
|
// unless the test explicitly sets one up.
|
||||||
CodeQL.setCodeQL({});
|
codeql.setCodeQL({});
|
||||||
|
|
||||||
// Replace stdout and stderr so we can record output during tests
|
// Replace stdout and stderr so we can record output during tests
|
||||||
t.context.testOutput = "";
|
t.context.testOutput = "";
|
||||||
|
|
@ -214,7 +221,7 @@ export function mockLanguagesInRepo(languages: string[]) {
|
||||||
export const makeVersionInfo = (
|
export const makeVersionInfo = (
|
||||||
version: string,
|
version: string,
|
||||||
features?: { [name: string]: boolean },
|
features?: { [name: string]: boolean },
|
||||||
): CodeQL.VersionInfo => ({
|
): codeql.VersionInfo => ({
|
||||||
version,
|
version,
|
||||||
features,
|
features,
|
||||||
});
|
});
|
||||||
|
|
@ -227,7 +234,7 @@ export function mockCodeQLVersion(
|
||||||
async getVersion() {
|
async getVersion() {
|
||||||
return makeVersionInfo(version, features);
|
return makeVersionInfo(version, features);
|
||||||
},
|
},
|
||||||
} as CodeQL.CodeQL;
|
} as codeql.CodeQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -291,3 +298,29 @@ export function mockBundleDownloadApi({
|
||||||
|
|
||||||
return `${baseUrl}${relativeUrl}`;
|
return `${baseUrl}${relativeUrl}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createTestConfig(overrides: Partial<Config>): Config {
|
||||||
|
return Object.assign(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
languages: [],
|
||||||
|
originalUserInput: {},
|
||||||
|
tempDir: "",
|
||||||
|
codeQLCmd: "",
|
||||||
|
gitHubVersion: {
|
||||||
|
type: GitHubVariant.DOTCOM,
|
||||||
|
} as GitHubVersion,
|
||||||
|
dbLocation: "",
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
augmentationProperties: {
|
||||||
|
packsInputCombines: false,
|
||||||
|
queriesInputCombines: false,
|
||||||
|
},
|
||||||
|
trapCaches: {},
|
||||||
|
trapCacheDownloadTime: 0,
|
||||||
|
},
|
||||||
|
overrides,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,27 +5,18 @@ import test from "ava";
|
||||||
|
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { makeVersionInfo, setupTests } from "./testing-utils";
|
import { createTestConfig, makeVersionInfo, setupTests } from "./testing-utils";
|
||||||
import { getCombinedTracerConfig } from "./tracer-config";
|
import { getCombinedTracerConfig } from "./tracer-config";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
function getTestConfig(tmpDir: string): configUtils.Config {
|
function getTestConfig(tempDir: string): configUtils.Config {
|
||||||
return {
|
return createTestConfig({
|
||||||
languages: [Language.java],
|
languages: [Language.java],
|
||||||
originalUserInput: {},
|
tempDir,
|
||||||
tempDir: tmpDir,
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
codeQLCmd: "",
|
});
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: configUtils.defaultAugmentationProperties,
|
|
||||||
trapCaches: {},
|
|
||||||
trapCacheDownloadTime: 0,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
test("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ import {
|
||||||
getTrapCachingExtractorConfigArgsForLang,
|
getTrapCachingExtractorConfigArgsForLang,
|
||||||
} from "./codeql";
|
} from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
import { Config } from "./config-utils";
|
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import {
|
import {
|
||||||
|
createTestConfig,
|
||||||
getRecordingLogger,
|
getRecordingLogger,
|
||||||
makeVersionInfo,
|
makeVersionInfo,
|
||||||
setupTests,
|
setupTests,
|
||||||
|
|
@ -69,49 +69,23 @@ const stubCodeql = setCodeQL({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const testConfigWithoutTmpDir: Config = {
|
const testConfigWithoutTmpDir = createTestConfig({
|
||||||
languages: [Language.javascript, Language.cpp],
|
languages: [Language.javascript, Language.cpp],
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: "",
|
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
} as util.GitHubVersion,
|
|
||||||
dbLocation: "",
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {
|
trapCaches: {
|
||||||
javascript: "/some/cache/dir",
|
javascript: "/some/cache/dir",
|
||||||
},
|
},
|
||||||
trapCacheDownloadTime: 0,
|
});
|
||||||
};
|
|
||||||
|
|
||||||
function getTestConfigWithTempDir(tmpDir: string): configUtils.Config {
|
function getTestConfigWithTempDir(tempDir: string): configUtils.Config {
|
||||||
return {
|
return createTestConfig({
|
||||||
languages: [Language.javascript, Language.ruby],
|
languages: [Language.javascript, Language.ruby],
|
||||||
originalUserInput: {},
|
tempDir,
|
||||||
tempDir: tmpDir,
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM } as util.GitHubVersion,
|
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
|
||||||
debugMode: false,
|
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
|
||||||
augmentationProperties: {
|
|
||||||
packsInputCombines: false,
|
|
||||||
queriesInputCombines: false,
|
|
||||||
},
|
|
||||||
trapCaches: {
|
trapCaches: {
|
||||||
javascript: path.resolve(tmpDir, "jsCache"),
|
javascript: path.resolve(tempDir, "jsCache"),
|
||||||
ruby: path.resolve(tmpDir, "rubyCache"),
|
ruby: path.resolve(tempDir, "rubyCache"),
|
||||||
},
|
},
|
||||||
trapCacheDownloadTime: 0,
|
});
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test("check flags for JS, analyzing default branch", async (t) => {
|
test("check flags for JS, analyzing default branch", async (t) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue