Add the feature to bypass the toolcache for kotlin and swift

This works by moving the logic to check for toolcache bypass out of
creating the codeql instance. The logic now _may_ perform an API request
in order to check what languages are in the repository. This check is
redundant because the same call is being made later in the action when
the actual list of languages is calculated.
This commit is contained in:
Andrew Eisenberg 2022-11-23 14:53:40 -08:00
parent 5b7c9daecd
commit f79028af27
27 changed files with 471 additions and 78 deletions

View file

@ -11,7 +11,7 @@ export enum Language {
}
// Additional names for languages
const LANGUAGE_ALIASES: { [lang: string]: Language } = {
export const LANGUAGE_ALIASES: { [lang: string]: Language } = {
c: Language.cpp,
"c++": Language.cpp,
"c#": Language.csharp,
@ -19,8 +19,12 @@ const LANGUAGE_ALIASES: { [lang: string]: Language } = {
typescript: Language.javascript,
};
export type LanguageOrAlias = Language | keyof typeof LANGUAGE_ALIASES;
export const KOTLIN_SWIFT_BYPASS = ["kotlin", "swift"];
// Translate from user input or GitHub's API names for languages to CodeQL's names for languages
export function parseLanguage(language: string): Language | undefined {
export function parseLanguage(language: string): LanguageOrAlias | undefined {
// Normalise to lower case
language = language.toLowerCase();
@ -31,7 +35,7 @@ export function parseLanguage(language: string): Language | undefined {
// Check language aliases
if (language in LANGUAGE_ALIASES) {
return LANGUAGE_ALIASES[language];
return language;
}
return undefined;