-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EVG-15206: Add CommitQueue to parser project #5085
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is coming up more and more; I'm leaning towards incorporating it into FindMergedProjectRef. (But I get if we want to do that at the end; should maybe make a ticket for it though)
model/project.go
Outdated
@@ -66,7 +66,8 @@ type Project struct { | |||
// The below fields can be set for the ProjectRef struct on the project page, or in the project config yaml. | |||
// Values for the below fields set on this struct when TranslateProject is called for the project parser will | |||
// take precedence over the project page and will be the configs used for a given project during runtime. | |||
DeactivatePrevious bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"` | |||
DeactivatePrevious bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"` | |||
CommitQueue *CommitQueueParams `yaml:"commit_queue" bson:"commit_queue"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The benefit of this being a pointer is that we can use omitempty to prevent saving an empty struct.
model/project_parser.go
Outdated
@@ -89,7 +89,8 @@ type ParserProject struct { | |||
// The below fields can be set for the ProjectRef struct on the project page, or in the project config yaml. | |||
// Values for the below fields set on this struct will take precedence over the project page and will | |||
// be the configs used for a given project during runtime. | |||
DeactivatePrevious *bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"` | |||
DeactivatePrevious *bool `yaml:"deactivate_previous" bson:"deactivate_previous,omitempty"` | |||
CommitQueue *CommitQueueParams `yaml:"commit_queue" bson:"commit_queue"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also omitempty
model/project_ref.go
Outdated
@@ -2131,6 +2138,10 @@ func (p *ProjectRef) CommitQueueIsOn() error { | |||
if p.IsPatchingDisabled() { | |||
catcher.Add(errors.Errorf("patching is disabled for project '%s'", p.Id)) | |||
} | |||
err := p.MergeWithParserProject("") | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can combine in one line if err := ... ; err != nil
model/project_ref.go
Outdated
@@ -2131,6 +2138,10 @@ func (p *ProjectRef) CommitQueueIsOn() error { | |||
if p.IsPatchingDisabled() { | |||
catcher.Add(errors.Errorf("patching is disabled for project '%s'", p.Id)) | |||
} | |||
err := p.MergeWithParserProject("") | |||
if err != nil { | |||
catcher.Add(errors.Wrap(err, "can't merge parser project with project ref")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catcher.Wrapf
operations/commit_queue.go
Outdated
@@ -419,6 +419,10 @@ func listCommitQueue(ctx context.Context, client client.Communicator, ac *legacy | |||
if err != nil { | |||
return errors.Wrapf(err, "can't find project for queue id '%s'", projectID) | |||
} | |||
err = projectRef.MergeWithParserProject("") | |||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combine with 423 (also below)
operations/commit_queue.go
Outdated
@@ -690,7 +698,8 @@ func (p *moduleParams) addModule(ac *legacyClient, rc *legacyClient) error { | |||
|
|||
func showCQMessageForProject(ac *legacyClient, projectID string) { | |||
projectRef, _ := ac.GetProjectRef(projectID) | |||
if projectRef != nil && projectRef.CommitQueue.Message != "" { | |||
err := projectRef.MergeWithParserProject("") | |||
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't combine these checks; MergeWithParserProject will (and rightly should) panic if projectRef is nil
rest/route/repo.go
Outdated
@@ -277,7 +281,8 @@ func (h repoIDPatchHandler) validateBranchesForRepo(ctx context.Context, newRepo | |||
githubCheckIds []string | |||
}{} | |||
for _, p := range mergedRepos { | |||
if !p.IsEnabled() { | |||
err = p.MergeWithParserProject("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually commit queue; are we allowing overall enabled to also be defined in yaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this was mistaken on my end for commit queue enabled check. Reverted.
rest/route/project.go
Outdated
@@ -235,6 +235,10 @@ func (h *projectIDPatchHandler) Parse(ctx context.Context, r *http.Request) erro | |||
if err != nil { | |||
return errors.Wrap(err, "error finding original project") | |||
} | |||
err = oldProject.MergeWithParserProject("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to do this; we use this to determine what the new project ref to be saved to the DB should be, so we'll end up saving project ref values.
service/project.go
Outdated
@@ -150,6 +150,11 @@ func (uis *UIServer) projectPage(w http.ResponseWriter, r *http.Request) { | |||
CQConflictingRefs := []string{} | |||
githubChecksConflictingRefs := []string{} | |||
for _, ref := range matchingRefs { | |||
err = ref.MergeWithParserProject("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to display yaml values on the UI like this
I've thought about it more and I agree - I've created a small 2 point ticket to cover this refactoring to be done next sprint: https://jira.mongodb.org/browse/EVG-15562 |
operations/commit_queue.go
Outdated
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" { | ||
grip.Info(projectRef.CommitQueue.Message) | ||
if projectRef != nil && projectRef.CommitQueue.Message != "" { | ||
if err := projectRef.MergeWithParserProject(""); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not catching earlier; you can't do this for the CLI; it needs to use rest routes to communicate with Evergreen, i.e. to get the version. GetProjectRef is an example of this. I would modify that function to send over the already merged project.
operations/commit_queue.go
Outdated
err := projectRef.MergeWithParserProject("") | ||
if err != nil && projectRef != nil && projectRef.CommitQueue.Message != "" { | ||
grip.Info(projectRef.CommitQueue.Message) | ||
if projectRef != nil && projectRef.CommitQueue.Message != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're moving this anyway but you'd want to look this up even if Message == ""
EVG-15206
Description
Parser project struct has been updated to support commit queue configs in the yaml structure and all relevant places where properties are checked on the commit queue configs for a given project will now be checking a merged project ref struct with any necessary overriding properties from the parser project.