mirror of
https://github.com/github/codeql-action.git
synced 2026-10-03 17:41:28 +00:00
Abstract over FeatureEnablement implementations with initFeatures
This commit is contained in:
7
lib/analyze-action.js
generated
7
lib/analyze-action.js
generated
@@ -108114,6 +108114,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
async function getDiffInformedAnalysisBranches(codeql, features, logger) {
|
||||
@@ -110059,7 +110062,7 @@ async function setupCppAutobuild(codeql, logger) {
|
||||
const featureName = "C++ automatic installation of dependencies";
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
@@ -112958,7 +112961,7 @@ async function run(startedAt2) {
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
checkActionVersion(getActionVersion(), gitHubVersion);
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/autobuild-action.js
generated
5
lib/autobuild-action.js
generated
@@ -104447,6 +104447,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/trap-caching.ts
|
||||
var actionsCache2 = __toESM(require_cache5());
|
||||
@@ -105198,7 +105201,7 @@ async function setupCppAutobuild(codeql, logger) {
|
||||
const featureName = "C++ automatic installation of dependencies";
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/init-action-post.js
generated
5
lib/init-action-post.js
generated
@@ -165440,6 +165440,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
function getDiffRangesJsonFilePath() {
|
||||
@@ -169936,7 +169939,7 @@ async function run2(startedAt) {
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/init-action.js
generated
5
lib/init-action.js
generated
@@ -105647,6 +105647,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/diff-informed-analysis-utils.ts
|
||||
async function shouldPerformDiffInformedAnalysis(codeql, features, logger) {
|
||||
@@ -109139,7 +109142,7 @@ async function run(startedAt) {
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
checkActionVersion(getActionVersion(), gitHubVersion);
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
features = new Features(
|
||||
features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/setup-codeql-action.js
generated
5
lib/setup-codeql-action.js
generated
@@ -104348,6 +104348,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/init.ts
|
||||
var toolrunner4 = __toESM(require_toolrunner());
|
||||
@@ -106442,7 +106445,7 @@ async function run(startedAt) {
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
checkActionVersion(getActionVersion(), gitHubVersion);
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/start-proxy-action.js
generated
5
lib/start-proxy-action.js
generated
@@ -121141,6 +121141,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/start-proxy.ts
|
||||
var path2 = __toESM(require("path"));
|
||||
@@ -121909,7 +121912,7 @@ async function run(startedAt) {
|
||||
core11.saveState("proxy-log-file", proxyLogFilePath);
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
features = new Features(
|
||||
features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
5
lib/upload-sarif-action.js
generated
5
lib/upload-sarif-action.js
generated
@@ -107302,6 +107302,9 @@ var GitHubFeatureFlags = class {
|
||||
function supportsFeatureFlags(githubVariant) {
|
||||
return githubVariant === "GitHub.com" /* DOTCOM */ || githubVariant === "GitHub Enterprise Cloud with data residency" /* GHEC_DR */;
|
||||
}
|
||||
function initFeatures(gitHubVersion, repositoryNwo, tempDir, logger) {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
// src/status-report.ts
|
||||
var os = __toESM(require("os"));
|
||||
@@ -111272,7 +111275,7 @@ async function run(startedAt) {
|
||||
checkActionVersion(getActionVersion(), gitHubVersion);
|
||||
persistInputs();
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
} from "./dependency-caching";
|
||||
import { getDiffInformedAnalysisBranches } from "./diff-informed-analysis-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Features } from "./feature-flags";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import { KnownLanguage } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay-database-utils";
|
||||
@@ -293,7 +293,7 @@ async function run(startedAt: Date) {
|
||||
|
||||
util.checkActionVersion(actionsUtil.getActionVersion(), gitHubVersion);
|
||||
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { CodeQL, getCodeQL } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, featureConfig, Features } from "./feature-flags";
|
||||
import { Feature, featureConfig, initFeatures } from "./feature-flags";
|
||||
import { KnownLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -117,7 +117,7 @@ export async function setupCppAutobuild(codeql: CodeQL, logger: Logger) {
|
||||
const featureName = "C++ automatic installation of dependencies";
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
shouldPerformDiffInformedAnalysis,
|
||||
exportedForTesting,
|
||||
} from "./diff-informed-analysis-utils";
|
||||
import { Feature, Features } from "./feature-flags";
|
||||
import { Feature, initFeatures } from "./feature-flags";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import {
|
||||
@@ -63,7 +63,7 @@ const testShouldPerformDiffInformedAnalysis = test.macro({
|
||||
delete process.env.CODEQL_ACTION_DIFF_INFORMED_QUERIES;
|
||||
}
|
||||
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
testCase.gitHubVersion,
|
||||
parseRepositoryNwo("github/example"),
|
||||
tmpDir,
|
||||
|
||||
@@ -8,10 +8,10 @@ import {
|
||||
Feature,
|
||||
featureConfig,
|
||||
FeatureEnablement,
|
||||
Features,
|
||||
FEATURE_FLAGS_FILE_NAME,
|
||||
FeatureConfig,
|
||||
FeatureWithoutCLI,
|
||||
initFeatures,
|
||||
} from "./feature-flags";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
@@ -565,7 +565,7 @@ function setUpFeatureFlagTests(
|
||||
): FeatureEnablement {
|
||||
setupActionsVars(tmpDir, tmpDir);
|
||||
|
||||
return new Features(gitHubVersion, testRepositoryNwo, tmpDir, logger);
|
||||
return initFeatures(gitHubVersion, testRepositoryNwo, tmpDir, logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -357,7 +357,7 @@ export const FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
||||
* Determines the enablement status of a number of features locally without
|
||||
* consulting the GitHub API.
|
||||
*/
|
||||
export class OfflineFeatures implements FeatureEnablement {
|
||||
class OfflineFeatures implements FeatureEnablement {
|
||||
constructor(protected readonly logger: Logger) {}
|
||||
|
||||
async getDefaultCliVersion(
|
||||
@@ -494,7 +494,7 @@ export class OfflineFeatures implements FeatureEnablement {
|
||||
* If feature enablement is not able to be determined locally, a request to the
|
||||
* GitHub API is made to determine the enablement status.
|
||||
*/
|
||||
export class Features extends OfflineFeatures {
|
||||
class Features extends OfflineFeatures {
|
||||
private gitHubFeatureFlags: GitHubFeatureFlags;
|
||||
|
||||
constructor(
|
||||
@@ -798,3 +798,16 @@ function supportsFeatureFlags(githubVariant: util.GitHubVariant): boolean {
|
||||
githubVariant === util.GitHubVariant.GHEC_DR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialises an instance of a `FeatureEnablement` implementation. The implementation used
|
||||
* is determined by the environment we are running in.
|
||||
*/
|
||||
export function initFeatures(
|
||||
gitHubVersion: util.GitHubVersion,
|
||||
repositoryNwo: RepositoryNwo,
|
||||
tempDir: string,
|
||||
logger: Logger,
|
||||
): FeatureEnablement {
|
||||
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
getDependencyCacheUsage,
|
||||
} from "./dependency-caching";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Features } from "./feature-flags";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import * as initActionPostHelper from "./init-action-post-helper";
|
||||
import { getActionsLogger } from "./logging";
|
||||
@@ -62,7 +62,7 @@ async function run(startedAt: Date) {
|
||||
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
makeTelemetryDiagnostic,
|
||||
} from "./diagnostics";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, FeatureEnablement, Features } from "./feature-flags";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import {
|
||||
loadPropertiesFromApi,
|
||||
RepositoryProperties,
|
||||
@@ -210,7 +210,7 @@ async function run(startedAt: Date) {
|
||||
let config: configUtils.Config | undefined;
|
||||
let configFile: string | undefined;
|
||||
let codeql: CodeQL;
|
||||
let features: Features;
|
||||
let features: FeatureEnablement;
|
||||
let sourceRoot: string;
|
||||
let toolsDownloadStatusReport: ToolsDownloadStatusReport | undefined;
|
||||
let toolsFeatureFlagsValid: boolean | undefined;
|
||||
@@ -237,7 +237,7 @@ async function run(startedAt: Date) {
|
||||
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
|
||||
features = new Features(
|
||||
features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CodeQL } from "./codeql";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Features } from "./feature-flags";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import { initCodeQL } from "./init";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -114,7 +114,7 @@ async function run(startedAt: Date): Promise<void> {
|
||||
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { pki } from "node-forge";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { Feature, Features } from "./feature-flags";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import { KnownLanguage } from "./languages";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -99,7 +99,7 @@ async function run(startedAt: Date) {
|
||||
// possible, and only use safe functions outside.
|
||||
|
||||
const logger = getActionsLogger();
|
||||
let features: Features | undefined;
|
||||
let features: FeatureEnablement | undefined;
|
||||
let language: KnownLanguage | undefined;
|
||||
|
||||
try {
|
||||
@@ -114,7 +114,7 @@ async function run(startedAt: Date) {
|
||||
// Initialise FFs.
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const gitHubVersion = await getGitHubVersion();
|
||||
features = new Features(
|
||||
features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
actionsUtil.getTemporaryDirectory(),
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as actionsUtil from "./actions-util";
|
||||
import { getActionVersion, getTemporaryDirectory } from "./actions-util";
|
||||
import * as analyses from "./analyses";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { Features } from "./feature-flags";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import { Logger, getActionsLogger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
import {
|
||||
@@ -70,7 +70,7 @@ async function run(startedAt: Date) {
|
||||
actionsUtil.persistInputs();
|
||||
|
||||
const repositoryNwo = getRepositoryNwo();
|
||||
const features = new Features(
|
||||
const features = initFeatures(
|
||||
gitHubVersion,
|
||||
repositoryNwo,
|
||||
getTemporaryDirectory(),
|
||||
|
||||
Reference in New Issue
Block a user