Merge branch 'main' into always_log_error
This commit is contained in:
commit
ac66bbe1fe
6 changed files with 54 additions and 16 deletions
22
lib/config-utils.js
generated
22
lib/config-utils.js
generated
|
|
@ -328,6 +328,9 @@ async function getLanguagesInRepo() {
|
||||||
* The result is obtained from the action input parameter 'languages' if that
|
* The result is obtained from the action input parameter 'languages' if that
|
||||||
* has been set, otherwise it is deduced as all languages in the repo that
|
* has been set, otherwise it is deduced as all languages in the repo that
|
||||||
* can be analysed.
|
* can be analysed.
|
||||||
|
*
|
||||||
|
* If no languages could be detected from either the workflow or the repository
|
||||||
|
* then throw an error.
|
||||||
*/
|
*/
|
||||||
async function getLanguages() {
|
async function getLanguages() {
|
||||||
// Obtain from action input 'languages' if set
|
// Obtain from action input 'languages' if set
|
||||||
|
|
@ -341,6 +344,12 @@ async function getLanguages() {
|
||||||
languages = await getLanguagesInRepo();
|
languages = await getLanguagesInRepo();
|
||||||
core.info("Automatically detected languages: " + JSON.stringify(languages));
|
core.info("Automatically detected languages: " + JSON.stringify(languages));
|
||||||
}
|
}
|
||||||
|
// If the languages parameter was not given and no languages were
|
||||||
|
// detected then fail here as this is a workflow configuration error.
|
||||||
|
if (languages.length === 0) {
|
||||||
|
throw new Error("Did not detect any languages to analyze. " +
|
||||||
|
"Please update input in workflow or check that GitHub detects the correct languages in your repository.");
|
||||||
|
}
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
@ -384,11 +393,6 @@ async function loadConfig(configFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languages = await getLanguages();
|
const languages = await getLanguages();
|
||||||
// If the languages parameter was not given and no languages were
|
|
||||||
// detected then fail here as this is a workflow configuration error.
|
|
||||||
if (languages.length === 0) {
|
|
||||||
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
|
|
||||||
}
|
|
||||||
const queries = {};
|
const queries = {};
|
||||||
const pathsIgnore = [];
|
const pathsIgnore = [];
|
||||||
const paths = [];
|
const paths = [];
|
||||||
|
|
@ -435,6 +439,14 @@ async function loadConfig(configFile) {
|
||||||
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile));
|
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// The list of queries should not be empty for any language. If it is then
|
||||||
|
// it is a user configuration error.
|
||||||
|
for (const language of languages) {
|
||||||
|
if (queries[language] === undefined || queries[language].length === 0) {
|
||||||
|
throw new Error(`Did not detect any queries to run for ${language}. ` +
|
||||||
|
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
10
lib/config-utils.test.js
generated
10
lib/config-utils.test.js
generated
|
|
@ -200,7 +200,9 @@ ava_1.default("default queries are used", async (t) => {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
'javascript': {},
|
'javascript': {
|
||||||
|
'foo.ql': {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
noDeclaredLanguage: {},
|
noDeclaredLanguage: {},
|
||||||
multipleDeclaredLanguages: {},
|
multipleDeclaredLanguages: {},
|
||||||
|
|
@ -231,7 +233,11 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
||||||
CodeQL.setCodeQL({
|
CodeQL.setCodeQL({
|
||||||
resolveQueries: async function () {
|
resolveQueries: async function () {
|
||||||
return {
|
return {
|
||||||
byLanguage: {},
|
byLanguage: {
|
||||||
|
'javascript': {
|
||||||
|
'foo.ql': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
noDeclaredLanguage: {},
|
noDeclaredLanguage: {},
|
||||||
multipleDeclaredLanguages: {},
|
multipleDeclaredLanguages: {},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -224,7 +224,9 @@ test("default queries are used", async t => {
|
||||||
resolveQueriesArgs.push({queries, extraSearchPath});
|
resolveQueriesArgs.push({queries, extraSearchPath});
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
'javascript': {},
|
'javascript': {
|
||||||
|
'foo.ql': {},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
noDeclaredLanguage: {},
|
noDeclaredLanguage: {},
|
||||||
multipleDeclaredLanguages: {},
|
multipleDeclaredLanguages: {},
|
||||||
|
|
@ -262,7 +264,11 @@ test("API client used when reading remote config", async t => {
|
||||||
CodeQL.setCodeQL({
|
CodeQL.setCodeQL({
|
||||||
resolveQueries: async function() {
|
resolveQueries: async function() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {},
|
byLanguage: {
|
||||||
|
'javascript': {
|
||||||
|
'foo.ql': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
noDeclaredLanguage: {},
|
noDeclaredLanguage: {},
|
||||||
multipleDeclaredLanguages: {},
|
multipleDeclaredLanguages: {},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,9 @@ async function getLanguagesInRepo(): Promise<string[]> {
|
||||||
* The result is obtained from the action input parameter 'languages' if that
|
* The result is obtained from the action input parameter 'languages' if that
|
||||||
* has been set, otherwise it is deduced as all languages in the repo that
|
* has been set, otherwise it is deduced as all languages in the repo that
|
||||||
* can be analysed.
|
* can be analysed.
|
||||||
|
*
|
||||||
|
* If no languages could be detected from either the workflow or the repository
|
||||||
|
* then throw an error.
|
||||||
*/
|
*/
|
||||||
async function getLanguages(): Promise<string[]> {
|
async function getLanguages(): Promise<string[]> {
|
||||||
|
|
||||||
|
|
@ -468,6 +471,13 @@ async function getLanguages(): Promise<string[]> {
|
||||||
core.info("Automatically detected languages: " + JSON.stringify(languages));
|
core.info("Automatically detected languages: " + JSON.stringify(languages));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the languages parameter was not given and no languages were
|
||||||
|
// detected then fail here as this is a workflow configuration error.
|
||||||
|
if (languages.length === 0) {
|
||||||
|
throw new Error("Did not detect any languages to analyze. " +
|
||||||
|
"Please update input in workflow or check that GitHub detects the correct languages in your repository.");
|
||||||
|
}
|
||||||
|
|
||||||
return languages;
|
return languages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -515,11 +525,6 @@ async function loadConfig(configFile: string): Promise<Config> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const languages = await getLanguages();
|
const languages = await getLanguages();
|
||||||
// If the languages parameter was not given and no languages were
|
|
||||||
// detected then fail here as this is a workflow configuration error.
|
|
||||||
if (languages.length === 0) {
|
|
||||||
throw new Error("Did not detect any languages to analyze. Please update input in workflow.");
|
|
||||||
}
|
|
||||||
|
|
||||||
const queries = {};
|
const queries = {};
|
||||||
const pathsIgnore: string[] = [];
|
const pathsIgnore: string[] = [];
|
||||||
|
|
@ -572,6 +577,15 @@ async function loadConfig(configFile: string): Promise<Config> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The list of queries should not be empty for any language. If it is then
|
||||||
|
// it is a user configuration error.
|
||||||
|
for (const language of languages) {
|
||||||
|
if (queries[language] === undefined || queries[language].length === 0) {
|
||||||
|
throw new Error(`Did not detect any queries to run for ${language}. ` +
|
||||||
|
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue