diff --git a/lib/analyze-action.js b/lib/analyze-action.js index 40348b31f..249f7e53d 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -108012,14 +108012,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 61525b980..9fa9255ce 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -103130,10 +103130,6 @@ function getWorkflowRunAttempt() { function isSelfHostedRunner() { return process.env.RUNNER_ENVIRONMENT === "self-hosted"; } -var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer"; -function isCCR() { - return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false; -} function prettyPrintInvocation(cmd, args) { return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" "); } @@ -104349,14 +104345,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/init-action-post.js b/lib/init-action-post.js index 2fb2de351..daa13ab66 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -165338,14 +165338,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/init-action.js b/lib/init-action.js index 19a73d5c4..29003aa83 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -105545,14 +105545,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 289d27e5c..2f5f004fb 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -103247,10 +103247,6 @@ function isSelfHostedRunner() { function isDynamicWorkflow() { return getWorkflowEventName() === "dynamic"; } -var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer"; -function isCCR() { - return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false; -} function prettyPrintInvocation(cmd, args) { return [cmd, ...args].map((x) => x.includes(" ") ? `'${x}'` : x).join(" "); } @@ -104250,14 +104246,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/start-proxy-action.js b/lib/start-proxy-action.js index 2b16dae66..250957241 100644 --- a/lib/start-proxy-action.js +++ b/lib/start-proxy-action.js @@ -120267,10 +120267,6 @@ function getWorkflowRunAttempt() { function isSelfHostedRunner() { return process.env.RUNNER_ENVIRONMENT === "self-hosted"; } -var CCR_KEY_PREFIX = "dynamic/copilot-pull-request-reviewer"; -function isCCR() { - return process.env["CODEQL_ACTION_ANALYSIS_KEY" /* ANALYSIS_KEY */]?.startsWith(CCR_KEY_PREFIX) || false; -} var persistedInputsKey = "persisted_inputs"; var persistInputs = function() { const inputEnvironmentVariables = Object.entries(process.env).filter( @@ -121043,14 +121039,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 15e29edd5..e97a0aaf7 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -107200,14 +107200,7 @@ var GitHubFeatureFlags = class { async loadApiResponse() { if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features." - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features." + "Not running against github.com. Disabling all toggleable features." ); this.hasAccessedRemoteFeatureFlags = false; return {}; diff --git a/src/feature-flags.test.ts b/src/feature-flags.test.ts index 6632cf252..cdab85e27 100644 --- a/src/feature-flags.test.ts +++ b/src/feature-flags.test.ts @@ -4,7 +4,6 @@ import * as path from "path"; import test, { ExecutionContext } from "ava"; import * as defaults from "./defaults.json"; -import { EnvVar } from "./environment"; import { Feature, featureConfig, @@ -38,39 +37,29 @@ test.beforeEach(() => { const testRepositoryNwo = parseRepositoryNwo("github/example"); -test(`All features use default values if running against GHES`, async (t) => { +test(`All features are disabled if running against GHES`, async (t) => { await withTmpDir(async (tmpDir) => { - const loggedMessages: LoggedMessage[] = []; + const loggedMessages = []; const features = setUpFeatureFlagTests( tmpDir, getRecordingLogger(loggedMessages), { type: GitHubVariant.GHES, version: "3.0.0" }, ); - await assertAllFeaturesHaveDefaultValues(t, features); - assertLoggedMessage( - t, - loggedMessages, - "Not running against github.com. Using default values for all features.", - ); - }); -}); + for (const feature of Object.values(Feature)) { + t.deepEqual( + await getFeatureIncludingCodeQlIfRequired(features, feature), + featureConfig[feature].defaultValue, + ); + } -test(`All features use default values if running in CCR`, async (t) => { - await withTmpDir(async (tmpDir) => { - const loggedMessages: LoggedMessage[] = []; - const features = setUpFeatureFlagTests( - tmpDir, - getRecordingLogger(loggedMessages), - ); - - process.env[EnvVar.ANALYSIS_KEY] = "dynamic/copilot-pull-request-reviewer"; - - await assertAllFeaturesHaveDefaultValues(t, features); - assertLoggedMessage( - t, - loggedMessages, - "Feature flags are not supported in Copilot Code Review. Using default values for all features.", + t.assert( + loggedMessages.find( + (v: LoggedMessage) => + v.type === "debug" && + v.message === + "Not running against github.com. Disabling all toggleable features.", + ) !== undefined, ); }); }); @@ -553,30 +542,6 @@ test("non-legacy feature flags should not start with codeql_action_", async (t) } }); -async function assertAllFeaturesHaveDefaultValues( - t: ExecutionContext, - features: FeatureEnablement, -) { - for (const feature of Object.values(Feature)) { - t.deepEqual( - await getFeatureIncludingCodeQlIfRequired(features, feature), - featureConfig[feature].defaultValue, - ); - } -} - -function assertLoggedMessage( - t: ExecutionContext, - loggedMessages: LoggedMessage[], - expectedMessage: string, -) { - t.assert( - loggedMessages.find( - (v: LoggedMessage) => v.type === "debug" && v.message === expectedMessage, - ) !== undefined, - ); -} - function assertAllFeaturesUndefinedInApi( t: ExecutionContext, loggedMessages: LoggedMessage[], diff --git a/src/feature-flags.ts b/src/feature-flags.ts index 04508089d..ea8cc1767 100644 --- a/src/feature-flags.ts +++ b/src/feature-flags.ts @@ -3,7 +3,6 @@ import * as path from "path"; import * as semver from "semver"; -import { isCCR } from "./actions-util"; import { getApiClient } from "./api-client"; import type { CodeQL } from "./codeql"; import * as defaults from "./defaults.json"; @@ -665,14 +664,7 @@ class GitHubFeatureFlags { // Do nothing when not running against github.com if (!supportsFeatureFlags(this.gitHubVersion.type)) { this.logger.debug( - "Not running against github.com. Using default values for all features.", - ); - this.hasAccessedRemoteFeatureFlags = false; - return {}; - } - if (isCCR()) { - this.logger.debug( - "Feature flags are not supported in Copilot Code Review. Using default values for all features.", + "Not running against github.com. Disabling all toggleable features.", ); this.hasAccessedRemoteFeatureFlags = false; return {};