-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: PR check status to show summary e.g. Plan: 1 to add, 0 to change, 1 to destroy
#2699
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,14 +51,13 @@ func (d *DefaultCommitStatusUpdater) UpdateCombined(repo models.Repo, pull model | |
var descripWords string | ||
switch status { | ||
case models.PendingCommitStatus: | ||
descripWords = "in progress..." | ||
descripWords = genProjectStatusDescription(cmdName.String(), "in progress...") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work @albertorm95 ! Could you also add test(s) for this to verify the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I can create one, just that I don't understand my current test fail :(
|
||
case models.FailedCommitStatus: | ||
descripWords = "failed." | ||
descripWords = genProjectStatusDescription(cmdName.String(), "failed.") | ||
case models.SuccessCommitStatus: | ||
descripWords = "succeeded." | ||
descripWords = genProjectStatusDescription(cmdName.String(), "succeeded.") | ||
} | ||
descrip := fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName.String()), descripWords) | ||
return d.Client.UpdateStatus(repo, pull, status, src, descrip, "") | ||
return d.Client.UpdateStatus(repo, pull, status, src, descripWords, "") | ||
} | ||
|
||
func (d *DefaultCommitStatusUpdater) UpdateCombinedCount(repo models.Repo, pull models.PullRequest, status models.CommitStatus, cmdName command.Name, numSuccess int, numTotal int) error { | ||
|
@@ -86,13 +85,19 @@ func (d *DefaultCommitStatusUpdater) UpdateProject(ctx command.ProjectContext, c | |
var descripWords string | ||
switch status { | ||
case models.PendingCommitStatus: | ||
descripWords = "in progress..." | ||
descripWords = genProjectStatusDescription(cmdName.String(), "in progress...") | ||
case models.FailedCommitStatus: | ||
descripWords = "failed." | ||
descripWords = genProjectStatusDescription(cmdName.String(), "failed.") | ||
case models.SuccessCommitStatus: | ||
descripWords = "succeeded." | ||
if ctx.CommandResult.PlanSuccess != nil { | ||
descripWords = ctx.CommandResult.PlanSuccess.Summary() | ||
} else { | ||
descripWords = genProjectStatusDescription(cmdName.String(), "succeeded.") | ||
} | ||
} | ||
return d.Client.UpdateStatus(ctx.BaseRepo, ctx.Pull, status, src, descripWords, url) | ||
} | ||
|
||
descrip := fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName.String()), descripWords) | ||
return d.Client.UpdateStatus(ctx.BaseRepo, ctx.Pull, status, src, descrip, url) | ||
func genProjectStatusDescription(cmdName, description string) string { | ||
return fmt.Sprintf("%s %s", cases.Title(language.English).String(cmdName), description) | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -167,6 +167,7 @@ func (p *ProjectOutputWrapper) updateProjectPRStatus(commandName command.Name, c | |||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
// ensures we are differentiating between project level command and overall command | ||||||||||||||||||||||||||||||||||||||
result := execute(ctx) | ||||||||||||||||||||||||||||||||||||||
ctx.CommandResult = result | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. + ctx.CommandResult = result This change is making the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @albertorm95 is this change needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @albertorm95 it's odd that this line is causing the failure because it should not affect the Perhaps it's a test issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it looks like a test issue
atlantis/server/events/models/commit_status.go Lines 22 to 38 in 9ca57d6
Basically, since you changed the status of the pr check, the test still thinks the status should be pending/success/failed. Please update the test and it should work as expected. cc: @albertorm95 |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
if result.Error != nil || result.Failure != "" { | ||||||||||||||||||||||||||||||||||||||
if err := p.JobURLSetter.SetJobURLWithStatus(ctx, commandName, models.FailedCommitStatus); 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.
ProjectContext
is used for command execution context. So you should not useProjectContext
as a mutable variable likectx.CommandResult = result
.In this case, it is better to add
result ProjectResult
arg intoSetJobURLWithStatus
likeSetJobURLWithStatus(ctx command.ProjectContext, cmdName command.Name, status models.CommitStatus, projectResult ProjectResult) error
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.
Currently
TestProjectOutputWrapper
is failed by following reasons.ctx
.CommandResult
.Mutable variables are difficult to maintain it. I recommend you to change like above comment. @albertorm95
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.
Thank you! @albertorm95 could you find a way to make these tests work?
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.
I tried with that solution, but it gets very complex.
Update
SetJobURLWithStatus
means to also updateUpdateProject
which is in a lot of places and makes me to update a lot of test cases, I have no experience with those mocks 😢cc: @krrrr38 @nitrocode