Skip to content
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

fix: set policy_check status to success for PRs with no modified projects #3780

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
14 changes: 14 additions & 0 deletions server/events/plan_command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,12 @@ func (p *PlanCommandRunner) run(ctx *command.Context, cmd *CommentCommand) {
if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Plan, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.Apply, 0, 0); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can we make sure this doesn't affect issues like #3725 and cause a regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand what you are asking here - this part of the code just replicates what autoplan does. Is autoplan broken wrt #3725?

Copy link
Member

@GenPage GenPage Oct 6, 2023

Choose a reason for hiding this comment

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

I wanted to clarify that we are considering all possible states and have tested for them. #3747 and #3378 are better contexts around commit statuses and the issues with trying to optimize them

Especially since we are not just adding PolicyCheck but Apply commit statuses as well with this PR

ctx.Log.Warn("unable to update commit status: %s", err)
}
}
}
return
Expand Down Expand Up @@ -282,6 +288,14 @@ func (p *PlanCommandRunner) run(ctx *command.Context, cmd *CommentCommand) {
!(result.HasErrors() || result.PlansDeleted) {
ctx.Log.Info("Running policy check for %s", cmd.String())
p.policyCheckCommandRunner.Run(ctx, policyCheckCmds)
} else if len(projectCmds) == 0 && !cmd.IsForSpecificProject() {
// If there were no projects modified, we set successful commit statuses
// with 0/0 projects planned/policy_checked/applied successfully because some users require
// the Atlantis status to be passing for all pull requests.
ctx.Log.Debug("setting VCS status to success with no projects found")
if err := p.commitStatusUpdater.UpdateCombinedCount(baseRepo, pull, models.SuccessCommitStatus, command.PolicyCheck, 0, 0); err != nil {
ctx.Log.Warn("unable to update commit status: %s", err)
}
}
}

Expand Down