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 3b5da409d fix(github): skip jobs with no started_at in 
cicd_job_convertor (#8488)
3b5da409d is described below

commit 3b5da409d991bb9056518515705abe197dc618b9
Author: Brend Smits <brend.sm...@philips.com>
AuthorDate: Mon Jul 7 05:29:34 2025 +0200

    fix(github): skip jobs with no started_at in cicd_job_convertor (#8488)
    
    This change skips GitHub job records that have no started_at value, as a 
workaround for #8442.
    
    Closes #8442
---
 backend/plugins/github/tasks/cicd_job_convertor.go |  8 +--
 .../github/tasks/cicd_job_convertor_test.go        | 67 +++++++++++++++++++++-
 2 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/backend/plugins/github/tasks/cicd_job_convertor.go 
b/backend/plugins/github/tasks/cicd_job_convertor.go
index e5e734d4e..81ef9cd4d 100644
--- a/backend/plugins/github/tasks/cicd_job_convertor.go
+++ b/backend/plugins/github/tasks/cicd_job_convertor.go
@@ -19,7 +19,6 @@ package tasks
 
 import (
        "reflect"
-       "time"
 
        "github.com/apache/incubator-devlake/core/dal"
        "github.com/apache/incubator-devlake/core/errors"
@@ -87,10 +86,11 @@ func ConvertJobs(taskCtx plugin.SubTaskContext) (err 
errors.Error) {
                Convert: func(inputRow interface{}) ([]interface{}, 
errors.Error) {
                        line := inputRow.(*models.GithubJob)
 
-                       createdAt := time.Now()
-                       if line.StartedAt != nil {
-                               createdAt = *line.StartedAt
+                       // Skip jobs with no started_at value (workaround for 
https://github.com/apache/incubator-devlake/issues/8442)
+                       if line.StartedAt == nil {
+                               return nil, nil
                        }
+                       createdAt := *line.StartedAt
                        domainJob := &devops.CICDTask{
                                DomainEntity: domainlayer.DomainEntity{Id: 
jobIdGen.Generate(data.Options.ConnectionId, line.RunID,
                                        line.ID)},
diff --git a/backend/plugins/github/tasks/cicd_job_convertor_test.go 
b/backend/plugins/github/tasks/cicd_job_convertor_test.go
index 9dd3045f1..7e3438289 100644
--- a/backend/plugins/github/tasks/cicd_job_convertor_test.go
+++ b/backend/plugins/github/tasks/cicd_job_convertor_test.go
@@ -19,12 +19,15 @@ package tasks
 
 import (
        "fmt"
+       "testing"
+       "time"
+
+       "github.com/apache/incubator-devlake/core/models/domainlayer/devops"
        "github.com/apache/incubator-devlake/core/models/domainlayer/didgen"
        "github.com/apache/incubator-devlake/core/plugin"
        mockplugin "github.com/apache/incubator-devlake/mocks/core/plugin"
        "github.com/apache/incubator-devlake/plugins/github/models"
        "github.com/stretchr/testify/assert"
-       "testing"
 )
 
 func GenJobIDWithReflect(jobIdGen *didgen.DomainIdGenerator) {
@@ -63,3 +66,65 @@ func BenchmarkGenJobID(b *testing.B) {
        }
        //BenchmarkGenJobID-8           11078593                99.43 ns/op
 }
+
+func TestConvertJobs_SkipNoStartedAt(t *testing.T) {
+          job := &models.GithubJob{
+                          ID:        123,
+                          RunID:     456,
+                          Name:      "test-job",
+                          StartedAt: nil,
+          }
+
+          convert := func(inputRow interface{}) ([]interface{}, error) {
+                          line := inputRow.(*models.GithubJob)
+                          if line.StartedAt == nil {
+                                          return nil, nil
+                          }
+                          createdAt := *line.StartedAt
+                          domainJob := &devops.CICDTask{
+                                          Name: line.Name,
+                                          TaskDatesInfo: devops.TaskDatesInfo{
+                                                          CreatedDate:  
createdAt,
+                                                          StartedDate:  
line.StartedAt,
+                                                          FinishedDate: 
line.CompletedAt,
+                                          },
+                          }
+                          return []interface{}{domainJob}, nil
+          }
+
+          result, err := convert(job)
+          assert.Nil(t, err)
+          assert.Nil(t, result)
+}
+
+func TestConvertJobs_WithStartedAt(t *testing.T) {
+          now := time.Now()
+          job := &models.GithubJob{
+                          ID:        123,
+                          RunID:     456,
+                          Name:      "test-job",
+                          StartedAt: &now,
+          }
+
+          convert := func(inputRow interface{}) ([]interface{}, error) {
+                          line := inputRow.(*models.GithubJob)
+                          if line.StartedAt == nil {
+                                          return nil, nil
+                          }
+                          createdAt := *line.StartedAt
+                          domainJob := &devops.CICDTask{
+                                          Name: line.Name,
+                                          TaskDatesInfo: devops.TaskDatesInfo{
+                                                          CreatedDate:  
createdAt,
+                                                          StartedDate:  
line.StartedAt,
+                                                          FinishedDate: 
line.CompletedAt,
+                                          },
+                          }
+                          return []interface{}{domainJob}, nil
+          }
+
+          result, err := convert(job)
+          assert.Nil(t, err)
+          assert.NotNil(t, result)
+          assert.Equal(t, "test-job", result[0].(*devops.CICDTask).Name)
+}

Reply via email to