This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new ad698c5bf fix(circleci): prevent negative values when calculating
circleci (#8800)
ad698c5bf is described below
commit ad698c5bfbcc70760aae3edc4110138415d0add7
Author: Chris Pavlicek <[email protected]>
AuthorDate: Wed Apr 1 13:52:58 2026 +0100
fix(circleci): prevent negative values when calculating circleci (#8800)
workflow duration
---
backend/plugins/circleci/circleci | Bin 0 -> 39212626 bytes
.../e2e/raw_tables/_raw_circleci_api_workflows.csv | 2 +-
.../e2e/snapshot_tables/_tool_circleci_workflows.csv | 2 +-
.../circleci/e2e/snapshot_tables/cicd_pipelines.csv | 2 +-
backend/plugins/circleci/tasks/workflow_extractor.go | 6 +++++-
5 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/backend/plugins/circleci/circleci
b/backend/plugins/circleci/circleci
new file mode 100755
index 000000000..745e690b9
Binary files /dev/null and b/backend/plugins/circleci/circleci differ
diff --git
a/backend/plugins/circleci/e2e/raw_tables/_raw_circleci_api_workflows.csv
b/backend/plugins/circleci/e2e/raw_tables/_raw_circleci_api_workflows.csv
index 5760d52da..a599e8aeb 100644
--- a/backend/plugins/circleci/e2e/raw_tables/_raw_circleci_api_workflows.csv
+++ b/backend/plugins/circleci/e2e/raw_tables/_raw_circleci_api_workflows.csv
@@ -96,7 +96,7 @@ id,params,data,url,input,created_at
""started_by"" : ""1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7"",
""pipeline_number"" : 8,
""created_at"" : ""2023-03-25T18:06:13Z"",
- ""stopped_at"" : ""2023-03-25T18:06:28Z""
+ ""stopped_at"" : ""2023-03-25T18:05:28Z""
}",https://circleci.com/api/v2/pipeline/afe0cabe-e7ee-4eb7-bf13-bb6170d139f0/workflow,"{""id"":
""afe0cabe-e7ee-4eb7-bf13-bb6170d139f0"", ""vcs"": {""tag"": """", ""branch"":
"""", ""commit"": {""body"": """", ""subject"": """"}, ""revision"": """",
""review_id"": """", ""review_url"": """", ""provider_name"": """",
""origin_repository_url"": """", ""target_repository_url"": """"}, ""state"":
"""", ""errors"": null, ""number"": 0, ""trigger"": {""type"": """", ""actor"":
{""login"": "" [...]
28,"{""ConnectionId"":1,""ProjectSlug"":""github/coldgust/coldgust.github.io""}","{
""pipeline_id"" : ""f5a2a6e8-4430-4935-8bec-77ca2b26c61d"",
diff --git
a/backend/plugins/circleci/e2e/snapshot_tables/_tool_circleci_workflows.csv
b/backend/plugins/circleci/e2e/snapshot_tables/_tool_circleci_workflows.csv
index bd6af7cc9..eb1e03e8e 100644
--- a/backend/plugins/circleci/e2e/snapshot_tables/_tool_circleci_workflows.csv
+++ b/backend/plugins/circleci/e2e/snapshot_tables/_tool_circleci_workflows.csv
@@ -7,5 +7,5 @@
connection_id,id,project_slug,pipeline_id,canceled_by,name,errored_by,tag,status
1,b3b77371-e27a-4e93-a554-c728f757cd24,github/coldgust/coldgust.github.io,f5a2a6e8-4430-4935-8bec-77ca2b26c61d,,workflow,,,failed,,16,,,0
1,b9ab7bbe-2f30-4c59-b4e2-eb2005bffb14,github/coldgust/coldgust.github.io,70f3eb15-3b94-4f80-b65e-f23f4b74c33a,,workflow,,,failed,1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7,6,2023-03-25T17:54:09.000+00:00,2023-03-25T17:54:23.000+00:00,14
1,c7df82a6-0d2b-4e19-a36a-3f3aa9fd3943,github/coldgust/coldgust.github.io,2c45280f-7fb3-4025-b703-a547c4a94916,,workflow,,,failed,1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7,4,2023-03-25T17:50:20.000+00:00,2023-03-25T17:50:25.000+00:00,5
-1,fc76deef-bcdd-4856-8e96-a8e2d1c5a85f,github/coldgust/coldgust.github.io,afe0cabe-e7ee-4eb7-bf13-bb6170d139f0,,workflow,,,failed,1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7,8,2023-03-25T18:06:13.000+00:00,2023-03-25T18:06:28.000+00:00,15
+1,fc76deef-bcdd-4856-8e96-a8e2d1c5a85f,github/coldgust/coldgust.github.io,afe0cabe-e7ee-4eb7-bf13-bb6170d139f0,,workflow,,,failed,1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7,8,2023-03-25T18:06:13.000+00:00,2023-03-25T18:05:28.000+00:00,0
1,fd0bd4f5-264f-4e3c-a151-06153c018f78,github/coldgust/coldgust.github.io,7fcc1623-edcc-4a76-ad20-cd81aa83519f,,workflow,,,success,1c762fc2-b0fb-4fe2-97d2-5e54ddd1eba7,9,2023-03-25T18:13:21.000+00:00,2023-03-25T18:13:38.000+00:00,17
diff --git a/backend/plugins/circleci/e2e/snapshot_tables/cicd_pipelines.csv
b/backend/plugins/circleci/e2e/snapshot_tables/cicd_pipelines.csv
index 54a7ede5d..40e7b614a 100644
--- a/backend/plugins/circleci/e2e/snapshot_tables/cicd_pipelines.csv
+++ b/backend/plugins/circleci/e2e/snapshot_tables/cicd_pipelines.csv
@@ -6,5 +6,5 @@
circleci:CircleciWorkflow:1:8971a56b-5547-4824-94dd-07bb467524c5,say-hello-workf
circleci:CircleciWorkflow:1:8fe60291-68f7-40e2-acec-d99bff4da713,say-hello-workflow,say-hello-workflow#1,,SUCCESS,DONE,success,,,4,,PRODUCTION,,2023-03-25T17:12:18.000+00:00,2023-03-25T17:12:18.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
circleci:CircleciWorkflow:1:b9ab7bbe-2f30-4c59-b4e2-eb2005bffb14,workflow,workflow#6,,FAILURE,DONE,failed,,,14,,PRODUCTION,,2023-03-25T17:54:09.000+00:00,2023-03-25T17:54:09.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
circleci:CircleciWorkflow:1:c7df82a6-0d2b-4e19-a36a-3f3aa9fd3943,workflow,workflow#4,,FAILURE,DONE,failed,,,5,,PRODUCTION,,2023-03-25T17:50:20.000+00:00,2023-03-25T17:50:20.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
-circleci:CircleciWorkflow:1:fc76deef-bcdd-4856-8e96-a8e2d1c5a85f,workflow,workflow#8,,FAILURE,DONE,failed,,,15,,PRODUCTION,,2023-03-25T18:06:13.000+00:00,2023-03-25T18:06:13.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
+circleci:CircleciWorkflow:1:fc76deef-bcdd-4856-8e96-a8e2d1c5a85f,workflow,workflow#8,,FAILURE,DONE,failed,,,0,,PRODUCTION,,2023-03-25T18:06:13.000+00:00,2023-03-25T18:06:13.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
circleci:CircleciWorkflow:1:fd0bd4f5-264f-4e3c-a151-06153c018f78,workflow,workflow#9,,SUCCESS,DONE,success,,,17,,PRODUCTION,,2023-03-25T18:13:21.000+00:00,2023-03-25T18:13:21.000+00:00,circleci:CircleciProject:1:github/coldgust/coldgust.github.io
diff --git a/backend/plugins/circleci/tasks/workflow_extractor.go
b/backend/plugins/circleci/tasks/workflow_extractor.go
index 165c6d635..27ec520a0 100644
--- a/backend/plugins/circleci/tasks/workflow_extractor.go
+++ b/backend/plugins/circleci/tasks/workflow_extractor.go
@@ -19,6 +19,7 @@ package tasks
import (
"encoding/json"
+
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
"github.com/apache/incubator-devlake/helpers/pluginhelper/api"
@@ -51,7 +52,10 @@ func ExtractWorkflows(taskCtx plugin.SubTaskContext)
errors.Error {
if userRes.CreatedDate != nil && userRes.StoppedAt !=
nil {
startTime := userRes.CreatedDate.ToTime()
endTime := userRes.StoppedAt.ToTime()
- toolL.DurationSec =
float64(endTime.Sub(startTime).Milliseconds() / 1e3)
+ durationSec := endTime.Sub(startTime).Seconds()
+ if durationSec >= 0 {
+ toolL.DurationSec = durationSec
+ }
}
return []interface{}{
&toolL,