Store and restore dependency caches in init Action

This commit is contained in:
Michael B. Gale
2024-07-22 15:30:56 +01:00
parent 2b7af49a3d
commit f64038fc40
6 changed files with 29 additions and 2 deletions

View File

@@ -14,6 +14,7 @@ import {
import { getGitHubVersion } from "./api-client";
import { Config, getConfig } from "./config-utils";
import * as debugArtifacts from "./debug-artifacts";
import { uploadDependencyCaches } from "./dependency-caching";
import { Features } from "./feature-flags";
import * as initActionPostHelper from "./init-action-post-helper";
import { getActionsLogger } from "./logging";
@@ -25,6 +26,7 @@ import {
getActionsStatus,
ActionName,
getJobStatusDisplayName,
JobStatus,
} from "./status-report";
import {
checkDiskUsage,
@@ -116,6 +118,14 @@ async function runWrapper() {
};
await sendStatusReport(statusReport);
}
// Store dependency cache(s) if the job was successful and dependency caching is enabled.
if (
jobStatus === JobStatus.SuccessStatus &&
config.dependencyCachingEnabled
) {
await uploadDependencyCaches(config, logger);
}
}
void runWrapper();

View File

@@ -17,6 +17,7 @@ import {
import { getGitHubVersion } from "./api-client";
import { CodeQL } from "./codeql";
import * as configUtils from "./config-utils";
import { downloadDependencyCaches } from "./dependency-caching";
import {
addDiagnostic,
flushDiagnostics,
@@ -557,6 +558,11 @@ async function run() {
core.exportVariable(bmnVar, value);
}
// Restore dependency cache(s), if they exist.
if (config.dependencyCachingEnabled) {
await downloadDependencyCaches(config.languages, logger);
}
// For CLI versions <2.15.1, build tracing caused errors in MacOS ARM machines with
// System Integrity Protection (SIP) disabled.
if (