Skip to content

Commit 6ccd563

Browse files
committed
Put TRAP cache cleanup behind a feature flag
1 parent 4f2b182 commit 6ccd563

9 files changed

+35
-6
lines changed

lib/analyze-action.js

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

lib/analyze-action.js.map

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

lib/feature-flags.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/feature-flags.js.map

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

lib/trap-caching.js

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

lib/trap-caching.js.map

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

src/analyze-action.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,11 @@ async function run() {
321321
trapCacheUploadTime = performance.now() - trapCacheUploadStartTime;
322322

323323
// Clean up TRAP caches
324-
trapCacheCleanupTelemetry = await cleanupTrapCaches(config, logger);
324+
trapCacheCleanupTelemetry = await cleanupTrapCaches(
325+
config,
326+
features,
327+
logger,
328+
);
325329

326330
// We don't upload results in test mode, so don't wait for processing
327331
if (util.isInTestMode()) {

src/feature-flags.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface FeatureEnablement {
4646
*/
4747
export enum Feature {
4848
AutobuildDirectTracing = "autobuild_direct_tracing",
49+
CleanupTrapCaches = "cleanup_trap_caches",
4950
CppDependencyInstallation = "cpp_dependency_installation_enabled",
5051
CppTrapCachingEnabled = "cpp_trap_caching_enabled",
5152
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
@@ -91,6 +92,11 @@ export const featureConfig: Record<
9192
minimumVersion: undefined,
9293
toolsFeature: ToolsFeature.TraceCommandUseBuildMode,
9394
},
95+
[Feature.CleanupTrapCaches]: {
96+
defaultValue: false,
97+
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
98+
minimumVersion: undefined,
99+
},
94100
[Feature.CppDependencyInstallation]: {
95101
defaultValue: false,
96102
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",

src/trap-caching.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as actionsUtil from "./actions-util";
77
import * as apiClient from "./api-client";
88
import { CodeQL } from "./codeql";
99
import type { Config } from "./config-utils";
10+
import { Feature, FeatureEnablement } from "./feature-flags";
1011
import { Language } from "./languages";
1112
import { Logger } from "./logging";
1213
import { isHTTPError, tryGetFolderBytes, withTimeout, wrapError } from "./util";
@@ -169,8 +170,14 @@ export interface TrapCacheCleanupStatusReport {
169170

170171
export async function cleanupTrapCaches(
171172
config: Config,
173+
features: FeatureEnablement,
172174
logger: Logger,
173175
): Promise<TrapCacheCleanupStatusReport> {
176+
if (!(await features.getValue(Feature.CleanupTrapCaches))) {
177+
return {
178+
trap_cache_cleanup_skipped_because: "feature disabled",
179+
};
180+
}
174181
if (!(await actionsUtil.isAnalyzingDefaultBranch())) {
175182
return {
176183
trap_cache_cleanup_skipped_because: "not analyzing default branch",

0 commit comments

Comments
 (0)