@@ -44225,10 +44225,12 @@ const crypto_1 = __nccwpck_require__(76982);
4422544225const fs_1 = __nccwpck_require__(79896);
4422644226const cargo_1 = __nccwpck_require__(38472);
4422744227const cache_impl_1 = __nccwpck_require__(36609);
44228- function buildCacheStrategy(projectDir, strategy, toolchains, fallbackBranch) {
44228+ function buildCacheStrategy(projectDir, strategy, toolchains, fallbackBranch, cachePrefix) {
44229+ if (!cachePrefix)
44230+ return;
4422944231 switch (strategy) {
4423044232 case 'github':
44231- return new GithubBuildCacheStrategy(projectDir, toolchains, fallbackBranch);
44233+ return new GithubBuildCacheStrategy(cachePrefix, projectDir, toolchains, fallbackBranch);
4423244234 case 'none':
4423344235 return undefined;
4423444236 default:
@@ -44242,11 +44244,11 @@ class GithubBuildCacheStrategy {
4424244244 projectDir;
4424344245 fallbackBranch;
4424444246 restoredFrom;
44245- constructor(projectDir, toolchains, fallbackBranch) {
44247+ constructor(cachePrefix, projectDir, toolchains, fallbackBranch) {
4424644248 this.projectDir = projectDir;
4424744249 this.fallbackBranch = fallbackBranch;
44248- this.cacheKey = GithubBuildCacheStrategy.buildCacheKey(projectDir, toolchains, fallbackBranch);
44249- this.fallbackKey = GithubBuildCacheStrategy.buildFallbackCacheKey(projectDir, toolchains, fallbackBranch);
44250+ this.cacheKey = GithubBuildCacheStrategy.buildCacheKey(cachePrefix, projectDir, toolchains, fallbackBranch);
44251+ this.fallbackKey = GithubBuildCacheStrategy.buildFallbackCacheKey(cachePrefix, projectDir, toolchains, fallbackBranch);
4425044252 }
4425144253 async restore() {
4425244254 this.restoredFrom = await GithubBuildCacheStrategy.restoreBuildCache(this.projectDir, this.cacheKey, this.fallbackKey);
@@ -44284,7 +44286,7 @@ class GithubBuildCacheStrategy {
4428444286 await (0, cache_impl_1.saveToCache)([targetDir], cacheKey);
4428544287 (0, core_1.info)(`Saved build cache with key: ${cacheKey}`);
4428644288 }
44287- static buildCacheKey(projectDir, toolchains, fallbackBranch) {
44289+ static buildCacheKey(cachePrefix, projectDir, toolchains, fallbackBranch) {
4428844290 const lockFile = cargo_1.Cargo.cargoLock(projectDir);
4428944291 let lockHashOrBranch = process.env.GITHUB_REF_NAME || 'not-in-gh-action';
4429044292 if (fallbackBranch === lockHashOrBranch) {
@@ -44309,16 +44311,16 @@ class GithubBuildCacheStrategy {
4430944311 normalizedProjectDir = normalizedProjectDir.replace(/[\\/]+/g, '-');
4431044312 const platform = process.platform;
4431144313 const arch = process.arch;
44312- return `rax-cache -build-${platform}-${arch}-${toolchainHash}-${normalizedProjectDir}-${lockHashOrBranch}`;
44314+ return `${cachePrefix} -build-${platform}-${arch}-${toolchainHash}-${normalizedProjectDir}-${lockHashOrBranch}`;
4431344315 }
44314- static buildFallbackCacheKey(projectDir, toolchains, fallbackBranch) {
44316+ static buildFallbackCacheKey(cachePrefix, projectDir, toolchains, fallbackBranch) {
4431544317 const platform = process.platform;
4431644318 const arch = process.arch;
4431744319 const toolchainHash = (0, crypto_1.createHash)('sha256')
4431844320 .update(toolchains.sort().join(','))
4431944321 .digest('hex')
4432044322 .slice(0, 8);
44321- return `rax-cache -build-${platform}-${arch}-${toolchainHash}-${projectDir}-${fallbackBranch}`;
44323+ return `${cachePrefix} -build-${platform}-${arch}-${toolchainHash}-${projectDir}-${fallbackBranch}`;
4432244324 }
4432344325}
4432444326exports.GithubBuildCacheStrategy = GithubBuildCacheStrategy;
@@ -44359,18 +44361,17 @@ async function saveToCache(cachePath, key) {
4435944361 }
4436044362 if (!anyExists) {
4436144363 core.warning(`No paths from ${cachePath} exist, skip caching for key ${key}`);
44362- return;
44364+ return false ;
4436344365 }
4436444366 try {
4436544367 await cache.saveCache(cachePath, key);
4436644368 core.info(`Cached key ${key}`);
4436744369 }
4436844370 catch (err) {
44369- if (err.name === cache.ValidationError.name)
44370- throw err;
44371- if (err.name === cache.ReserveCacheError.name)
44372- core.warning(`Caching failed for ${key}: ${err.message}`);
44371+ core.error(`Caching failed for ${key}: ${err.message}`);
44372+ return false;
4437344373 }
44374+ return true;
4437444375}
4437544376/**
4437644377 * Generates a cache key
@@ -44717,7 +44718,7 @@ async function run(cfg) {
4471744718 }
4471844719 cfg.toolchain = tomlChannel;
4471944720 }
44720- const cacheKey = cfg.cacheKey === 'no-cache' ? undefined : 'rax-cache';
44721+ const cachePrefix = cfg.cacheKey === 'no-cache' ? undefined : 'rax-cache';
4472144722 // Ensure default toolchain is set to allow rustc -vV calls
4472244723 if ((await (0, rustup_js_1.getGlobalDefaultToolchain)()) === undefined) {
4472344724 await (0, rustup_js_1.setDefaultToolchain)(cfg.toolchain || 'stable');
@@ -44731,8 +44732,8 @@ async function run(cfg) {
4473144732 new workflows_js_1.DenyWorkflow((0, workflows_js_1.workflowConfig)(cfg, 'deny')),
4473244733 ].filter((wf) => workflowFilter(cfg, wf.name));
4473344734 // Prepare toolchains
44734- const installedToolchains = await installToolchains(cfg, enabledWorkflows, start, cacheKey );
44735- const installedTools = await installTools(start, enabledWorkflows, cacheKey , cfg);
44735+ const installedToolchains = await installToolchains(cfg, enabledWorkflows, start, cachePrefix );
44736+ const installedTools = await installTools(start, enabledWorkflows, cachePrefix , cfg);
4473644737 // If installOnly is set, skip workflow execution
4473744738 if (cfg.installOnly) {
4473844739 (0, core_1.info)('Install-only mode enabled, skipping workflow execution.');
@@ -44743,7 +44744,7 @@ async function run(cfg) {
4474344744 succeeded: true,
4474444745 };
4474544746 }
44746- const buildCache = (0, build_cache_js_1.buildCacheStrategy)(cfg.project, cfg.buildCacheStrategy, installedToolchains, cfg.buildCacheFallbackBranch);
44747+ const buildCache = (0, build_cache_js_1.buildCacheStrategy)(cfg.project, cfg.buildCacheStrategy, installedToolchains, cfg.buildCacheFallbackBranch, cachePrefix );
4474744748 if (buildCache) {
4474844749 await (0, core_1.group)(`Restoring build cache: ${timeSinceStart(start)}`, async () => {
4474944750 await buildCache.restore();
0 commit comments