Remove dependence of GITHUB_REPOSITORY env var
This commit is contained in:
parent
688df282cd
commit
39b361ed69
15 changed files with 108 additions and 86 deletions
61
lib/config-utils.js
generated
61
lib/config-utils.js
generated
|
|
@ -292,34 +292,25 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
|
||||||
/**
|
/**
|
||||||
* Gets the set of languages in the current repository
|
* Gets the set of languages in the current repository
|
||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(githubAuth, githubUrl, logger) {
|
async function getLanguagesInRepo(repository, githubAuth, githubUrl, logger) {
|
||||||
var _a;
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
let repo_nwo = (_a = process.env['GITHUB_REPOSITORY']) === null || _a === void 0 ? void 0 : _a.split("/");
|
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
|
||||||
if (repo_nwo) {
|
owner: repository.owner,
|
||||||
let owner = repo_nwo[0];
|
repo: repository.repo
|
||||||
let repo = repo_nwo[1];
|
});
|
||||||
logger.debug(`GitHub repo ${owner} ${repo}`);
|
logger.debug("Languages API response: " + JSON.stringify(response));
|
||||||
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
|
// The GitHub API is going to return languages in order of popularity,
|
||||||
owner,
|
// When we pick a language to autobuild we want to pick the most popular traced language
|
||||||
repo
|
// Since sets in javascript maintain insertion order, using a set here and then splatting it
|
||||||
});
|
// into an array gives us an array of languages ordered by popularity
|
||||||
logger.debug("Languages API response: " + JSON.stringify(response));
|
let languages = new Set();
|
||||||
// The GitHub API is going to return languages in order of popularity,
|
for (let lang of Object.keys(response.data)) {
|
||||||
// When we pick a language to autobuild we want to pick the most popular traced language
|
let parsedLang = languages_1.parseLanguage(lang);
|
||||||
// Since sets in javascript maintain insertion order, using a set here and then splatting it
|
if (parsedLang !== undefined) {
|
||||||
// into an array gives us an array of languages ordered by popularity
|
languages.add(parsedLang);
|
||||||
let languages = new Set();
|
|
||||||
for (let lang of Object.keys(response.data)) {
|
|
||||||
let parsedLang = languages_1.parseLanguage(lang);
|
|
||||||
if (parsedLang !== undefined) {
|
|
||||||
languages.add(parsedLang);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [...languages];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
return [...languages];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the languages to analyse.
|
* Get the languages to analyse.
|
||||||
|
|
@ -331,7 +322,7 @@ async function getLanguagesInRepo(githubAuth, githubUrl, logger) {
|
||||||
* If no languages could be detected from either the workflow or the repository
|
* If no languages could be detected from either the workflow or the repository
|
||||||
* then throw an error.
|
* then throw an error.
|
||||||
*/
|
*/
|
||||||
async function getLanguages(languagesInput, githubAuth, githubUrl, logger) {
|
async function getLanguages(languagesInput, repository, githubAuth, githubUrl, logger) {
|
||||||
// Obtain from action input 'languages' if set
|
// Obtain from action input 'languages' if set
|
||||||
let languages = (languagesInput || "")
|
let languages = (languagesInput || "")
|
||||||
.split(',')
|
.split(',')
|
||||||
|
|
@ -340,7 +331,7 @@ async function getLanguages(languagesInput, githubAuth, githubUrl, logger) {
|
||||||
logger.info("Languages from configuration: " + JSON.stringify(languages));
|
logger.info("Languages from configuration: " + JSON.stringify(languages));
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain languages as all languages in the repo that can be analysed
|
||||||
languages = await getLanguagesInRepo(githubAuth, githubUrl, logger);
|
languages = await getLanguagesInRepo(repository, githubAuth, githubUrl, logger);
|
||||||
logger.info("Automatically detected languages: " + JSON.stringify(languages));
|
logger.info("Automatically detected languages: " + JSON.stringify(languages));
|
||||||
}
|
}
|
||||||
// If the languages parameter was not given and no languages were
|
// If the languages parameter was not given and no languages were
|
||||||
|
|
@ -377,8 +368,8 @@ async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap
|
||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
const languages = await getLanguages(languagesInput, githubAuth, githubUrl, logger);
|
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
|
|
@ -399,7 +390,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, configFile, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
async function loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, 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
|
||||||
|
|
@ -419,7 +410,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, tempDir, too
|
||||||
throw new Error(getNameInvalid(configFile));
|
throw new Error(getNameInvalid(configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languages = await getLanguages(languagesInput, githubAuth, githubUrl, logger);
|
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
const pathsIgnore = [];
|
const pathsIgnore = [];
|
||||||
const paths = [];
|
const paths = [];
|
||||||
|
|
@ -496,15 +487,15 @@ async function loadConfig(languagesInput, queriesInput, configFile, tempDir, too
|
||||||
* 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, configFile, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug('No configuration file was provided');
|
logger.debug('No configuration file was provided');
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, configFile, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
config = await loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, 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
|
||||||
await saveConfig(config, logger);
|
await saveConfig(config, logger);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
36
lib/config-utils.test.js
generated
36
lib/config-utils.test.js
generated
|
|
@ -58,8 +58,8 @@ ava_1.default("load empty config", async (t) => {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
ava_1.default("loading config saves config", async (t) => {
|
||||||
|
|
@ -78,7 +78,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// Sanity check that getConfig throws before we have called initConfig
|
// Sanity check that getConfig throws before we have called initConfig
|
||||||
await t.throwsAsync(() => configUtils.getConfig(tmpDir, logger));
|
await t.throwsAsync(() => configUtils.getConfig(tmpDir, logger));
|
||||||
const config1 = await configUtils.initConfig('javascript,python', undefined, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logger);
|
const config1 = await configUtils.initConfig('javascript,python', undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', 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(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
|
|
@ -89,7 +89,7 @@ ava_1.default("loading config saves config", async (t) => {
|
||||||
ava_1.default("load input outside of workspace", async (t) => {
|
ava_1.default("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, '../input', tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(undefined, undefined, '../input', { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -102,7 +102,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
||||||
// 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, configFile, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(undefined, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -116,7 +116,7 @@ ava_1.default("load non-existent input", async (t) => {
|
||||||
const configFile = 'input';
|
const configFile = 'input';
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -172,7 +172,7 @@ ava_1.default("load non-empty input", async (t) => {
|
||||||
const languages = 'javascript';
|
const languages = 'javascript';
|
||||||
const configFile = 'input';
|
const configFile = 'input';
|
||||||
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
const actualConfig = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
|
|
@ -209,7 +209,7 @@ ava_1.default("default queries are used", async (t) => {
|
||||||
const languages = 'javascript';
|
const languages = 'javascript';
|
||||||
const configFile = 'input';
|
const configFile = 'input';
|
||||||
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
fs.writeFileSync(path.join(tmpDir, configFile), inputFileContents, 'utf8');
|
||||||
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
// Check resolve queries was called correctly
|
// Check resolve queries was called correctly
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries, ['javascript-code-scanning.qls']);
|
t.deepEqual(resolveQueriesArgs[0].queries, ['javascript-code-scanning.qls']);
|
||||||
|
|
@ -244,7 +244,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = 'javascript';
|
const languages = 'javascript';
|
||||||
const config = await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
const config = await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries
|
// It'll be called once for the default queries
|
||||||
// and once for `./foo` from the config file.
|
// and once for `./foo` from the config file.
|
||||||
|
|
@ -288,7 +288,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = 'javascript';
|
const languages = 'javascript';
|
||||||
const config = await configUtils.initConfig(languages, queries, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
const config = await configUtils.initConfig(languages, queries, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries and once for `./override`,
|
// It'll be called once for the default queries and once for `./override`,
|
||||||
// but won't be called for './foo' from the config file.
|
// but won't be called for './foo' from the config file.
|
||||||
|
|
@ -325,7 +325,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = 'javascript';
|
const languages = 'javascript';
|
||||||
const config = await configUtils.initConfig(languages, queries, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
const config = await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
// Check resolveQueries was called correctly:
|
// Check resolveQueries was called correctly:
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// and then once for each of the two queries from the workflow
|
// and then once for each of the two queries from the workflow
|
||||||
|
|
@ -359,7 +359,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, queries, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
t.fail('initConfig did not throw error');
|
t.fail('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -402,7 +402,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, 'foo/bar/dev'), { recursive: true });
|
fs.mkdirSync(path.join(tmpDir, '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 languages = 'javascript';
|
||||||
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -412,7 +412,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
||||||
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, repoReference, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -428,7 +428,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
||||||
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, repoReference, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -440,7 +440,7 @@ ava_1.default("No detected languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(undefined, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -452,7 +452,7 @@ ava_1.default("Unknown languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = 'ruby,english';
|
const languages = 'ruby,english';
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, undefined, undefined, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
throw new Error('initConfig did not throw error');
|
throw new Error('initConfig did not throw error');
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|
@ -477,7 +477,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, 'utf8');
|
fs.writeFileSync(inputFile, inputFileContents, 'utf8');
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, configFile, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
await configUtils.initConfig(languages, undefined, configFile, { owner: 'github', repo: 'example ' }, tmpDir, tmpDir, codeQL, tmpDir, 'token', 'https://github.example.com', logging_1.getRunnerLogger());
|
||||||
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
3
lib/init-action.js
generated
3
lib/init-action.js
generated
|
|
@ -10,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const init_1 = require("./init");
|
const init_1 = require("./init");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
async function sendSuccessStatusReport(startedAt, config) {
|
async function sendSuccessStatusReport(startedAt, config) {
|
||||||
const statusReportBase = await util.createStatusReportBase('init', 'success', startedAt);
|
const statusReportBase = await util.createStatusReportBase('init', 'success', startedAt);
|
||||||
|
|
@ -41,7 +42,7 @@ async function run() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
codeql = await init_1.initCodeQL(core.getInput('tools'), core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), 'actions', logger);
|
codeql = await init_1.initCodeQL(core.getInput('tools'), core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), 'actions', logger);
|
||||||
config = await init_1.initConfig(core.getInput('languages'), core.getInput('queries'), core.getInput('config-file'), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), codeql, util.getRequiredEnvParam('GITHUB_WORKSPACE'), core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), logger);
|
config = await init_1.initConfig(core.getInput('languages'), core.getInput('queries'), core.getInput('config-file'), repository_1.parseRepositoryNwo(util.getRequiredEnvParam('GITHUB_REPOSITORY')), util.getRequiredEnvParam('RUNNER_TEMP'), util.getRequiredEnvParam('RUNNER_TOOL_CACHE'), codeql, util.getRequiredEnvParam('GITHUB_WORKSPACE'), core.getInput('token'), util.getRequiredEnvParam('GITHUB_SERVER_URL'), logger);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.setFailed(e.message);
|
core.setFailed(e.message);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAItC,iCAAyD;AACzD,uCAA6C;AAC7C,6CAA+B;AAkB/B,KAAK,UAAU,uBAAuB,CAAC,SAAe,EAAE,MAA0B;IAChF,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAEzF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC7C,MAAM,iBAAiB,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/D,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/E,MA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toolsDir, m
|
||||||
return codeql;
|
return codeql;
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
logger.startGroup('Load language configuration');
|
logger.startGroup('Load language configuration');
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.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,oDAAsC;AACtC,uCAAyB;AACzB,2CAA6B;AAE7B,gEAAkD;AAClD,qCAA+C;AAC/C,4DAA8C;AAE9C,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAAkB,EAClB,SAAiB,EACjB,OAAe,EACf,QAAgB,EAChB,IAAe,EACf,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,oBAAW,CAC9B,SAAS,EACT,UAAU,EACV,SAAS,EACT,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,CAAC,CAAC;IACV,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OA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Y,EACZ;gBACE,gBAAgB;gBAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC;aAC7E,EACD,EAAE,GAAG,EAAE,EAAE,4BAA4B,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;SACjE;KACF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAvCD,0BAuCC"}
|
||||||
3
lib/runner.js
generated
3
lib/runner.js
generated
|
|
@ -57,6 +57,7 @@ const logger = logging_1.getRunnerLogger();
|
||||||
program
|
program
|
||||||
.command('init')
|
.command('init')
|
||||||
.description('Initializes CodeQL')
|
.description('Initializes CodeQL')
|
||||||
|
.requiredOption('--repository <repository>', 'Repository name')
|
||||||
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
||||||
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
||||||
.option('--languages <languages>', 'Comma-separated list of languages to analyze. Defaults to trying to detect languages from the repo.')
|
.option('--languages <languages>', 'Comma-separated list of languages to analyze. Defaults to trying to detect languages from the repo.')
|
||||||
|
|
@ -80,7 +81,7 @@ program
|
||||||
else {
|
else {
|
||||||
codeql = await init_1.initCodeQL(undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, 'runner', logger);
|
codeql = await init_1.initCodeQL(undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, 'runner', logger);
|
||||||
}
|
}
|
||||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
|
||||||
const tracerConfig = await init_1.runInit(codeql, config);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -59,6 +59,7 @@ test("load empty config", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -70,6 +71,7 @@ test("load empty config", async t => {
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(
|
t.deepEqual(config, await configUtils.getDefaultConfig(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -105,6 +107,7 @@ test("loading config saves config", async t => {
|
||||||
'javascript,python',
|
'javascript,python',
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -129,6 +132,7 @@ test("load input outside of workspace", async t => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
'../input',
|
'../input',
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -153,6 +157,7 @@ test("load non-local input with invalid repo syntax", async t => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -178,6 +183,7 @@ test("load non-existent input", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -249,6 +255,7 @@ test("load non-empty input", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -303,6 +310,7 @@ test("default queries are used", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -355,6 +363,7 @@ test("Queries can be specified in config file", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -418,6 +427,7 @@ test("Queries from config file can be overridden in workflow file", async t => {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -472,6 +482,7 @@ test("Multiple queries can be specified in workflow file, no config file require
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -521,6 +532,7 @@ test("Invalid queries in workflow file handled correctly", async t => {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -578,6 +590,7 @@ test("API client used when reading remote config", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -600,6 +613,7 @@ test("Remote config handles the case where a directory is provided", async t =>
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
repoReference,
|
repoReference,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -627,6 +641,7 @@ test("Invalid format of remote config handled correctly", async t => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
repoReference,
|
repoReference,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -650,6 +665,7 @@ test("No detected languages", async t => {
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -673,6 +689,7 @@ test("Unknown languages", async t => {
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getCachedCodeQL(),
|
getCachedCodeQL(),
|
||||||
|
|
@ -714,6 +731,7 @@ function doInvalidInputTest(
|
||||||
languages,
|
languages,
|
||||||
undefined,
|
undefined,
|
||||||
configFile,
|
configFile,
|
||||||
|
{ owner: 'github', repo: 'example '},
|
||||||
tmpDir,
|
tmpDir,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { CodeQL, ResolveQueriesOutput } from './codeql';
|
||||||
import * as externalQueries from "./external-queries";
|
import * as externalQueries from "./external-queries";
|
||||||
import { Language, parseLanguage } from "./languages";
|
import { Language, parseLanguage } from "./languages";
|
||||||
import { Logger } from './logging';
|
import { Logger } from './logging';
|
||||||
|
import { RepositoryNwo } from './repository';
|
||||||
|
|
||||||
// Property names from the user-supplied config file.
|
// Property names from the user-supplied config file.
|
||||||
const NAME_PROPERTY = 'name';
|
const NAME_PROPERTY = 'name';
|
||||||
|
|
@ -450,38 +451,31 @@ export function getUnknownLanguagesError(languages: string[]): string {
|
||||||
* Gets the set of languages in the current repository
|
* Gets the set of languages in the current repository
|
||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(
|
async function getLanguagesInRepo(
|
||||||
|
repository: RepositoryNwo,
|
||||||
githubAuth: string,
|
githubAuth: string,
|
||||||
githubUrl: string,
|
githubUrl: string,
|
||||||
logger: Logger): Promise<Language[]> {
|
logger: Logger): Promise<Language[]> {
|
||||||
|
|
||||||
let repo_nwo = process.env['GITHUB_REPOSITORY']?.split("/");
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
if (repo_nwo) {
|
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
|
||||||
let owner = repo_nwo[0];
|
owner: repository.owner,
|
||||||
let repo = repo_nwo[1];
|
repo: repository.repo
|
||||||
|
});
|
||||||
|
|
||||||
logger.debug(`GitHub repo ${owner} ${repo}`);
|
logger.debug("Languages API response: " + JSON.stringify(response));
|
||||||
const response = await api.getApiClient(githubAuth, githubUrl, true).repos.listLanguages({
|
|
||||||
owner,
|
|
||||||
repo
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.debug("Languages API response: " + JSON.stringify(response));
|
// The GitHub API is going to return languages in order of popularity,
|
||||||
|
// When we pick a language to autobuild we want to pick the most popular traced language
|
||||||
// The GitHub API is going to return languages in order of popularity,
|
// Since sets in javascript maintain insertion order, using a set here and then splatting it
|
||||||
// When we pick a language to autobuild we want to pick the most popular traced language
|
// into an array gives us an array of languages ordered by popularity
|
||||||
// Since sets in javascript maintain insertion order, using a set here and then splatting it
|
let languages: Set<Language> = new Set();
|
||||||
// into an array gives us an array of languages ordered by popularity
|
for (let lang of Object.keys(response.data)) {
|
||||||
let languages: Set<Language> = new Set();
|
let parsedLang = parseLanguage(lang);
|
||||||
for (let lang of Object.keys(response.data)) {
|
if (parsedLang !== undefined) {
|
||||||
let parsedLang = parseLanguage(lang);
|
languages.add(parsedLang);
|
||||||
if (parsedLang !== undefined) {
|
|
||||||
languages.add(parsedLang);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [...languages];
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
return [...languages];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -496,6 +490,7 @@ async function getLanguagesInRepo(
|
||||||
*/
|
*/
|
||||||
async function getLanguages(
|
async function getLanguages(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
|
repository: RepositoryNwo,
|
||||||
githubAuth: string,
|
githubAuth: string,
|
||||||
githubUrl: string,
|
githubUrl: string,
|
||||||
logger: Logger): Promise<Language[]> {
|
logger: Logger): Promise<Language[]> {
|
||||||
|
|
@ -510,6 +505,7 @@ async function getLanguages(
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain languages as all languages in the repo that can be analysed
|
||||||
languages = await getLanguagesInRepo(
|
languages = await getLanguagesInRepo(
|
||||||
|
repository,
|
||||||
githubAuth,
|
githubAuth,
|
||||||
githubUrl,
|
githubUrl,
|
||||||
logger);
|
logger);
|
||||||
|
|
@ -564,6 +560,7 @@ async function addQueriesFromWorkflow(
|
||||||
export async function getDefaultConfig(
|
export async function getDefaultConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
|
repository: RepositoryNwo,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
|
|
@ -574,6 +571,7 @@ export async function getDefaultConfig(
|
||||||
|
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
|
repository,
|
||||||
githubAuth,
|
githubAuth,
|
||||||
githubUrl,
|
githubUrl,
|
||||||
logger);
|
logger);
|
||||||
|
|
@ -602,6 +600,7 @@ async function loadConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
configFile: string,
|
configFile: string,
|
||||||
|
repository: RepositoryNwo,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
|
|
@ -636,6 +635,7 @@ async function loadConfig(
|
||||||
|
|
||||||
const languages = await getLanguages(
|
const languages = await getLanguages(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
|
repository,
|
||||||
githubAuth,
|
githubAuth,
|
||||||
githubUrl,
|
githubUrl,
|
||||||
logger);
|
logger);
|
||||||
|
|
@ -734,6 +734,7 @@ export async function initConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
configFile: string | undefined,
|
configFile: string | undefined,
|
||||||
|
repository: RepositoryNwo,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
|
|
@ -750,6 +751,7 @@ export async function initConfig(
|
||||||
config = await getDefaultConfig(
|
config = await getDefaultConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
|
repository,
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
@ -762,6 +764,7 @@ export async function initConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
configFile,
|
configFile,
|
||||||
|
repository,
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { CodeQL } from './codeql';
|
||||||
import * as configUtils from './config-utils';
|
import * as configUtils from './config-utils';
|
||||||
import { initCodeQL, initConfig, runInit } from './init';
|
import { initCodeQL, initConfig, runInit } from './init';
|
||||||
import { getActionsLogger } from './logging';
|
import { getActionsLogger } from './logging';
|
||||||
|
import { parseRepositoryNwo } from './repository';
|
||||||
import * as util from './util';
|
import * as util from './util';
|
||||||
|
|
||||||
interface InitSuccessStatusReport extends util.StatusReportBase {
|
interface InitSuccessStatusReport extends util.StatusReportBase {
|
||||||
|
|
@ -69,6 +70,7 @@ async function run() {
|
||||||
core.getInput('languages'),
|
core.getInput('languages'),
|
||||||
core.getInput('queries'),
|
core.getInput('queries'),
|
||||||
core.getInput('config-file'),
|
core.getInput('config-file'),
|
||||||
|
parseRepositoryNwo(util.getRequiredEnvParam('GITHUB_REPOSITORY')),
|
||||||
util.getRequiredEnvParam('RUNNER_TEMP'),
|
util.getRequiredEnvParam('RUNNER_TEMP'),
|
||||||
util.getRequiredEnvParam('RUNNER_TOOL_CACHE'),
|
util.getRequiredEnvParam('RUNNER_TOOL_CACHE'),
|
||||||
codeql,
|
codeql,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import * as analysisPaths from './analysis-paths';
|
||||||
import { CodeQL, setupCodeQL } from './codeql';
|
import { CodeQL, setupCodeQL } from './codeql';
|
||||||
import * as configUtils from './config-utils';
|
import * as configUtils from './config-utils';
|
||||||
import { Logger } from './logging';
|
import { Logger } from './logging';
|
||||||
|
import { RepositoryNwo } from './repository';
|
||||||
import { getCombinedTracerConfig, TracerConfig } from './tracer-config';
|
import { getCombinedTracerConfig, TracerConfig } from './tracer-config';
|
||||||
import * as util from './util';
|
import * as util from './util';
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ export async function initConfig(
|
||||||
languagesInput: string | undefined,
|
languagesInput: string | undefined,
|
||||||
queriesInput: string | undefined,
|
queriesInput: string | undefined,
|
||||||
configFile: string | undefined,
|
configFile: string | undefined,
|
||||||
|
repository: RepositoryNwo,
|
||||||
tempDir: string,
|
tempDir: string,
|
||||||
toolCacheDir: string,
|
toolCacheDir: string,
|
||||||
codeQL: CodeQL,
|
codeQL: CodeQL,
|
||||||
|
|
@ -49,6 +51,7 @@ export async function initConfig(
|
||||||
languagesInput,
|
languagesInput,
|
||||||
queriesInput,
|
queriesInput,
|
||||||
configFile,
|
configFile,
|
||||||
|
repository,
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ interface InitArgs {
|
||||||
tempDir: string | undefined;
|
tempDir: string | undefined;
|
||||||
toolsDir: string | undefined;
|
toolsDir: string | undefined;
|
||||||
checkoutPath: string | undefined;
|
checkoutPath: string | undefined;
|
||||||
|
repository: string;
|
||||||
githubUrl: string;
|
githubUrl: string;
|
||||||
githubAuth: string;
|
githubAuth: string;
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +71,7 @@ interface InitArgs {
|
||||||
program
|
program
|
||||||
.command('init')
|
.command('init')
|
||||||
.description('Initializes CodeQL')
|
.description('Initializes CodeQL')
|
||||||
|
.requiredOption('--repository <repository>', 'Repository name')
|
||||||
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
.requiredOption('--github-url <url>', 'URL of GitHub instance')
|
||||||
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
.requiredOption('--github-auth <auth>', 'GitHub Apps token, or of the form "username:token" if using a personal access token')
|
||||||
.option('--languages <languages>', 'Comma-separated list of languages to analyze. Defaults to trying to detect languages from the repo.')
|
.option('--languages <languages>', 'Comma-separated list of languages to analyze. Defaults to trying to detect languages from the repo.')
|
||||||
|
|
@ -106,6 +108,7 @@ program
|
||||||
cmd.languages,
|
cmd.languages,
|
||||||
cmd.queries,
|
cmd.queries,
|
||||||
cmd.configFile,
|
cmd.configFile,
|
||||||
|
parseRepositoryNwo(cmd.repository),
|
||||||
tempDir,
|
tempDir,
|
||||||
toolsDir,
|
toolsDir,
|
||||||
codeql,
|
codeql,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue