Skip to content

Commit 3cde7b6

Browse files
Ruben Tordjmanrclsilver
Ruben Tordjman
authored andcommitted
fix(step): Prevented step's conditions from being evaluated when the step isn't in a final state
Signed-off-by: Ruben Tordjman <[email protected]>
1 parent f9892e1 commit 3cde7b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

engine/step/step.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"encoding/json"
77
"fmt"
8+
"slices"
89
"sort"
910
"strings"
1011
"sync"
@@ -65,6 +66,7 @@ var (
6566
stepConditionValidStates = []string{StateDone, StatePrune, StateToRetry, StateRetryNow, StateFatalError, StateClientError}
6667
runnableStates = []string{StateTODO, StateServerError, StateClientError, StateFatalError, StateCrashed, StateToRetry, StateRetryNow, StateAfterrunError, StateExpanded, StateWaiting} // everything but RUNNING, DONE, PRUNE
6768
retriableStates = []string{StateServerError, StateToRetry, StateAfterrunError}
69+
validAfterRunStates = []string{StateDone, StateClientError, StateAfterrunError}
6870
)
6971

7072
// Step describes one unit of work within a task, and its dependency to other steps
@@ -531,7 +533,8 @@ func PreRun(st *Step, values *values.Values, ss StateSetter, executedSteps map[s
531533
// AfterRun evaluates a step's "check" conditions after the Step's action has been performed
532534
// and impacts the entire task's execution flow through the provided StateSetter
533535
func AfterRun(st *Step, values *values.Values, ss StateSetter) {
534-
if st.skipped || st.State == StateServerError || st.State == StateFatalError || st.ForEach != "" {
536+
// Not all steps' states should trigger evaluation of AfterRun conditions
537+
if st.skipped || st.ForEach != "" || !slices.Contains(validAfterRunStates, st.State) {
535538
return
536539
}
537540

0 commit comments

Comments
 (0)