Skip to content

Commit cc6cfa2

Browse files
committed
fix(cli): cache failed direct script builds
2 parents d9db602 + 6a25c16 commit cc6cfa2

3 files changed

Lines changed: 339 additions & 22 deletions

File tree

‎include/vix/cli/commands/run/RunDetail.hpp‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,17 @@ namespace vix::commands::RunCommand::detail
293293
fs::path rootDir;
294294
fs::path binaryPath;
295295
fs::path metaFile;
296+
fs::path failureMetaFile;
296297
fs::path stdoutLogPath;
297298
fs::path stderrLogPath;
298299

299300
std::string cacheKey;
300301
std::string rebuildReason;
302+
303+
int cachedFailureExitCode = 0;
304+
301305
bool cacheHit = false;
306+
bool cachedFailure = false;
302307
bool needsRebuild = true;
303308
};
304309

@@ -720,6 +725,16 @@ namespace vix::commands::RunCommand::detail
720725
*/
721726
bool persist_direct_script_cache_metadata(const DirectScriptPlan &plan);
722727

728+
bool persist_direct_script_failure_cache(
729+
const DirectScriptPlan &plan,
730+
int exitCode,
731+
const std::string &stdoutText,
732+
const std::string &stderrText);
733+
734+
int replay_direct_script_cached_failure(
735+
const DirectScriptPlan &plan,
736+
const DirectScriptCacheState &cache);
737+
723738
// ===========================================================================
724739
// Script mode execution
725740
// ===========================================================================

‎src/commands/run/RunScript.cpp‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,13 @@ namespace vix::commands::RunCommand::detail
15201520

15211521
const DirectScriptCacheState cache = load_direct_script_cache_state(directPlan);
15221522

1523+
if (cache.cachedFailure)
1524+
{
1525+
return replay_direct_script_cached_failure(
1526+
directPlan,
1527+
cache);
1528+
}
1529+
15231530
if (cache.needsRebuild)
15241531
{
15251532
const LiveRunResult build = run_cmd_live_filtered_capture(
@@ -1532,6 +1539,16 @@ namespace vix::commands::RunCommand::detail
15321539

15331540
if (build.exitCode != 0)
15341541
{
1542+
if (!persist_direct_script_failure_cache(
1543+
directPlan,
1544+
build.exitCode,
1545+
build.stdoutText,
1546+
build.stderrText))
1547+
{
1548+
std::cerr
1549+
<< "warning: unable to persist direct script failure cache\n";
1550+
}
1551+
15351552
bool handled = false;
15361553

15371554
if (!build.stdoutText.empty() || !build.stderrText.empty())

0 commit comments

Comments
 (0)