Skip to content

feat: github cicd enricher from run to pipeline#2680

Closed
abeizn wants to merge 10 commits into
apache:mainfrom
merico-ai:github-cicd
Closed

feat: github cicd enricher from run to pipeline#2680
abeizn wants to merge 10 commits into
apache:mainfrom
merico-ai:github-cicd

Conversation

@abeizn
Copy link
Copy Markdown
Contributor

@abeizn abeizn commented Aug 4, 2022

Summary

enricher : from _tool_github_runs to _tool_github_pipelines

Does this close any open issues?

related to #2584

Screenshots

Include any relevant screenshots here.

Other Information

Any other information that is important to this PR.

if entity.Status == "completed" {
entity.Duration = float64(item.GithubUpdatedAt.Sub(*item.GithubCreatedAt).Seconds())
}
entity.Results = item.Conclusion
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our result should be a enum value

Comment thread plugins/github/models/pipeline.go Outdated
FinishedDate *time.Time `json:"finished_time"`
Duration float64 `json:"duration"`
Status string `json:"status" gorm:"type:varchar(255)"`
Results string `json:"results" gorm:"type:varchar(255)"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Result?

@@ -29,7 +29,6 @@ import (
type GithubRun20220728 struct {
archived.NoPKModel
ConnectionId uint64 `gorm:"primaryKey"`
GithubId int `gorm:"primaryKey"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this one have a githubId?

FinishedDate *time.Time `json:"finished_time"`
Duration float64 `json:"duration"`
Status string `json:"status" gorm:"type:varchar(255)"`
Results string `json:"results" gorm:"type:varchar(255)"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

type GithubRun struct {
common.NoPKModel
ConnectionId uint64 `gorm:"primaryKey"`
GithubId int `gorm:"primaryKey"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above


entity := &githubModels.GithubPipeline{}
cursor, err := db.Cursor(
dal.Select("head_sha, head_branch, status, conclusion, github_created_at, github_updated_at, run_attempt, run_started_at"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can also order by github_created_at, then you can get the earliest github_created_at easily

entity.Results = item.Conclusion
// TODO
entity.Type = "CI/CD"
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you'd better create a new entity, for this, I'm wondering if there is a bug. In my thought, if err := db.CreateOrUpdate(entity) is doing batch save, the value of entity might be the last one

if entity.Status == "completed" {
entity.Duration = float64(item.GithubUpdatedAt.Sub(*item.GithubCreatedAt).Seconds())
}
entity.Result = item.Conclusion
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify Result and Status after #2683 get merged

Copy link
Copy Markdown
Contributor

@warren830 warren830 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abeizn abeizn closed this Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants