You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2022/09/16 12:11:41 UTC
[incubator-devlake] branch main updated: fix(framwork): remove build and job
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 b8b11996 fix(framwork): remove build and job
b8b11996 is described below
commit b8b11996c8d5b3edd679e80cdf4e9f55893a843f
Author: Yingchu Chen <yi...@merico.dev>
AuthorDate: Fri Sep 16 19:54:51 2022 +0800
fix(framwork): remove build and job
closes #3091
---
models/domainlayer/devops/build.go | 37 ---------
models/domainlayer/devops/job.go | 32 --------
models/domainlayer/domaininfo/domaininfo.go | 2 -
.../migrationscripts/20220707_add_domain_tables.go | 4 -
models/migrationscripts/20220721_add_type_filed.go | 50 -------------
models/migrationscripts/archived/build.go | 36 ---------
models/migrationscripts/archived/job.go | 27 -------
models/migrationscripts/register.go | 1 -
plugins/jenkins/e2e/jobs_test.go | 19 -----
plugins/jenkins/e2e/snapshot_tables/jobs.csv | 11 ---
plugins/jenkins/impl/impl.go | 1 -
plugins/jenkins/tasks/job_convertor.go | 87 ----------------------
12 files changed, 307 deletions(-)
diff --git a/models/domainlayer/devops/build.go b/models/domainlayer/devops/build.go
deleted file mode 100644
index 76886f95..00000000
--- a/models/domainlayer/devops/build.go
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-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 devops
-
-import (
- "github.com/apache/incubator-devlake/models/domainlayer"
- "time"
-)
-
-type Build struct {
- domainlayer.DomainEntity
- JobId string `gorm:"index"`
- Name string `gorm:"type:varchar(255)"`
- CommitSha string `gorm:"type:varchar(40)"`
- DurationSec uint64
- Status string `gorm:"type:varchar(100)"`
- StartedDate time.Time
-}
-
-func (Build) TableName() string {
- return "builds"
-}
diff --git a/models/domainlayer/devops/job.go b/models/domainlayer/devops/job.go
deleted file mode 100644
index 56594b2f..00000000
--- a/models/domainlayer/devops/job.go
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-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 devops
-
-import (
- "github.com/apache/incubator-devlake/models/domainlayer"
-)
-
-type Job struct {
- Name string `gorm:"type:varchar(255)"`
- Type string `gorm:"type:varchar(255)"`
- domainlayer.DomainEntity
-}
-
-func (Job) TableName() string {
- return "jobs"
-}
diff --git a/models/domainlayer/domaininfo/domaininfo.go b/models/domainlayer/domaininfo/domaininfo.go
index 4a8c5b30..b6c6abaf 100644
--- a/models/domainlayer/domaininfo/domaininfo.go
+++ b/models/domainlayer/domaininfo/domaininfo.go
@@ -59,10 +59,8 @@ func GetDomainTablesInfo() []Tabler {
&crossdomain.User{},
&crossdomain.UserAccount{},
// devops
- &devops.Build{},
&devops.CICDPipeline{},
&devops.CICDTask{},
- &devops.Job{},
// didgen no table
// ticket
&ticket.Board{},
diff --git a/models/migrationscripts/20220707_add_domain_tables.go b/models/migrationscripts/20220707_add_domain_tables.go
index 48087cca..1c139f99 100644
--- a/models/migrationscripts/20220707_add_domain_tables.go
+++ b/models/migrationscripts/20220707_add_domain_tables.go
@@ -54,8 +54,6 @@ func (*addDomainTables) Up(ctx context.Context, db *gorm.DB) errors.Error {
&archived.IssueChangelogs{},
&archived.Sprint{},
&archived.SprintIssue{},
- &archived.Job{},
- &archived.Build{},
&archived.IssueWorklog{},
&archived.BoardRepo{},
&archived.PullRequestIssue{},
@@ -90,8 +88,6 @@ func (*addDomainTables) Up(ctx context.Context, db *gorm.DB) errors.Error {
&archived.IssueChangelogs{},
&archived.Sprint{},
&archived.SprintIssue{},
- &archived.Job{},
- &archived.Build{},
&archived.IssueWorklog{},
&archived.BoardRepo{},
&archived.PullRequestIssue{},
diff --git a/models/migrationscripts/20220721_add_type_filed.go b/models/migrationscripts/20220721_add_type_filed.go
deleted file mode 100644
index 6ee65cb6..00000000
--- a/models/migrationscripts/20220721_add_type_filed.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-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 (
- "context"
- "github.com/apache/incubator-devlake/errors"
-
- "github.com/apache/incubator-devlake/models/migrationscripts/archived"
- "gorm.io/gorm"
-)
-
-type Job20220721 struct {
- Name string `gorm:"type:varchar(255)"`
- Type string `gorm:"type:varchar(255)"`
- archived.DomainEntity
-}
-
-func (Job20220721) TableName() string {
- return "jobs"
-}
-
-type addTypeField struct{}
-
-func (*addTypeField) Up(ctx context.Context, db *gorm.DB) errors.Error {
- return errors.Convert(db.Migrator().AddColumn(Job20220721{}, "type"))
-}
-
-func (*addTypeField) Version() uint64 {
- return 20220721000005
-}
-
-func (*addTypeField) Name() string {
- return "add column `type` at jobs"
-}
diff --git a/models/migrationscripts/archived/build.go b/models/migrationscripts/archived/build.go
deleted file mode 100644
index 0a1d7cc1..00000000
--- a/models/migrationscripts/archived/build.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-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 archived
-
-import (
- "time"
-)
-
-type Build struct {
- DomainEntity
- JobId string `gorm:"index"`
- Name string `gorm:"type:varchar(255)"`
- CommitSha string `gorm:"type:varchar(40)"`
- DurationSec uint64
- Status string `gorm:"type:varchar(100)"`
- StartedDate time.Time
-}
-
-func (Build) TableName() string {
- return "builds"
-}
diff --git a/models/migrationscripts/archived/job.go b/models/migrationscripts/archived/job.go
deleted file mode 100644
index ea9502a6..00000000
--- a/models/migrationscripts/archived/job.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-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 archived
-
-type Job struct {
- Name string `gorm:"type:varchar(255)"`
- DomainEntity
-}
-
-func (Job) TableName() string {
- return "jobs"
-}
diff --git a/models/migrationscripts/register.go b/models/migrationscripts/register.go
index d9b57dc9..81da1cce 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -28,7 +28,6 @@ func All() []migration.Script {
new(updateBlueprintMode),
new(renameTasksToPlan),
new(addDomainTables),
- new(addTypeField),
new(commitfileComponent),
new(removeNotes),
new(addProjectMapping),
diff --git a/plugins/jenkins/e2e/jobs_test.go b/plugins/jenkins/e2e/jobs_test.go
index f0f5ab12..85da78d4 100644
--- a/plugins/jenkins/e2e/jobs_test.go
+++ b/plugins/jenkins/e2e/jobs_test.go
@@ -20,8 +20,6 @@ package e2e
import (
"testing"
- "github.com/apache/incubator-devlake/models/domainlayer/devops"
-
"github.com/apache/incubator-devlake/helpers/e2ehelper"
"github.com/apache/incubator-devlake/plugins/jenkins/impl"
"github.com/apache/incubator-devlake/plugins/jenkins/models"
@@ -62,21 +60,4 @@ func TestJenkinsJobsDataFlow(t *testing.T) {
"_raw_data_remark",
},
)
-
- // verify conversion
- dataflowTester.FlushTabler(&devops.Job{})
- dataflowTester.Subtask(tasks.ConvertJobsMeta, taskData)
- dataflowTester.VerifyTable(
- devops.Job{},
- "./snapshot_tables/jobs.csv",
- []string{
- "name",
- "id",
- "_raw_data_params",
- "_raw_data_table",
- "_raw_data_id",
- "_raw_data_remark",
- "type",
- },
- )
}
diff --git a/plugins/jenkins/e2e/snapshot_tables/jobs.csv b/plugins/jenkins/e2e/snapshot_tables/jobs.csv
deleted file mode 100644
index a9414d62..00000000
--- a/plugins/jenkins/e2e/snapshot_tables/jobs.csv
+++ /dev/null
@@ -1,11 +0,0 @@
-id,name,_raw_data_params,_raw_data_table,_raw_data_id,_raw_data_remark,type
-jenkins:JenkinsJob:1:devlake,devlake,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,28,,hudson.model.FreeStyleProject
-jenkins:JenkinsJob:1:dir-test,dir-test,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,29,,com.cloudbees.hudson.plugins.folder.Folder
-jenkins:JenkinsJob:1:dir-test-2,dir-test-2,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,33,,com.cloudbees.hudson.plugins.folder.Folder
-jenkins:JenkinsJob:1:free,free,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,36,,hudson.model.FreeStyleProject
-jenkins:JenkinsJob:1:free1,free1,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,37,,hudson.model.FreeStyleProject
-jenkins:JenkinsJob:1:pipeline-test,pipeline-test,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,34,,org.jenkinsci.plugins.workflow.job.WorkflowJob
-jenkins:JenkinsJob:1:pipeline-test2,pipeline-test2,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,30,,org.jenkinsci.plugins.workflow.job.WorkflowJob
-jenkins:JenkinsJob:1:testfile,testfile,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,35,,hudson.model.FreeStyleProject
-jenkins:JenkinsJob:1:测试流水线,测试流水线,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,31,,org.jenkinsci.plugins.workflow.job.WorkflowJob
-jenkins:JenkinsJob:1:这是一个改了名字的测试任务,这是一个改了名字的测试任务,"{""ConnectionId"":1}",_raw_jenkins_api_jobs,32,,hudson.model.FreeStyleProject
diff --git a/plugins/jenkins/impl/impl.go b/plugins/jenkins/impl/impl.go
index 2ba87aaf..9a94dbe2 100644
--- a/plugins/jenkins/impl/impl.go
+++ b/plugins/jenkins/impl/impl.go
@@ -76,7 +76,6 @@ func (plugin Jenkins) SubTaskMetas() []core.SubTaskMeta {
tasks.ConvertBuildsToCICDMeta,
tasks.ConvertStagesMeta,
tasks.ConvertBuildReposMeta,
- tasks.ConvertJobsMeta,
}
}
func (plugin Jenkins) PrepareTaskData(taskCtx core.TaskContext, options map[string]interface{}) (interface{}, errors.Error) {
diff --git a/plugins/jenkins/tasks/job_convertor.go b/plugins/jenkins/tasks/job_convertor.go
deleted file mode 100644
index aa617bb0..00000000
--- a/plugins/jenkins/tasks/job_convertor.go
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
-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 tasks
-
-import (
- "github.com/apache/incubator-devlake/errors"
- "reflect"
-
- "github.com/apache/incubator-devlake/models/domainlayer"
- "github.com/apache/incubator-devlake/models/domainlayer/devops"
- "github.com/apache/incubator-devlake/models/domainlayer/didgen"
- "github.com/apache/incubator-devlake/plugins/core"
- "github.com/apache/incubator-devlake/plugins/core/dal"
- "github.com/apache/incubator-devlake/plugins/helper"
- "github.com/apache/incubator-devlake/plugins/jenkins/models"
-)
-
-var ConvertJobsMeta = core.SubTaskMeta{
- Name: "convertJobs",
- EntryPoint: ConvertJobs,
- EnabledByDefault: true,
- Description: "Convert tool layer table jenkins_jobs into domain layer table jobs",
- DomainTypes: []string{core.DOMAIN_TYPE_CICD},
-}
-
-func ConvertJobs(taskCtx core.SubTaskContext) errors.Error {
- db := taskCtx.GetDal()
- data := taskCtx.GetData().(*JenkinsTaskData)
-
- clauses := []dal.Clause{
- dal.Select("*"),
- dal.From("_tool_jenkins_jobs"),
- dal.Where("connection_id = ?", data.Options.ConnectionId),
- }
- cursor, err := db.Cursor(clauses...)
- if err != nil {
- return err
- }
- defer cursor.Close()
-
- jobIdGen := didgen.NewDomainIdGenerator(&models.JenkinsJob{})
-
- converter, err := helper.NewDataConverter(helper.DataConverterArgs{
- InputRowType: reflect.TypeOf(models.JenkinsJob{}),
- Input: cursor,
- RawDataSubTaskArgs: helper.RawDataSubTaskArgs{
- Params: JenkinsApiParams{
- ConnectionId: data.Options.ConnectionId,
- },
- Ctx: taskCtx,
- Table: RAW_JOB_TABLE,
- },
- Convert: func(inputRow interface{}) ([]interface{}, errors.Error) {
- jenkinsJob := inputRow.(*models.JenkinsJob)
- job := &devops.Job{
- DomainEntity: domainlayer.DomainEntity{
- Id: jobIdGen.Generate(jenkinsJob.ConnectionId, jenkinsJob.Name),
- },
- Name: jenkinsJob.Name,
- Type: jenkinsJob.Class,
- }
- return []interface{}{
- job,
- }, nil
- },
- })
- if err != nil {
- return err
- }
-
- return converter.Execute()
-}