From 048b2e630fc4203816c4136bef929441aec2788e 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 561fd9c..ac15323 100644 --- a/runtime/task.go +++ b/runtime/task.go @@ -134,6 +134,7 @@ func (t *Task) Run(ctx context.Context, task *runnerv1.Task, runnerName string) Data: log.Fields{ "jobResult": "failure", }, + Time: time.Now(), }) } _ = reporter.Close(lastWords)