Return OfflineFeatures for CCR

This commit is contained in:
Michael B. Gale
2026-02-12 18:00:19 +00:00
parent 2c9bc45d46
commit 9dcfdf2c9c
9 changed files with 70 additions and 8 deletions

6
lib/analyze-action.js generated
View File

@@ -108115,7 +108115,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/diff-informed-analysis-utils.ts

View File

@@ -103130,6 +103130,10 @@ 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(" ");
}
@@ -104448,7 +104452,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/trap-caching.ts

View File

@@ -165441,7 +165441,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/diff-informed-analysis-utils.ts

6
lib/init-action.js generated
View File

@@ -105648,7 +105648,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/diff-informed-analysis-utils.ts

View File

@@ -103247,6 +103247,10 @@ 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(" ");
}
@@ -104349,7 +104353,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/init.ts

View File

@@ -120267,6 +120267,10 @@ 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(
@@ -121142,7 +121146,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/start-proxy.ts

View File

@@ -107303,7 +107303,11 @@ 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);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}
// src/status-report.ts

View File

@@ -4,6 +4,7 @@ import * as path from "path";
import test, { ExecutionContext } from "ava";
import * as defaults from "./defaults.json";
import { EnvVar } from "./environment";
import {
Feature,
featureConfig,
@@ -542,6 +543,22 @@ test("non-legacy feature flags should not start with codeql_action_", async (t)
}
});
test("initFeatures returns a `Features` instance by default", async (t) => {
await withTmpDir(async (tmpDir) => {
const features = setUpFeatureFlagTests(tmpDir);
t.is("Features", features.constructor.name);
});
});
test("initFeatures returns an `OfflineFeatures` instance in CCR", async (t) => {
await withTmpDir(async (tmpDir) => {
process.env.GITHUB_EVENT_NAME = "dynamic";
process.env[EnvVar.ANALYSIS_KEY] = "dynamic/copilot-pull-request-reviewer";
const features = setUpFeatureFlagTests(tmpDir);
t.is("OfflineFeatures", features.constructor.name);
});
});
function assertAllFeaturesUndefinedInApi(
t: ExecutionContext<unknown>,
loggedMessages: LoggedMessage[],

View File

@@ -3,6 +3,7 @@ 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";
@@ -809,5 +810,9 @@ export function initFeatures(
tempDir: string,
logger: Logger,
): FeatureEnablement {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
if (isCCR()) {
return new OfflineFeatures(logger);
} else {
return new Features(gitHubVersion, repositoryNwo, tempDir, logger);
}
}