Skip to content

Commit

Permalink
Put TRAP cache cleanup behind a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Mercer committed May 23, 2024
1 parent 4f2b182 commit 6ccd563
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/analyze-action.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lib/feature-flags.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/feature-flags.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion lib/trap-caching.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/trap-caching.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,11 @@ async function run() {
trapCacheUploadTime = performance.now() - trapCacheUploadStartTime;

// Clean up TRAP caches
trapCacheCleanupTelemetry = await cleanupTrapCaches(config, logger);
trapCacheCleanupTelemetry = await cleanupTrapCaches(
config,
features,
logger,
);

// We don't upload results in test mode, so don't wait for processing
if (util.isInTestMode()) {
Expand Down
6 changes: 6 additions & 0 deletions src/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface FeatureEnablement {
*/
export enum Feature {
AutobuildDirectTracing = "autobuild_direct_tracing",
CleanupTrapCaches = "cleanup_trap_caches",
CppDependencyInstallation = "cpp_dependency_installation_enabled",
CppTrapCachingEnabled = "cpp_trap_caching_enabled",
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
Expand Down Expand Up @@ -91,6 +92,11 @@ export const featureConfig: Record<
minimumVersion: undefined,
toolsFeature: ToolsFeature.TraceCommandUseBuildMode,
},
[Feature.CleanupTrapCaches]: {
defaultValue: false,
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
minimumVersion: undefined,
},
[Feature.CppDependencyInstallation]: {
defaultValue: false,
envVar: "CODEQL_EXTRACTOR_CPP_AUTOINSTALL_DEPENDENCIES",
Expand Down
7 changes: 7 additions & 0 deletions src/trap-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as actionsUtil from "./actions-util";
import * as apiClient from "./api-client";
import { CodeQL } from "./codeql";
import type { Config } from "./config-utils";
import { Feature, FeatureEnablement } from "./feature-flags";
import { Language } from "./languages";
import { Logger } from "./logging";
import { isHTTPError, tryGetFolderBytes, withTimeout, wrapError } from "./util";
Expand Down Expand Up @@ -169,8 +170,14 @@ export interface TrapCacheCleanupStatusReport {

export async function cleanupTrapCaches(
config: Config,
features: FeatureEnablement,
logger: Logger,
): Promise<TrapCacheCleanupStatusReport> {
if (!(await features.getValue(Feature.CleanupTrapCaches))) {
return {
trap_cache_cleanup_skipped_because: "feature disabled",
};
}
if (!(await actionsUtil.isAnalyzingDefaultBranch())) {
return {
trap_cache_cleanup_skipped_because: "not analyzing default branch",
Expand Down

0 comments on commit 6ccd563

Please sign in to comment.