Skip to content

Commit e72d214

Browse files
committed
Return OfflineFeatures for CCR
1 parent 1c78264 commit e72d214

File tree

9 files changed

+70
-8
lines changed

9 files changed

+70
-8
lines changed

lib/analyze-action.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/autobuild-action.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/setup-codeql-action.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/feature-flags.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from "path";
44
import test, { ExecutionContext } from "ava";
55

66
import * as defaults from "./defaults.json";
7+
import { EnvVar } from "./environment";
78
import {
89
Feature,
910
featureConfig,
@@ -542,6 +543,22 @@ test("non-legacy feature flags should not start with codeql_action_", async (t)
542543
}
543544
});
544545

546+
test("initFeatures returns a `Features` instance by default", async (t) => {
547+
await withTmpDir(async (tmpDir) => {
548+
const features = setUpFeatureFlagTests(tmpDir);
549+
t.is("Features", features.constructor.name);
550+
});
551+
});
552+
553+
test("initFeatures returns an `OfflineFeatures` instance in CCR", async (t) => {
554+
await withTmpDir(async (tmpDir) => {
555+
process.env.GITHUB_EVENT_NAME = "dynamic";
556+
process.env[EnvVar.ANALYSIS_KEY] = "dynamic/copilot-pull-request-reviewer";
557+
const features = setUpFeatureFlagTests(tmpDir);
558+
t.is("OfflineFeatures", features.constructor.name);
559+
});
560+
});
561+
545562
function assertAllFeaturesUndefinedInApi(
546563
t: ExecutionContext<unknown>,
547564
loggedMessages: LoggedMessage[],

src/feature-flags.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "path";
33

44
import * as semver from "semver";
55

6+
import { isCCR } from "./actions-util";
67
import { getApiClient } from "./api-client";
78
import type { CodeQL } from "./codeql";
89
import * as defaults from "./defaults.json";
@@ -809,5 +810,9 @@ export function initFeatures(
809810
featureFlagsFile: string,
810811
logger: Logger,
811812
): FeatureEnablement {
812-
return new Features(gitHubVersion, repositoryNwo, featureFlagsFile, logger);
813+
if (isCCR()) {
814+
return new OfflineFeatures(logger);
815+
} else {
816+
return new Features(gitHubVersion, repositoryNwo, featureFlagsFile, logger);
817+
}
813818
}

0 commit comments

Comments
 (0)