Fix wrong last step duration when job failed (#41)

This PR is to fix the wrong last step duration when job failed like shown in the screenshot.
The reason is because when job failed, `Fire` function did not pass in Time, and `r.state.StoppedAt` is by default set to `0001-01-01 08:05:43 +0805 LMT`, which is later on reported to gitea by `UpdateTask`, which calls `UpdateTaskByState` to update the `task.Stopped`, and `task.Stopped` is used in `FullSteps`, resulting in wrong calcaulation of last step duration.

Co-authored-by: nickname <test@123.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/41
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: HesterG <hesterg@noreply.gitea.io>
Co-committed-by: HesterG <hesterg@noreply.gitea.io>
This commit is contained in:
HesterG 2023-03-08 21:32:54 +08:00 committed by Earl Warren
parent 40954c450d
commit 048b2e630f
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -134,6 +134,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName string)
Data: log.Fields{ Data: log.Fields{
"jobResult": "failure", "jobResult": "failure",
}, },
Time: time.Now(),
}) })
} }
_ = reporter.Close(lastWords) _ = reporter.Close(lastWords)