Skip to content
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
4 changes: 2 additions & 2 deletions backend/core/models/domainlayer/devops/cicd_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type CicdRelease struct {
RepoId string `gorm:"type:varchar(255)"`
//RepoUrl string `gorm:"index;not null"`

TagName string `json:"tagName"`
//CommitSha string `gorm:"primaryKey;type:varchar(255)"`
TagName string `json:"tagName"`
CommitSha string `gorm:"uniqueIndex;type:varchar(255)"`
//CommitMsg string
//RefName string `gorm:"type:varchar(255)"`
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
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"
"github.com/apache/incubator-devlake/helpers/migrationhelper"
)

var _ plugin.MigrationScript = (*addCommitShaToCicdRelease)(nil)

type cicdRelease20240515 struct {
CommitSha string
}

func (cicdRelease20240515) TableName() string {
return "cicd_releases"
}

type addCommitShaToCicdRelease struct{}

func (*addCommitShaToCicdRelease) Up(basicRes context.BasicRes) errors.Error {
return migrationhelper.AutoMigrateTables(basicRes, &cicdRelease20240515{})
}

func (*addCommitShaToCicdRelease) Version() uint64 {
return 20240515194901
}

func (*addCommitShaToCicdRelease) Name() string {
return "add commit_sha to cicd_releases"
}
1 change: 1 addition & 0 deletions backend/core/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,6 @@ func All() []plugin.MigrationScript {
new(addDisplayTitleAndUrl),
new(addSubtaskStates),
new(addCicdRelease),
new(addCommitShaToCicdRelease),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
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/helpers/migrationhelper"
)

type addReleaseCommitSha struct{}

type release20240515 struct {
CommitSha string
}

func (release20240515) TableName() string {
return "_tool_github_releases"
}

func (u *addReleaseCommitSha) Up(baseRes context.BasicRes) errors.Error {
return migrationhelper.AutoMigrateTables(baseRes, &release20240515{})
}

func (*addReleaseCommitSha) Version() uint64 {
return 20240515194858
}

func (*addReleaseCommitSha) Name() string {
return "add commit_sha to _tool_github_releases"
}
1 change: 1 addition & 0 deletions backend/plugins/github/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ func All() []plugin.MigrationScript {
new(modifyIssueTypeLength),
new(addWorkflowDisplayTitle),
new(addReleaseTable),
new(addReleaseCommitSha),
}
}
1 change: 1 addition & 0 deletions backend/plugins/github/models/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type GithubRelease struct {
ResourcePath string `json:"resourcePath"`
TagName string `json:"tagName"`
UpdatedAt time.Time `json:"updatedAt"`
CommitSha string `json:"commit_sha"`
URL string `json:"url"`
}

Expand Down
1 change: 1 addition & 0 deletions backend/plugins/github/tasks/release_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func ConvertRelease(taskCtx plugin.SubTaskContext) errors.Error {
IsLatest: githubRelease.IsLatest,
IsPrerelease: githubRelease.IsPrerelease,
TagName: githubRelease.TagName,
CommitSha: githubRelease.CommitSha,

AuthorID: githubRelease.AuthorID,

Expand Down
37 changes: 22 additions & 15 deletions backend/plugins/github_graphql/tasks/release_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,29 @@ type GraphqlQueryReleaseAuthor struct {
ID string `graphql:"id"`
}

type GraphqlQueryReleaseTagCommit struct {
ID string `graphql:"id"`
Oid string `graphql:"oid"`
AbbreviatedOid string `graphql:"abbreviatedOid"`
}

type GraphqlQueryRelease struct {
Author GraphqlQueryReleaseAuthor `graphql:"author"`
DatabaseID int `graphql:"databaseId"`
Id string `graphql:"id"`
CreatedAt time.Time `graphql:"createdAt"`
Description string `graphql:"description"`
DescriptionHTML string `graphql:"descriptionHTML"`
IsDraft bool `graphql:"isDraft"`
IsLatest bool `graphql:"isLatest"`
IsPrerelease bool `graphql:"isPrerelease"`
Name string `graphql:"name"`
PublishedAt time.Time `graphql:"publishedAt"`
ResourcePath string `graphql:"resourcePath"`
TagName string `graphql:"tagName"`
UpdatedAt time.Time `graphql:"updatedAt"`
URL string `graphql:"url"`
Author GraphqlQueryReleaseAuthor `graphql:"author"`
DatabaseID int `graphql:"databaseId"`
Id string `graphql:"id"`
CreatedAt time.Time `graphql:"createdAt"`
Description string `graphql:"description"`
DescriptionHTML string `graphql:"descriptionHTML"`
IsDraft bool `graphql:"isDraft"`
IsLatest bool `graphql:"isLatest"`
IsPrerelease bool `graphql:"isPrerelease"`
Name string `graphql:"name"`
PublishedAt time.Time `graphql:"publishedAt"`
ResourcePath string `graphql:"resourcePath"`
TagName string `graphql:"tagName"`
TagCommit GraphqlQueryReleaseTagCommit `graphql:"tagCommit"`
UpdatedAt time.Time `graphql:"updatedAt"`
URL string `graphql:"url"`
}

var CollectReleaseMeta = plugin.SubTaskMeta{
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/github_graphql/tasks/release_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func convertGitHubRelease(release *GraphqlQueryRelease, connectionId uint64, git
TagName: release.TagName,
UpdatedAt: release.UpdatedAt,
URL: release.URL,
CommitSha: release.TagCommit.Oid,
}
if release.Author.Name != nil {
ret.AuthorName = *release.Author.Name
Expand Down