8000 Automatically clean up old TRAP caches by henrymercer · Pull Request #2306 · github/codeql-action · GitHub
[go: up one dir, main page]

Skip to content

Automatically clean up old TRAP caches #2306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Put TRAP cache cleanup behind a feature flag
  • Loading branch information
henrymercer committed May 23, 2024
commit 6ccd5631d811c84fd41304a746443149a9ce67ad
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
< 8000 td class="blob-code blob-code-context js-file-line"> // We don't upload results in test mode, so don't wait for processing
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,
);

if (util.isInTestMode()) {
Expand Down
6 changes: 6 additions & 0 deletions src/feature-flags.ts
8000
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))) {
4F0A 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