This is an automated email from the ASF dual-hosted git repository.

mappjzc 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 11146fcb feat(domainLayer): add cicd entities (#2667)
11146fcb is described below

commit 11146fcb66e506579c531c35f8308dd58981c7ae
Author: Warren Chen <[email protected]>
AuthorDate: Wed Aug 3 19:36:37 2022 +0800

    feat(domainLayer): add cicd entities (#2667)
    
    closes #2666
---
 models/domainlayer/devops/cicd_pipeline.go   | 24 +++++++++
 models/domainlayer/devops/cicd_task.go       | 22 ++++++++
 models/migrationscripts/20220803_add_cicd.go | 81 ++++++++++++++++++++++++++++
 models/migrationscripts/register.go          |  1 +
 4 files changed, 128 insertions(+)

diff --git a/models/domainlayer/devops/cicd_pipeline.go 
b/models/domainlayer/devops/cicd_pipeline.go
new file mode 100644
index 00000000..5550f29c
--- /dev/null
+++ b/models/domainlayer/devops/cicd_pipeline.go
@@ -0,0 +1,24 @@
+package devops
+
+import (
+       "github.com/apache/incubator-devlake/models/domainlayer"
+       "time"
+)
+
+type CICDPipeline struct {
+       domainlayer.DomainEntity
+       Name         string `gorm:"type:varchar(255)"`
+       CommitSha    string `gorm:"type:varchar(255);index"`
+       Branch       string `gorm:"type:varchar(255);index"`
+       Repo         string `gorm:"type:varchar(255);index"`
+       Result       string `gorm:"type:varchar(100)"`
+       Status       string `gorm:"type:varchar(100)"`
+       Type         string `gorm:"type:varchar(100);comment: to indicate this 
is CI or CD"`
+       DurationSec  uint64
+       CreatedDate  time.Time
+       FinishedDate time.Time
+}
+
+func (CICDPipeline) TableName() string {
+       return "cicd_pipelines"
+}
diff --git a/models/domainlayer/devops/cicd_task.go 
b/models/domainlayer/devops/cicd_task.go
new file mode 100644
index 00000000..03af484d
--- /dev/null
+++ b/models/domainlayer/devops/cicd_task.go
@@ -0,0 +1,22 @@
+package devops
+
+import (
+       "github.com/apache/incubator-devlake/models/domainlayer"
+       "time"
+)
+
+type CICDTask struct {
+       domainlayer.DomainEntity
+       Name         string `gorm:"type:varchar(255)"`
+       PipelineId   string `gorm:"index;type:varchar(255)"`
+       Result       string `gorm:"type:varchar(100)"`
+       Status       string `gorm:"type:varchar(100)"`
+       Type         string `gorm:"type:varchar(100);comment: to indicate this 
is CI or CD"`
+       DurationSec  uint64
+       StatedDate   time.Time
+       FinishedDate time.Time
+}
+
+func (CICDTask) TableName() string {
+       return "cicd_tasks"
+}
diff --git a/models/migrationscripts/20220803_add_cicd.go 
b/models/migrationscripts/20220803_add_cicd.go
new file mode 100644
index 00000000..81882678
--- /dev/null
+++ b/models/migrationscripts/20220803_add_cicd.go
@@ -0,0 +1,81 @@
+/*
+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/models/migrationscripts/archived"
+       "gorm.io/gorm"
+       "time"
+)
+
+type addCICD struct{}
+
+func (*addCICD) Up(ctx context.Context, db *gorm.DB) error {
+       err := db.Migrator().AutoMigrate(
+               &CICDPipeline{},
+               &CICDTask{},
+       )
+       if err != nil {
+               return err
+       }
+
+       return nil
+}
+
+func (*addCICD) Version() uint64 {
+       return 20220803232735
+}
+
+func (*addCICD) Name() string {
+       return "add cicd models"
+}
+
+type CICDPipeline struct {
+       archived.DomainEntity
+       Name         string `gorm:"type:varchar(255)"`
+       CommitSha    string `gorm:"type:varchar(255);index"`
+       Branch       string `gorm:"type:varchar(255);index"`
+       Repo         string `gorm:"type:varchar(255);index"`
+       Result       string `gorm:"type:varchar(100)"`
+       Status       string `gorm:"type:varchar(100)"`
+       Type         string `gorm:"type:varchar(100);comment: to indicate this 
is CI or CD"`
+       DurationSec  uint64
+       CreatedDate  time.Time
+       FinishedDate time.Time
+}
+
+func (CICDPipeline) TableName() string {
+       return "cicd_pipelines"
+}
+
+type CICDTask struct {
+       archived.DomainEntity
+       Name         string `gorm:"type:varchar(255)"`
+       PipelineId   string `gorm:"index;type:varchar(255)"`
+       Result       string `gorm:"type:varchar(100)"`
+       Status       string `gorm:"type:varchar(100)"`
+       Type         string `gorm:"type:varchar(100);comment: to indicate this 
is CI or CD"`
+       DurationSec  uint64
+       StatedDate   time.Time
+       FinishedDate time.Time
+}
+
+func (CICDTask) TableName() string {
+       return "cicd_tasks"
+}
diff --git a/models/migrationscripts/register.go 
b/models/migrationscripts/register.go
index 54ff6793..9c91cd8c 100644
--- a/models/migrationscripts/register.go
+++ b/models/migrationscripts/register.go
@@ -35,5 +35,6 @@ func All() []migration.Script {
                new(renameColumnsOfPullRequestIssue),
                new(addNoPKModelToCommitParent),
                new(addSubtasksTable),
+               new(addCICD),
        }
 }

Reply via email to