@@ -18,8 +18,32 @@ func FullSteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep {
18
18
return fullStepsOfEmptySteps (task )
19
19
}
20
20
21
- firstStep := task .Steps [0 ]
21
+ // firstStep is the first step that has run or running, not include preStep.
22
+ // For example,
23
+ // 1. preStep(Success) -> step1(Success) -> step2(Running) -> step3(Waiting) -> postStep(Waiting): firstStep is step1.
24
+ // 2. preStep(Success) -> step1(Skipped) -> step2(Success) -> postStep(Success): firstStep is step2.
25
+ // 3. preStep(Success) -> step1(Running) -> step2(Waiting) -> postStep(Waiting): firstStep is step1.
26
+ // 4. preStep(Success) -> step1(Skipped) -> step2(Skipped) -> postStep(Skipped): firstStep is nil.
27
+ // 5. preStep(Success) -> step1(Cancelled) -> step2(Cancelled) -> postStep(Cancelled): firstStep is nil.
28
+ var firstStep * actions_model.ActionTaskStep
29
+ // lastHasRunStep is the last step that has run.
30
+ // For example,
31
+ // 1. preStep(Success) -> step1(Success) -> step2(Running) -> step3(Waiting) -> postStep(Waiting): lastHasRunStep is step1.
32
+ // 2. preStep(Success) -> step1(Success) -> step2(Success) -> step3(Success) -> postStep(Success): lastHasRunStep is step3.
33
+ // 3. preStep(Success) -> step1(Success) -> step2(Failure) -> step3 -> postStep(Waiting): lastHasRunStep is step2.
34
+ // So its Stopped is the Started of postStep when there are no more steps to run.
35
+ var lastHasRunStep * actions_model.ActionTaskStep
36
+
22
37
var logIndex int64
38
+ for _ , step := range task .Steps {
39
+ if firstStep == nil && (step .Status .HasRun () || step .Status .IsRunning ()) {
40
+ firstStep = step
41
+ }
42
+ if step .Status .HasRun () {
43
+ lastHasRunStep = step
44
+ }
45
+ logIndex += step .LogLength
46
+ }
23
47
24
48
preStep := & actions_model.ActionTaskStep {
25
49
Name : preStepName ,
@@ -28,32 +52,17 @@ func FullSteps(task *actions_model.ActionTask) []*actions_model.ActionTaskStep {
28
52
Status : actions_model .StatusRunning ,
29
53
}
30
54
31
- if firstStep .Status .HasRun () || firstStep .Status .IsRunning () {
55
+ // No step has run or is running, so preStep is equal to the task
56
+ if firstStep == nil {
57
+ preStep .Stopped = task .Stopped
58
+ preStep .Status = task .Status
59
+ } else {
32
60
preStep .LogLength = firstStep .LogIndex
33
61
preStep .Stopped = firstStep .Started
34
62
preStep .Status = actions_model .StatusSuccess
35
- } else if task .Status .IsDone () {
36
- preStep .Stopped = task .Stopped
37
- preStep .Status = actions_model .StatusFailure
38
- if task .Status .IsSkipped () {
39
- preStep .Status = actions_model .StatusSkipped
40
- }
41
63
}
42
64
logIndex += preStep .LogLength
43
65
44
- // lastHasRunStep is the last step that has run.
45
- // For example,
46
- // 1. preStep(Success) -> step1(Success) -> step2(Running) -> step3(Waiting) -> postStep(Waiting): lastHasRunStep is step1.
47
- // 2. preStep(Success) -> step1(Success) -> step2(Success) -> step3(Success) -> postStep(Success): lastHasRunStep is step3.
48
- // 3. preStep(Success) -> step1(Success) -> step2(Failure) -> step3 -> postStep(Waiting): lastHasRunStep is step2.
49
- // So its Stopped is the Started of postStep when there are no more steps to run.
50
- var lastHasRunStep * actions_model.ActionTaskStep
51
- for _ , step := range task .Steps {
52
- if step .Status .HasRun () {
53
- lastHasRunStep = step
54
- }
55
- logIndex += step .LogLength
56
- }
57
66
if lastHasRunStep == nil {
58
67
lastHasRunStep = preStep
59
68
}
0 commit comments