This is an automated email from the ASF dual-hosted git repository.
abeizn 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 2dcdae4cf fix(gitlab): support `ENABLE_SUBTASKS_BY_DEFAULT` (#7612)
2dcdae4cf is described below
commit 2dcdae4cf8802c81d28b50f145a5f1c5d45cb0b0
Author: Lynwee <[email protected]>
AuthorDate: Thu Jun 13 14:05:49 2024 +0800
fix(gitlab): support `ENABLE_SUBTASKS_BY_DEFAULT` (#7612)
* fix(gitlab): support `ENABLE_SUBTASKS_BY_DEFAULT`
* fix(gitlab): fix unit test
* refactor(gitlab): remove unused codes
---
backend/core/models/pipeline.go | 3 ---
backend/plugins/gitlab/api/blueprint_V200_test.go | 28 ++++++++++++-----------
backend/plugins/gitlab/api/blueprint_v200.go | 22 +++++-------------
backend/plugins/gitlab/api/init.go | 2 ++
4 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/backend/core/models/pipeline.go b/backend/core/models/pipeline.go
index 4a0c944d9..2cdc3413f 100644
--- a/backend/core/models/pipeline.go
+++ b/backend/core/models/pipeline.go
@@ -29,9 +29,6 @@ type GenericPipelineTask[T any] struct {
Options T `json:"options"`
}
-type GenericPipelineStage[T any] []*GenericPipelineTask[T]
-type GenericPipelinePlan[T any] []GenericPipelineStage[T]
-
// PipelineTask represents a smallest unit of execution inside a PipelinePlan
type PipelineTask GenericPipelineTask[map[string]interface{}]
diff --git a/backend/plugins/gitlab/api/blueprint_V200_test.go
b/backend/plugins/gitlab/api/blueprint_V200_test.go
index f81280843..36b628e5d 100644
--- a/backend/plugins/gitlab/api/blueprint_V200_test.go
+++ b/backend/plugins/gitlab/api/blueprint_V200_test.go
@@ -36,7 +36,7 @@ func mockGitlabPlugin(t *testing.T) {
mockMeta := mockplugin.NewPluginMeta(t)
mockMeta.On("RootPkgPath").Return("github.com/apache/incubator-devlake/plugins/gitlab")
mockMeta.On("Name").Return("dummy").Maybe()
- err := plugin.RegisterPlugin("gitlab", mockMeta)
+ err := plugin.RegisterPlugin(pluginName, mockMeta)
assert.Equal(t, err, nil)
}
@@ -86,6 +86,18 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
const pathWithNamespace string = "nddtf/gitlab-test"
const expectDomainScopeId = "gitlab:GitlabProject:1:37"
+ scopeConfig := &models.GitlabScopeConfig{
+ ScopeConfig: common.ScopeConfig{
+ Entities: []string{plugin.DOMAIN_TYPE_CODE,
plugin.DOMAIN_TYPE_TICKET, plugin.DOMAIN_TYPE_CICD},
+ },
+ PrType: "hey,man,wasup",
+ Refdiff: map[string]interface{}{
+ "tagsPattern": "pattern",
+ "tagsLimit": 10,
+ "tagsOrder": "reverse semver",
+ },
+ }
+
actualPlans, err := makePipelinePlanV200(
[]plugin.SubTaskMeta{
tasks.ConvertProjectMeta,
@@ -119,17 +131,7 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
PathWithNamespace: pathWithNamespace,
HttpUrlToRepo: httpUrlToRepo,
},
- ScopeConfig: &models.GitlabScopeConfig{
- ScopeConfig: common.ScopeConfig{
- Entities:
[]string{plugin.DOMAIN_TYPE_CODE, plugin.DOMAIN_TYPE_TICKET,
plugin.DOMAIN_TYPE_CICD},
- },
- PrType: "hey,man,wasup",
- Refdiff: map[string]interface{}{
- "tagsPattern": "pattern",
- "tagsLimit": 10,
- "tagsOrder": "reverse semver",
- },
- },
+ ScopeConfig: scopeConfig,
},
},
)
@@ -138,7 +140,7 @@ func TestMakeDataSourcePipelinePlanV200(t *testing.T) {
var expectPlans = coreModels.PipelinePlan{
{
{
- Plugin: "gitlab",
+ Plugin: pluginName,
Subtasks: []string{
tasks.ConvertProjectMeta.Name,
tasks.CollectApiIssuesMeta.Name,
diff --git a/backend/plugins/gitlab/api/blueprint_v200.go
b/backend/plugins/gitlab/api/blueprint_v200.go
index 2596c4ba1..458d57bb3 100644
--- a/backend/plugins/gitlab/api/blueprint_v200.go
+++ b/backend/plugins/gitlab/api/blueprint_v200.go
@@ -114,26 +114,16 @@ func makePipelinePlanV200(
for _, scope := range scopeDetails {
gitlabProject, scopeConfig := scope.Scope, scope.ScopeConfig
var stage coreModels.PipelineStage
- var err errors.Error
- // get repo
-
- // gitlab main part
- options := make(map[string]interface{})
- options["connectionId"] = connection.ID
- options["projectId"] = gitlabProject.GitlabId
- options["fullName"] = gitlabProject.PathWithNamespace
-
// construct subtasks
- subtasks, err := helper.MakePipelinePlanSubtasks(subtaskMetas,
scopeConfig.Entities)
+ task, err := helper.MakePipelinePlanTask(pluginName,
subtaskMetas, scopeConfig.Entities, map[string]interface{}{
+ "connectionId": connection.ID,
+ "projectId": gitlabProject.GitlabId,
+ "fullName": gitlabProject.PathWithNamespace,
+ })
if err != nil {
return nil, err
}
-
- stage = append(stage, &coreModels.PipelineTask{
- Plugin: "gitlab",
- Subtasks: subtasks,
- Options: options,
- })
+ stage = append(stage, task)
// collect git data by gitextractor if CODE was requested
if utils.StringsContains(scopeConfig.Entities,
plugin.DOMAIN_TYPE_CODE) || len(scopeConfig.Entities) == 0 {
diff --git a/backend/plugins/gitlab/api/init.go
b/backend/plugins/gitlab/api/init.go
index 13148bb0c..fd63abcf0 100644
--- a/backend/plugins/gitlab/api/init.go
+++ b/backend/plugins/gitlab/api/init.go
@@ -25,6 +25,8 @@ import (
"github.com/go-playground/validator/v10"
)
+const pluginName = "gitlab"
+
var vld *validator.Validate
var basicRes context.BasicRes