From ebcf341de7a133bddac4752f124f3bafc2f348ce Mon Sep 17 00:00:00 2001 From: HesterG Date: Wed, 8 Mar 2023 21:32:54 +0800 Subject: [PATCH] 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 Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/act_runner/pulls/41 Reviewed-by: Jason Song Reviewed-by: Lunny Xiao Co-authored-by: HesterG Co-committed-by: HesterG --- runtime/task.go | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/task.go b/runtime/task.go index d13b6df..ef07022 100644 --- a/runtime/task.go +++ b/runtime/task.go @@ -137,6 +137,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName string) Data: log.Fields{ "jobResult": "failure", }, + Time: time.Now(), }) } _ = reporter.Close(lastWords)