Fall back to the default.json CLI version if feature flags misconfigured

This commit is contained in:
Henry Mercer
2023-01-23 20:00:44 +00:00
parent 14c4412c63
commit 5d931ea2a2
6 changed files with 33 additions and 15 deletions

View File

@@ -407,7 +407,7 @@ test("selects CLI v2.12.1 on Dotcom when feature flags enable v2.12.0 and v2.12.
});
});
test(`selects CLI v2.11.6 on Dotcom when no default version feature flags are enabled`, async (t) => {
test(`selects CLI from defaults.json on Dotcom when no default version feature flags are enabled`, async (t) => {
await withTmpDir(async (tmpDir) => {
const featureEnablement = setUpFeatureFlagTests(tmpDir);
const expectedFeatureEnablement = initializeFeatures(true);
@@ -416,7 +416,7 @@ test(`selects CLI v2.11.6 on Dotcom when no default version feature flags are en
t.deepEqual(
await featureEnablement.getDefaultCliVersion(GitHubVariant.DOTCOM),
{
cliVersion: "2.11.6",
cliVersion: defaults.cliVersion,
variant: GitHubVariant.DOTCOM,
}
);

View File

@@ -12,7 +12,6 @@ import * as util from "./util";
const DEFAULT_VERSION_FEATURE_FLAG_PREFIX = "default_codeql_version_";
const DEFAULT_VERSION_FEATURE_FLAG_SUFFIX = "_enabled";
const MINIMUM_ENABLED_CODEQL_VERSION = "2.11.6";
export type CodeQLDefaultVersionInfo =
| {
@@ -231,11 +230,21 @@ class GitHubFeatureFlags implements FeatureEnablement {
.map((f) => f as string);
if (enabledFeatureFlagCliVersions.length === 0) {
this.logger.debug(
"Feature flags do not specify a default CLI version. Falling back to CLI version " +
`${MINIMUM_ENABLED_CODEQL_VERSION}.`
// We expect at least one default CLI version to be enabled on Dotcom at any time. However if
// the feature flags are misconfigured, rather than crashing, we fall back to the CLI version
// shipped with the Action in defaults.json. This has the effect of immediately rolling out
// new CLI versions to all users running the latest Action.
//
// A drawback of this approach relates to the small number of users that run old versions of
// the Action on Dotcom. As a result of this approach, if we misconfigure the feature flags
// then these users will experience some alert churn. This is because the CLI version in the
// defaults.json shipped with an old version of the Action is likely older than the CLI
// version that would have been specified by the feature flags before they were misconfigured.
this.logger.warning(
"Feature flags do not specify a default CLI version. Falling back to the CLI version " +
`shipped with the Action. This is ${defaults.cliVersion}.`
);
return MINIMUM_ENABLED_CODEQL_VERSION;
return defaults.cliVersion;
}
const maxCliVersion = enabledFeatureFlagCliVersions.reduce(