Fix Docker build cache command handling#236
Conversation
Greptile Summary
Confidence Score: 4/5The Docker cache command changes need attention before merge because cache persistence, failure reporting, and command escaping behavior are affected. The changed surface is narrow and covered by focused tests, but the cache-enabled runtime paths include regressions that impact expected build cache behavior and command execution semantics. src/Executor/Runner/Docker.php
What T-Rex did
Reviews (1): Last reviewed commit: "fix: preserve build command with cache" | Re-trigger Greptile |
| $status = $this->orchestration->execute( | ||
| name: $runtimeName, | ||
| command: $commands, | ||
| command: $this->getBuildCommands($command, $version), |
There was a problem hiding this comment.
When cacheKey is set, this path now runs the original user command directly and then tries to upload /cache/stores.sqfs. The removed wrapper was the code path that ran the build-cache helper around the command, and the removed script generation was the code path that gave that helper the original build command. Normal build commands such as tar -zxf ... && bash helpers/build.sh "npm install..." do not create /cache/stores.sqfs, so storeBuildCacheArtifact() returns early and no cache artifact is saved. Cache-enabled builds can still succeed, but subsequent builds will not produce the expected saved/hit cache behavior.
Artifacts
Repro: PHP script testing getBuildCommands cache lifecycle gap
- Contains supporting evidence from the run (text/x-php; charset=utf-8).
Repro: failing test output showing no cache lifecycle in build commands
- Keeps the command output available without making the summary code-heavy.
| } catch (Throwable $err) { | ||
| throw new ExecutorException(ExecutorException::RUNTIME_FAILED, $err->getMessage(), null, $err); |
There was a problem hiding this comment.
If cache restore records a warning and the user command then fails, this rethrow skips the only merge of $cacheWarnings below. The outer catch rebuilds $output from container logs or the throwable message, so the cache warning is dropped from the failed build response. A build with both a restore problem and a command failure will hide the cache problem from the caller.
Artifacts
Repro: PHP script simulating Docker.php createRuntime control flow for cache warning loss
- Contains supporting evidence from the run (text/x-php; charset=utf-8).
Repro: execution output showing cache warnings present on success but missing on failure
- Keeps the command output available without making the summary code-heavy.
| return [ | ||
| 'bash', | ||
| '-c', | ||
| 'mkdir -p /tmp/logging && touch /tmp/logging/timings.txt && touch /tmp/logging/logs.txt && script --log-out /tmp/logging/logs.txt --flush --log-timing /tmp/logging/timings.txt --return --quiet --command "' . \str_replace('"', '\"', $command) . '"' |
There was a problem hiding this comment.
Cache-enabled v5 builds now pass the original command through the outer bash -c and script --command "..." string. Before this change, cache-enabled builds wrote the user command to /cache/build-command.sh and ran the cache helper, so the command body was not reinterpreted by this extra shell layer. Commands containing substitutions or shell escapes that were intended for the build shell can now be expanded before script receives them, changing behavior only when cache is enabled.
Artifacts
Repro: shell harness exercising the v5 getBuildCommands quoting surface
- Contains supporting evidence from the run (text/x-shellscript; charset=utf-8).
Repro: failing test output showing shell expansion of $(date), backticks, and $HOME
- Keeps the command output available without making the summary code-heavy.
Summary
Tests