You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2025/04/21 09:37:42 UTC
(incubator-devlake) branch main updated: fix(github_graphql): Update Extract Jobs task to use Check Run instead of Check Suite (#8384)
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 b7fca146a fix(github_graphql): Update Extract Jobs task to use Check Run instead of Check Suite (#8384)
b7fca146a is described below
commit b7fca146a244620be60f1d2d40cbaa59156dd8fe
Author: benduncan-tote <12...@users.noreply.github.com>
AuthorDate: Mon Apr 21 10:37:37 2025 +0100
fix(github_graphql): Update Extract Jobs task to use Check Run instead of Check Suite (#8384)
Co-authored-by: Klesh Wong <zh...@merico.dev>
---
.../plugins/github_graphql/tasks/job_collector.go | 58 +++++++++++----------
.../plugins/github_graphql/tasks/job_extractor.go | 60 ++++++++++------------
2 files changed, 56 insertions(+), 62 deletions(-)
diff --git a/backend/plugins/github_graphql/tasks/job_collector.go b/backend/plugins/github_graphql/tasks/job_collector.go
index af25d5897..c73ecfa5d 100644
--- a/backend/plugins/github_graphql/tasks/job_collector.go
+++ b/backend/plugins/github_graphql/tasks/job_collector.go
@@ -55,38 +55,40 @@ type GraphqlQueryCheckSuite struct {
EndCursor string `graphql:"endCursor"`
HasNextPage bool `graphql:"hasNextPage"`
}
- Nodes []struct {
- Id string
- Name string
- DetailsUrl string
- DatabaseId int
- Status string
- StartedAt *time.Time
- Conclusion string
- CompletedAt *time.Time
- //ExternalId string
- //Url string
- //Title interface{}
- //Text interface{}
- //Summary interface{}
-
- Steps struct {
- TotalCount int
- Nodes []struct {
- CompletedAt *time.Time `json:"completed_at"`
- Conclusion string `json:"conclusion"`
- Name string `json:"name"`
- Number int `json:"number"`
- SecondsToCompletion int `json:"seconds_to_completion"`
- StartedAt *time.Time `json:"started_at"`
- Status string `json:"status"`
- }
- } `graphql:"steps(first: 50)"`
- }
+ Nodes []GraphqlQueryCheckRun
} `graphql:"checkRuns(first: $pageSize, after: $skipCursor)"`
} `graphql:"... on CheckSuite"`
}
+type GraphqlQueryCheckRun struct {
+ Id string
+ Name string
+ DetailsUrl string
+ DatabaseId int
+ Status string
+ StartedAt *time.Time
+ Conclusion string
+ CompletedAt *time.Time
+ //ExternalId string
+ //Url string
+ //Title interface{}
+ //Text interface{}
+ //Summary interface{}
+
+ Steps struct {
+ TotalCount int
+ Nodes []struct {
+ CompletedAt *time.Time `json:"completed_at"`
+ Conclusion string `json:"conclusion"`
+ Name string `json:"name"`
+ Number int `json:"number"`
+ SecondsToCompletion int `json:"seconds_to_completion"`
+ StartedAt *time.Time `json:"started_at"`
+ Status string `json:"status"`
+ }
+ } `graphql:"steps(first: 50)"`
+}
+
type SimpleWorkflowRun struct {
CheckSuiteNodeID string
}
diff --git a/backend/plugins/github_graphql/tasks/job_extractor.go b/backend/plugins/github_graphql/tasks/job_extractor.go
index 1bd035a7e..5d732eccd 100644
--- a/backend/plugins/github_graphql/tasks/job_extractor.go
+++ b/backend/plugins/github_graphql/tasks/job_extractor.go
@@ -51,50 +51,42 @@ func ExtractJobs(taskCtx plugin.SubTaskContext) errors.Error {
Table: RAW_GRAPHQL_JOBS_TABLE,
},
Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
- checkSuite := &GraphqlQueryCheckSuite{}
- err := errors.Convert(json.Unmarshal(row.Data, checkSuite))
+ checkRun := &GraphqlQueryCheckRun{}
+ err := errors.Convert(json.Unmarshal(row.Data, checkRun))
if err != nil {
return nil, err
}
results := make([]interface{}, 0, 1)
- for _, checkRun := range checkSuite.CheckSuite.CheckRuns.Nodes {
- paramsBytes, err := json.Marshal(checkRun.Steps.Nodes)
- if err != nil {
- taskCtx.GetLogger().Error(err, `Marshal checkRun.Steps.Nodes fail and ignore`)
- }
- githubJob := &models.GithubJob{
- ConnectionId: data.Options.ConnectionId,
- RunID: checkSuite.CheckSuite.WorkflowRun.DatabaseId,
- RepoId: data.Options.GithubId,
- ID: checkRun.DatabaseId,
- NodeID: checkRun.Id,
- HTMLURL: checkRun.DetailsUrl,
- Status: strings.ToUpper(checkRun.Status),
- Conclusion: strings.ToUpper(checkRun.Conclusion),
- StartedAt: checkRun.StartedAt,
- CompletedAt: checkRun.CompletedAt,
- Name: checkRun.Name,
- Steps: paramsBytes,
- Type: data.RegexEnricher.ReturnNameIfMatched(devops.DEPLOYMENT, checkRun.Name),
- Environment: data.RegexEnricher.ReturnNameIfOmittedOrMatched(devops.PRODUCTION, checkRun.Name),
- // these columns can not fill by graphql
- //HeadSha: ``, // use _tool_github_runs
- //RunURL: ``,
- //CheckRunURL: ``,
- //Labels: ``, // not in use
- //RunnerID: ``, // not in use
- //RunnerName: ``, // not in use
- //RunnerGroupID: ``, // not in use
- }
- results = append(results, githubJob)
+
+ paramsBytes, marshalError := json.Marshal(checkRun.Steps.Nodes)
+ err = errors.Convert(marshalError)
+ if err != nil {
+ taskCtx.GetLogger().Error(err, `Marshal checkRun.Steps.Nodes failed`)
}
- return results, nil
+ githubJob := &models.GithubJob{
+ ConnectionId: data.Options.ConnectionId,
+ RunID: checkRun.DatabaseId,
+ RepoId: data.Options.GithubId,
+ ID: checkRun.DatabaseId,
+ NodeID: checkRun.Id,
+ HTMLURL: checkRun.DetailsUrl,
+ Status: strings.ToUpper(checkRun.Status),
+ Conclusion: strings.ToUpper(checkRun.Conclusion),
+ StartedAt: checkRun.StartedAt,
+ CompletedAt: checkRun.CompletedAt,
+ Name: checkRun.Name,
+ Steps: paramsBytes,
+ Type: data.RegexEnricher.ReturnNameIfMatched(devops.DEPLOYMENT, checkRun.Name),
+ Environment: data.RegexEnricher.ReturnNameIfOmittedOrMatched(devops.PRODUCTION, checkRun.Name),
+ }
+ results = append(results, githubJob)
+ return results, nil
},
})
if err != nil {
- return err
+ return errors.Convert(err)
}
return extractor.Execute()