fix(actions): never show negative running durations (#39322)

This commit is contained in:
silverwind
2026-09-15 21:33:17 +02:00
committed by GitHub
parent 812191c0f9
commit f9d3268dbe
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ func calculateDuration(started, stopped timeutil.TimeStamp, status Status, fallb
}
return end.AsTime().Sub(s)
}
return timeSince(s).Truncate(time.Second)
return max(timeSince(s), 0).Truncate(time.Second)
}
// best effort function to convert an action schedule to action run, to be used in GenerateGiteaContext
+8
View File
@@ -73,6 +73,14 @@ func Test_calculateDuration(t *testing.T) {
},
want: 500 * time.Second,
},
{
name: "running started in the future",
args: args{
started: 1005,
status: StatusRunning,
},
want: 0,
},
{
name: "done",
args: args{