Add support for on-demand feature flags
This commit is contained in:
parent
7d9b7a1870
commit
c49579ba44
3 changed files with 66 additions and 34 deletions
40
lib/feature-flags.js
generated
40
lib/feature-flags.js
generated
|
|
@ -60,46 +60,53 @@ var Feature;
|
||||||
})(Feature || (exports.Feature = Feature = {}));
|
})(Feature || (exports.Feature = Feature = {}));
|
||||||
exports.featureConfig = {
|
exports.featureConfig = {
|
||||||
[Feature.AutobuildDirectTracingEnabled]: {
|
[Feature.AutobuildDirectTracingEnabled]: {
|
||||||
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING",
|
envVar: "CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
toolsFeature: tools_features_1.ToolsFeature.TraceCommandUseBuildMode,
|
toolsFeature: tools_features_1.ToolsFeature.TraceCommandUseBuildMode,
|
||||||
defaultValue: false,
|
|
||||||
},
|
},
|
||||||
[Feature.CombineSarifFilesDeprecationWarning]: {
|
[Feature.CombineSarifFilesDeprecationWarning]: {
|
||||||
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
|
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
|
||||||
|
legacyApi: true,
|
||||||
// Independent of the CLI version.
|
// Independent of the CLI version.
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
defaultValue: false,
|
|
||||||
},
|
},
|
||||||
[Feature.CppDependencyInstallation]: {
|
[Feature.CppDependencyInstallation]: {
|
||||||
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
|
|
||||||
minimumVersion: "2.15.0",
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: "2.15.0",
|
||||||
},
|
},
|
||||||
[Feature.CppTrapCachingEnabled]: {
|
[Feature.CppTrapCachingEnabled]: {
|
||||||
envVar: "CODEQL_CPP_TRAP_CACHING",
|
|
||||||
minimumVersion: "2.16.1",
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_CPP_TRAP_CACHING",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: "2.16.1",
|
||||||
},
|
},
|
||||||
[Feature.DisableJavaBuildlessEnabled]: {
|
[Feature.DisableJavaBuildlessEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.ExportDiagnosticsEnabled]: {
|
[Feature.ExportDiagnosticsEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
|
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.QaTelemetryEnabled]: {
|
[Feature.QaTelemetryEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
exports.FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
exports.FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
||||||
|
|
@ -315,9 +322,14 @@ class GitHubFeatureFlags {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const featuresToRequest = Object.entries(exports.featureConfig)
|
||||||
|
.filter(([, config]) => !config.legacyApi)
|
||||||
|
.map(([f]) => f)
|
||||||
|
.join(",");
|
||||||
const response = await (0, api_client_1.getApiClient)().request("GET /repos/:owner/:repo/code-scanning/codeql-action/features", {
|
const response = await (0, api_client_1.getApiClient)().request("GET /repos/:owner/:repo/code-scanning/codeql-action/features", {
|
||||||
owner: this.repositoryNwo.owner,
|
owner: this.repositoryNwo.owner,
|
||||||
repo: this.repositoryNwo.repo,
|
repo: this.repositoryNwo.repo,
|
||||||
|
features: featuresToRequest,
|
||||||
});
|
});
|
||||||
const remoteFlags = response.data;
|
const remoteFlags = response.data;
|
||||||
this.logger.debug("Loaded the following default values for the feature flags from the Code Scanning API: " +
|
this.logger.debug("Loaded the following default values for the feature flags from the Code Scanning API: " +
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -58,12 +58,24 @@ export enum Feature {
|
||||||
export const featureConfig: Record<
|
export const featureConfig: Record<
|
||||||
Feature,
|
Feature,
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Default value in environments where the feature flags API is not available,
|
||||||
|
* such as GitHub Enterprise Server.
|
||||||
|
*/
|
||||||
|
defaultValue: boolean;
|
||||||
/**
|
/**
|
||||||
* Environment variable for explicitly enabling or disabling the feature.
|
* Environment variable for explicitly enabling or disabling the feature.
|
||||||
*
|
*
|
||||||
* This overrides enablement status from the feature flags API.
|
* This overrides enablement status from the feature flags API.
|
||||||
*/
|
*/
|
||||||
envVar: string;
|
envVar: string;
|
||||||
|
/**
|
||||||
|
* Whether the feature flag is part of the legacy feature flags API.
|
||||||
|
*
|
||||||
|
* These feature flags are included by default in the API response and do not need to be
|
||||||
|
* explicitly requested.
|
||||||
|
*/
|
||||||
|
legacyApi?: boolean;
|
||||||
/**
|
/**
|
||||||
* Minimum version of the CLI, if applicable.
|
* Minimum version of the CLI, if applicable.
|
||||||
*
|
*
|
||||||
|
|
@ -72,54 +84,56 @@ export const featureConfig: Record<
|
||||||
minimumVersion: string | undefined;
|
minimumVersion: string | undefined;
|
||||||
/** Required tools feature, if applicable. */
|
/** Required tools feature, if applicable. */
|
||||||
toolsFeature?: ToolsFeature;
|
toolsFeature?: ToolsFeature;
|
||||||
/**
|
|
||||||
* Default value in environments where the feature flags API is not available,
|
|
||||||
* such as GitHub Enterprise Server.
|
|
||||||
*/
|
|
||||||
defaultValue: boolean;
|
|
||||||
}
|
}
|
||||||
> = {
|
> = {
|
||||||
[Feature.AutobuildDirectTracingEnabled]: {
|
[Feature.AutobuildDirectTracingEnabled]: {
|
||||||
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING",
|
envVar: "CODEQL_ACTION_AUTOBUILD_BUILD_MODE_DIRECT_TRACING",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
toolsFeature: ToolsFeature.TraceCommandUseBuildMode,
|
toolsFeature: ToolsFeature.TraceCommandUseBuildMode,
|
||||||
defaultValue: false,
|
|
||||||
},
|
},
|
||||||
[Feature.CombineSarifFilesDeprecationWarning]: {
|
[Feature.CombineSarifFilesDeprecationWarning]: {
|
||||||
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
|
envVar: "CODEQL_ACTION_COMBINE_SARIF_FILES_DEPRECATION_WARNING",
|
||||||
|
legacyApi: true,
|
||||||
// Independent of the CLI version.
|
// Independent of the CLI version.
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
defaultValue: false,
|
|
||||||
},
|
},
|
||||||
[Feature.CppDependencyInstallation]: {
|
[Feature.CppDependencyInstallation]: {
|
||||||
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
|
|
||||||
minimumVersion: "2.15.0",
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: "2.15.0",
|
||||||
},
|
},
|
||||||
[Feature.CppTrapCachingEnabled]: {
|
[Feature.CppTrapCachingEnabled]: {
|
||||||
envVar: "CODEQL_CPP_TRAP_CACHING",
|
|
||||||
minimumVersion: "2.16.1",
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_CPP_TRAP_CACHING",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: "2.16.1",
|
||||||
},
|
},
|
||||||
[Feature.DisableJavaBuildlessEnabled]: {
|
[Feature.DisableJavaBuildlessEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_DISABLE_JAVA_BUILDLESS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.DisableKotlinAnalysisEnabled]: {
|
[Feature.DisableKotlinAnalysisEnabled]: {
|
||||||
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_DISABLE_KOTLIN_ANALYSIS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.ExportDiagnosticsEnabled]: {
|
[Feature.ExportDiagnosticsEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
|
envVar: "CODEQL_ACTION_EXPORT_DIAGNOSTICS",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.QaTelemetryEnabled]: {
|
[Feature.QaTelemetryEnabled]: {
|
||||||
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
|
envVar: "CODEQL_ACTION_QA_TELEMETRY",
|
||||||
|
legacyApi: true,
|
||||||
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -450,11 +464,17 @@ class GitHubFeatureFlags {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
const featuresToRequest = Object.entries(featureConfig)
|
||||||
|
.filter(([, config]) => !config.legacyApi)
|
||||||
|
.map(([f]) => f)
|
||||||
|
.join(",");
|
||||||
|
|
||||||
const response = await getApiClient().request(
|
const response = await getApiClient().request(
|
||||||
"GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
"GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||||
{
|
{
|
||||||
owner: this.repositoryNwo.owner,
|
owner: this.repositoryNwo.owner,
|
||||||
repo: this.repositoryNwo.repo,
|
repo: this.repositoryNwo.repo,
|
||||||
|
features: featuresToRequest,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const remoteFlags = response.data;
|
const remoteFlags = response.data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue