This is an automated email from the ASF dual-hosted git repository.
lynwee pushed a commit to branch release-v1.0
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v1.0 by this push:
new 010f471fc feat(domain): add is_child field to table cicd_pipelines
(#8006) (#8008)
010f471fc is described below
commit 010f471fc96ea439df59c8e3f24886016111c482
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Sep 6 15:11:50 2024 +0800
feat(domain): add is_child field to table cicd_pipelines (#8006) (#8008)
* feat(domain): add is_child field to table cicd_pipelines
* fix(test): fix e2e
* fix(test): fix e2e
Co-authored-by: Lynwee <[email protected]>
---
.../models/domainlayer/devops/cicd_pipeline.go | 1 +
.../20240906_add_is_child_to_cicd_pipelines.go | 52 ++++++++++++++++++++++
backend/core/models/migrationscripts/register.go | 1 +
backend/plugins/bamboo/e2e/plan_build_test.go | 5 ++-
backend/plugins/circleci/e2e/workflow_test.go | 2 +-
backend/plugins/github/e2e/cicd_run_test.go | 5 ++-
.../plugins/gitlab/e2e/pipelines_detail_test.go | 5 ++-
7 files changed, 64 insertions(+), 7 deletions(-)
diff --git a/backend/core/models/domainlayer/devops/cicd_pipeline.go
b/backend/core/models/domainlayer/devops/cicd_pipeline.go
index e05d573b6..3a0a34f46 100644
--- a/backend/core/models/domainlayer/devops/cicd_pipeline.go
+++ b/backend/core/models/domainlayer/devops/cicd_pipeline.go
@@ -40,6 +40,7 @@ type CICDPipeline struct {
Environment string `gorm:"type:varchar(255)"`
TaskDatesInfo
CicdScopeId string `gorm:"index;type:varchar(255)"`
+ IsChild bool
}
func (CICDPipeline) TableName() string {
diff --git
a/backend/core/models/migrationscripts/20240906_add_is_child_to_cicd_pipelines.go
b/backend/core/models/migrationscripts/20240906_add_is_child_to_cicd_pipelines.go
new file mode 100644
index 000000000..3cf14e8d9
--- /dev/null
+++
b/backend/core/models/migrationscripts/20240906_add_is_child_to_cicd_pipelines.go
@@ -0,0 +1,52 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+)
+
+var _ plugin.MigrationScript = (*addIsChildToCicdPipeline)(nil)
+
+type cicdPipeline20240906 struct {
+ IsChild bool
+}
+
+func (cicdPipeline20240906) TableName() string {
+ return "cicd_pipelines"
+}
+
+type addIsChildToCicdPipeline struct{}
+
+func (*addIsChildToCicdPipeline) Up(basicRes context.BasicRes) errors.Error {
+ db := basicRes.GetDal()
+ if err := db.AutoMigrate(&cicdPipeline20240906{}); err != nil {
+ return err
+ }
+ return nil
+}
+
+func (*addIsChildToCicdPipeline) Version() uint64 {
+ return 20240906120000
+}
+
+func (*addIsChildToCicdPipeline) Name() string {
+ return "add is_child to cicd_pipelines"
+}
diff --git a/backend/core/models/migrationscripts/register.go
b/backend/core/models/migrationscripts/register.go
index 1a220e496..3a5bb5ec4 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -132,5 +132,6 @@ func All() []plugin.MigrationScript {
new(addTableScopeIdToIncident),
new(addAssigneeToIncident),
new(addIsSubtaskToIssue),
+ new(addIsChildToCicdPipeline),
}
}
diff --git a/backend/plugins/bamboo/e2e/plan_build_test.go
b/backend/plugins/bamboo/e2e/plan_build_test.go
index 7c3ea69ec..67584f8f1 100644
--- a/backend/plugins/bamboo/e2e/plan_build_test.go
+++ b/backend/plugins/bamboo/e2e/plan_build_test.go
@@ -107,7 +107,8 @@ func TestBambooPlanBuildDataFlow(t *testing.T) {
dataflowTester.Subtask(tasks.ConvertPlanBuildsMeta, taskData)
dataflowTester.VerifyTableWithOptions(&devops.CICDPipeline{},
e2ehelper.TableOptions{
- CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
- IgnoreTypes: []interface{}{common.NoPKModel{}},
+ CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
+ IgnoreTypes: []interface{}{common.NoPKModel{}},
+ IgnoreFields: []string{"is_child"},
})
}
diff --git a/backend/plugins/circleci/e2e/workflow_test.go
b/backend/plugins/circleci/e2e/workflow_test.go
index e4418f2e3..cc542fdb2 100644
--- a/backend/plugins/circleci/e2e/workflow_test.go
+++ b/backend/plugins/circleci/e2e/workflow_test.go
@@ -72,7 +72,7 @@ func TestCircleciWorkflow(t *testing.T) {
devops.CICDPipeline{},
e2ehelper.TableOptions{
CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
- IgnoreFields: []string{"finished_date", "created_date"},
+ IgnoreFields: []string{"finished_date", "created_date",
"is_child"},
IgnoreTypes: []interface{}{domainlayer.DomainEntity{}},
},
)
diff --git a/backend/plugins/github/e2e/cicd_run_test.go
b/backend/plugins/github/e2e/cicd_run_test.go
index 0d7d01df6..750b22e5e 100644
--- a/backend/plugins/github/e2e/cicd_run_test.go
+++ b/backend/plugins/github/e2e/cicd_run_test.go
@@ -70,8 +70,9 @@ func TestGithubCICDRunDataFlow(t *testing.T) {
dataflowTester.FlushTabler(&devops.CiCDPipelineCommit{})
dataflowTester.Subtask(tasks.ConvertRunsMeta, taskData)
dataflowTester.VerifyTableWithOptions(&devops.CICDPipeline{},
e2ehelper.TableOptions{
- CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
- IgnoreTypes: []interface{}{common.NoPKModel{}},
+ CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
+ IgnoreTypes: []interface{}{common.NoPKModel{}},
+ IgnoreFields: []string{"is_child"},
})
dataflowTester.VerifyTableWithOptions(&devops.CiCDPipelineCommit{},
e2ehelper.TableOptions{
diff --git a/backend/plugins/gitlab/e2e/pipelines_detail_test.go
b/backend/plugins/gitlab/e2e/pipelines_detail_test.go
index 33c8b2862..ea1c3dc2c 100644
--- a/backend/plugins/gitlab/e2e/pipelines_detail_test.go
+++ b/backend/plugins/gitlab/e2e/pipelines_detail_test.go
@@ -84,8 +84,9 @@ func TestGitlabPipelineDetailDataFlow(t *testing.T) {
dataflowTester.Subtask(tasks.ConvertDetailPipelineMeta, taskData)
dataflowTester.Subtask(tasks.ConvertPipelineCommitMeta, taskData)
dataflowTester.VerifyTableWithOptions(&devops.CICDPipeline{},
e2ehelper.TableOptions{
- CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
- IgnoreTypes: []interface{}{common.NoPKModel{}},
+ CSVRelPath: "./snapshot_tables/cicd_pipelines.csv",
+ IgnoreTypes: []interface{}{common.NoPKModel{}},
+ IgnoreFields: []string{"is_child"},
})
dataflowTester.VerifyTableWithOptions(&devops.CiCDPipelineCommit{},
e2ehelper.TableOptions{