diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a80f6371..a508109ad1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ All notable changes to `src-cli` are documented in this file. ### Fixed +- `src campaign [apply|preview]` now caches the result of running steps in a repository even if they didn't produce changes. + ## 3.21.8 ### Fixed diff --git a/internal/campaigns/executor.go b/internal/campaigns/executor.go index 07fb1e4294..92e4ec4925 100644 --- a/internal/campaigns/executor.go +++ b/internal/campaigns/executor.go @@ -261,6 +261,15 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) { return } + // Build the changeset spec. + spec := createChangesetSpec(task, string(diff), x.features) + + // Add to the cache. We don't use runCtx here because we want to write to + // the cache even if we've now reached the timeout. + if err = x.cache.Set(ctx, cacheKey, spec); err != nil { + err = errors.Wrapf(err, "caching result for %q", task.Repository.Name) + } + // If the steps didn't result in any diff, we don't need to add it to the // list of specs that are displayed to the user and send to the server. if len(diff) == 0 { @@ -268,18 +277,9 @@ func (x *executor) do(ctx context.Context, task *Task) (err error) { return } - // Build the changeset spec. - spec := createChangesetSpec(task, string(diff), x.features) - status.ChangesetSpec = spec x.updateTaskStatus(task, status) - // Add to the cache. We don't use runCtx here because we want to write to - // the cache even if we've now reached the timeout. - if err = x.cache.Set(ctx, cacheKey, spec); err != nil { - err = errors.Wrapf(err, "caching result for %q", task.Repository.Name) - } - // Add the spec to the executor's list of completed specs. x.specsMu.Lock() x.specs = append(x.specs, spec)