You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix empty diff being returned when single *cached* step had to be executed (#567)
This PR fixes a bug in the step-wise caching logic that @eseliger and I ran into last week.
### Problem
When no cached result for the *complete* task was found, but a cached result for a single step and that step was the only left to execute then an empty diff was returned.
### How to reproduce
1. Execute a batch spec with the following steps
```yaml
steps:
- run: echo "this is step 1" >> README.txt
container: alpine:3
- run: echo "this is step 2" >> README.md
container: alpine:3
```
the complete results and the results for each step are now cached.
2. Update the batch spec and re-execute:
```yaml
steps:
- run: echo "this is step 1" >> README.txt
container: alpine:3
```
This will produce an empty diff because the `Coordinator` did not find a cached result for the complete task/batch spec, but for the first step.
`runSteps` didn't handle this case though, when only a single step had to be executed but that was also cached.
### The fix
Take a look at my comments in the diffs here in GitHub to see what the fix is. Spoiler: it's just a condition and an early exit to handle the case of "cached step result == the only step to execute".
In order to get to this fix though I wrote a lot of tests, found one other bug (`Files` was not cached), and cleaned up the 300 line long `runSteps` function.
`runSteps` is now much easier to understand and doesn't contain _all_ levels of abstraction. The outer `runSteps` concerns itself with which steps need to be executed and how to handle their results and `executeSingleStep` does the lower-level work of rendering templates, starting containers, setting up the logger, etc.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ All notable changes to `src-cli` are documented in this file.
17
17
18
18
### Fixed
19
19
20
+
- The per-step caching of batch spec execution results was broken when re-execution could use the cached results of a step and that step was the only one left to execute. That resulted in empty diffs being uploaded. This is now fixed. [#567](https://github.com/sourcegraph/src-cli/pull/567)
0 commit comments