Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gitlab): support ENABLE_SUBTASKS_BY_DEFAULT #7612

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions backend/core/models/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}]

Expand Down
28 changes: 15 additions & 13 deletions backend/plugins/gitlab/api/blueprint_V200_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
},
)
Expand All @@ -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,
Expand Down
22 changes: 6 additions & 16 deletions backend/plugins/gitlab/api/blueprint_v200.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions backend/plugins/gitlab/api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/go-playground/validator/v10"
)

const pluginName = "gitlab"

var vld *validator.Validate

var basicRes context.BasicRes
Expand Down
Loading