Skip to content

Commit

Permalink
set policy_check status to success when no changes (#3780)
Browse files Browse the repository at this point in the history
Autoplan would set the "policy_check" status to successful if
there were no modified projects in a PR, but "atlantis plan"
would not. Changed "atlantis plan" to behave like autoplan
in this regard.
  • Loading branch information
finnag committed Dec 11, 2023
1 parent 56e38b4 commit 562a151
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions server/events/plan_command_runner.go
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 {
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

0 comments on commit 562a151

Please sign in to comment.