mirror of
https://github.com/github/codeql-action.git
synced 2026-04-14 18:53:20 +00:00
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:
44
src/util.ts
44
src/util.ts
@@ -14,12 +14,14 @@ import * as apiCompatibility from "./api-compatibility.json";
|
||||
import { CodeQL, CODEQL_VERSION_NEW_TRACING } from "./codeql";
|
||||
import {
|
||||
Config,
|
||||
getRawLanguages,
|
||||
parsePacksSpecification,
|
||||
prettyPrintPack,
|
||||
} from "./config-utils";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Language } from "./languages";
|
||||
import { KOTLIN_SWIFT_BYPASS, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import { CODEQL_ACTION_TEST_MODE } from "./shared-environment";
|
||||
|
||||
/**
|
||||
@@ -832,3 +834,43 @@ export function isHostedRunner() {
|
||||
process.env["RUNNER_TOOL_CACHE"]?.includes("hostedtoolcache")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param featuresEnablement The features enabled for the current run
|
||||
* @param languagesInput Languages input from the workflow
|
||||
* @param repository The owner/name of the repository
|
||||
* @param logger A logger
|
||||
* @returns A boolean indicating whether or not the toolcache should be bypassed and the latest codeql should be downloaded.
|
||||
*/
|
||||
export async function shouldBypassToolcache(
|
||||
featuresEnablement: FeatureEnablement,
|
||||
codeqlUrl: string | undefined,
|
||||
languagesInput: string | undefined,
|
||||
repository: RepositoryNwo,
|
||||
logger: Logger
|
||||
): Promise<boolean> {
|
||||
// An explicit codeql url is specified, that means the toolcache will not be used.
|
||||
if (codeqlUrl) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the toolcache is disabled for all languages
|
||||
if (await featuresEnablement.getValue(Feature.BypassToolcacheEnabled)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the toolcache is disabled for kotlin and swift.
|
||||
if (
|
||||
await featuresEnablement.getValue(Feature.BypassToolcacheKotlinSwiftEnabled)
|
||||
) {
|
||||
// Now check to see if kotlin or swift is one of the languages being analyzed.
|
||||
const { rawLanguages } = await getRawLanguages(
|
||||
languagesInput,
|
||||
repository,
|
||||
logger
|
||||
);
|
||||
return rawLanguages.some((lang) => KOTLIN_SWIFT_BYPASS.includes(lang));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user