You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ly...@apache.org on 2023/10/11 07:12:40 UTC
[incubator-devlake] branch main updated: GitHub skipped jobs collected by GraphQL is not handled properly (#6217)
This is an automated email from the ASF dual-hosted git repository.
lynwee 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 61be3cd42 GitHub skipped jobs collected by GraphQL is not handled properly (#6217)
61be3cd42 is described below
commit 61be3cd42b8d2b675cd74fb3227a0c548e931ce0
Author: Klesh Wong <zh...@merico.dev>
AuthorDate: Wed Oct 11 15:12:35 2023 +0800
GitHub skipped jobs collected by GraphQL is not handled properly (#6217)
* fix: skipped github jobs were not handled properly
* refactor: skip running pipelines when collecting
---
backend/plugins/github/tasks/cicd_job_convertor.go | 2 +-
backend/plugins/github/tasks/cicd_run_collector.go | 36 +---------------------
2 files changed, 2 insertions(+), 36 deletions(-)
diff --git a/backend/plugins/github/tasks/cicd_job_convertor.go b/backend/plugins/github/tasks/cicd_job_convertor.go
index 6b93d51c9..7041fb23e 100644
--- a/backend/plugins/github/tasks/cicd_job_convertor.go
+++ b/backend/plugins/github/tasks/cicd_job_convertor.go
@@ -99,7 +99,7 @@ func ConvertJobs(taskCtx plugin.SubTaskContext) (err errors.Error) {
Result: devops.GetResult(&devops.ResultRule{
Failed: []string{"failure"},
Success: []string{"success"},
- Skipped: []string{"skipped"},
+ Skipped: []string{"skipped", "NEUTRAL"},
}, line.Conclusion),
Status: devops.GetStatus(&devops.StatusRule[string]{
Done: []string{"completed", "COMPLETED"},
diff --git a/backend/plugins/github/tasks/cicd_run_collector.go b/backend/plugins/github/tasks/cicd_run_collector.go
index f29958575..c94f194ca 100644
--- a/backend/plugins/github/tasks/cicd_run_collector.go
+++ b/backend/plugins/github/tasks/cicd_run_collector.go
@@ -20,18 +20,14 @@ package tasks
import (
"encoding/json"
"fmt"
- "io"
"net/http"
"net/url"
- "reflect"
"time"
- "github.com/apache/incubator-devlake/core/dal"
"github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/models/common"
"github.com/apache/incubator-devlake/core/plugin"
helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
- "github.com/apache/incubator-devlake/plugins/github/models"
)
func init() {
@@ -67,7 +63,6 @@ var CollectRunsMeta = plugin.SubTaskMeta{
func CollectRuns(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*GithubTaskData)
- db := taskCtx.GetDal()
collector, err := helper.NewStatefulApiCollectorForFinalizableEntity(helper.FinalizableApiCollectorArgs{
RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
Ctx: taskCtx,
@@ -85,6 +80,7 @@ func CollectRuns(taskCtx plugin.SubTaskContext) errors.Error {
UrlTemplate: "repos/{{ .Params.Name }}/actions/runs",
Query: func(reqData *helper.RequestData, createdAfter *time.Time) (url.Values, errors.Error) {
query := url.Values{}
+ query.Set("status", "completed")
query.Set("page", fmt.Sprintf("%v", reqData.Pager.Page))
query.Set("per_page", fmt.Sprintf("%v", reqData.Pager.Size))
return query, nil
@@ -110,36 +106,6 @@ func CollectRuns(taskCtx plugin.SubTaskContext) errors.Error {
return pj.CreatedAt.ToTime(), nil
},
},
- CollectUnfinishedDetails: &helper.FinalizableApiCollectorDetailArgs{
- BuildInputIterator: func() (helper.Iterator, errors.Error) {
- // load unfinished runs from the database
- cursor, err := db.Cursor(
- dal.Select("id"),
- dal.From(&models.GithubRun{}),
- dal.Where(
- "repo_id = ? AND connection_id = ? AND status IN ('ACTION_REQUIRED', 'STALE', 'IN_PROGRESS', 'QUEUED', 'REQUESTED', 'WAITING', 'PENDING')",
- data.Options.GithubId, data.Options.ConnectionId,
- ),
- )
- if err != nil {
- return nil, err
- }
- return helper.NewDalCursorIterator(db, cursor, reflect.TypeOf(SimpleGithubApiJob{}))
- },
-
- FinalizableApiCollectorCommonArgs: helper.FinalizableApiCollectorCommonArgs{
- UrlTemplate: "repos/{{ .Params.Name }}/actions/runs/{{ .Input.ID }}",
- ResponseParser: func(res *http.Response) ([]json.RawMessage, errors.Error) {
- body, err := io.ReadAll(res.Body)
- if err != nil {
- return nil, errors.Convert(err)
- }
- res.Body.Close()
- return []json.RawMessage{body}, nil
- },
- AfterResponse: ignoreHTTPStatus404,
- },
- },
})
if err != nil {