@@ -12,10 +12,16 @@ import {
1212 printDebugLogs ,
1313} from "./actions-util" ;
1414import { getGitHubVersion } from "./api-client" ;
15+ import { CachingKind } from "./caching-utils" ;
1516import { getCodeQL } from "./codeql" ;
1617import { Config , getConfig } from "./config-utils" ;
1718import * as debugArtifacts from "./debug-artifacts" ;
19+ import {
20+ DependencyCachingUsageReport ,
21+ getDependencyCacheUsage ,
22+ } from "./dependency-caching" ;
1823import { Features } from "./feature-flags" ;
24+ import * as gitUtils from "./git-utils" ;
1925import * as initActionPostHelper from "./init-action-post-helper" ;
2026import { getActionsLogger } from "./logging" ;
2127import { getRepositoryNwo } from "./repository" ;
@@ -32,7 +38,8 @@ import { checkDiskUsage, checkGitHubVersionInRange, wrapError } from "./util";
3238interface InitPostStatusReport
3339 extends StatusReportBase ,
3440 initActionPostHelper . UploadFailedSarifResult ,
35- initActionPostHelper . JobStatusReport { }
41+ initActionPostHelper . JobStatusReport ,
42+ initActionPostHelper . DependencyCachingUsageReport { }
3643
3744async function runWrapper ( ) {
3845 const logger = getActionsLogger ( ) ;
@@ -41,6 +48,7 @@ async function runWrapper() {
4148 let uploadFailedSarifResult :
4249 | initActionPostHelper . UploadFailedSarifResult
4350 | undefined ;
51+ let dependencyCachingUsage : DependencyCachingUsageReport | undefined ;
4452 try {
4553 // Restore inputs from `init` Action.
4654 restoreInputs ( ) ;
@@ -73,6 +81,17 @@ async function runWrapper() {
7381 features ,
7482 logger ,
7583 ) ;
84+
85+ // If we are analysing the default branch and some kind of caching is enabled,
86+ // then try to determine our overall cache usage for dependency caches. We only
87+ // do this under these circumstances to avoid slowing down analyses for PRs
88+ // and where caching may not be enabled.
89+ if (
90+ ( await gitUtils . isAnalyzingDefaultBranch ( ) ) &&
91+ config . dependencyCachingEnabled !== CachingKind . None
92+ ) {
93+ dependencyCachingUsage = await getDependencyCacheUsage ( logger ) ;
94+ }
7695 }
7796 } catch ( unwrappedError ) {
7897 const error = wrapError ( unwrappedError ) ;
@@ -109,6 +128,7 @@ async function runWrapper() {
109128 ...statusReportBase ,
110129 ...uploadFailedSarifResult ,
111130 job_status : initActionPostHelper . getFinalJobStatus ( ) ,
131+ dependency_caching_usage : JSON . stringify ( dependencyCachingUsage ?? { } ) ,
112132 } ;
113133 logger . info ( "Sending status report for init-post step." ) ;
114134 await sendStatusReport ( statusReport ) ;
0 commit comments