@@ -52,9 +52,44 @@ func (rc *RunContext) String() string {
5252 return fmt .Sprintf ("%s/%s" , rc .Run .Workflow .Name , rc .Name )
5353}
5454
55+ type stepStatus int
56+
57+ const (
58+ stepStatusSuccess stepStatus = iota
59+ stepStatusFailure
60+ )
61+
62+ var stepStatusStrings = [... ]string {
63+ "success" ,
64+ "failure" ,
65+ }
66+
67+ func (s stepStatus ) MarshalText () ([]byte , error ) {
68+ return []byte (s .String ()), nil
69+ }
70+
71+ func (s * stepStatus ) UnmarshalText (b []byte ) error {
72+ str := string (b )
73+ for i , name := range stepStatusStrings {
74+ if name == str {
75+ * s = stepStatus (i )
76+ return nil
77+ }
78+ }
79+ return fmt .Errorf ("invalid step status %q" , str )
80+ }
81+
82+ func (s stepStatus ) String () string {
83+ if int (s ) >= len (stepStatusStrings ) {
84+ return ""
85+ }
86+ return stepStatusStrings [s ]
87+ }
88+
5589type stepResult struct {
56- Success bool `json:"success"`
57- Outputs map [string ]string `json:"outputs"`
90+ Outputs map [string ]string `json:"outputs"`
91+ Conclusion stepStatus `json:"conclusion"`
92+ Outcome stepStatus `json:"outcome"`
5893}
5994
6095// GetEnv returns the env for the context
@@ -266,8 +301,9 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor {
266301 return func (ctx context.Context ) error {
267302 rc .CurrentStep = sc .Step .ID
268303 rc .StepResults [rc .CurrentStep ] = & stepResult {
269- Success : true ,
270- Outputs : make (map [string ]string ),
304+ Outcome : stepStatusSuccess ,
305+ Conclusion : stepStatusSuccess ,
306+ Outputs : make (map [string ]string ),
271307 }
272308 runStep , err := rc .EvalBool (sc .Step .If .Value )
273309
@@ -278,7 +314,8 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor {
278314 return err
279315 }
280316 rc .ExprEval = exprEval
281- rc .StepResults [rc .CurrentStep ].Success = false
317+ rc .StepResults [rc .CurrentStep ].Conclusion = stepStatusFailure
318+ rc .StepResults [rc .CurrentStep ].Outcome = stepStatusFailure
282319 return err
283320 }
284321
@@ -300,12 +337,13 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor {
300337 } else {
301338 common .Logger (ctx ).Errorf (" \u274C Failure - %s" , sc .Step )
302339
340+ rc .StepResults [rc .CurrentStep ].Outcome = stepStatusFailure
303341 if sc .Step .ContinueOnError {
304342 common .Logger (ctx ).Infof ("Failed but continue next step" )
305343 err = nil
306- rc .StepResults [rc .CurrentStep ].Success = true
344+ rc .StepResults [rc .CurrentStep ].Conclusion = stepStatusSuccess
307345 } else {
308- rc .StepResults [rc .CurrentStep ].Success = false
346+ rc .StepResults [rc .CurrentStep ].Conclusion = stepStatusFailure
309347 }
310348 }
311349 return err
@@ -500,7 +538,7 @@ type jobContext struct {
500538func (rc * RunContext ) getJobContext () * jobContext {
501539 jobStatus := "success"
502540 for _ , stepStatus := range rc .StepResults {
503- if ! stepStatus .Success {
541+ if stepStatus .Conclusion == stepStatusFailure {
504542 jobStatus = "failure"
505543 break
506544 }
0 commit comments