-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automerging merges pull requests automatically if all plans have been successfully applied. * Save status of PR's to BoltDB so after each apply, we can check if there are pending plans. * Add new feature where we delete successful plans *unless* all plans have succeeded *if* automerge is enabled. This was requested by users because when automerge is enabled, they want to enforce that a pull request's changes have been fully applied. They asked that plans not be allowed to be applied "piecemeal" and instead, all plans must be generated successfully prior to allowing any plans to be applied.
- Loading branch information
Showing
64 changed files
with
2,452 additions
and
590 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Automerging | ||
Atlantis can be configured to automatically merge a pull request after all plans have | ||
been successfully applied. | ||
|
||
|
||
![Automerge](./images/automerge.png) | ||
|
||
## How To Enable | ||
Automerging can be enabled either by: | ||
1. Passing the `--automerge` flag to `atlantis server`. This will cause all | ||
pull requests to be automerged and any repo config will be ignored. | ||
1. Setting `automerge: true` in the repo's `atlantis.yaml` file: | ||
```yaml | ||
version: 2 | ||
automerge: true | ||
projects: | ||
- dir: . | ||
``` | ||
:::tip NOTE | ||
If a repo has an `atlantis.yaml` file, then each project in the repo needs | ||
to be configured under the `projects` key. | ||
::: | ||
|
||
## All Plans Must Succeed | ||
When automerge is enabled, **all plans** in a pull request **must succeed** before | ||
**any** plans can be applied. | ||
|
||
For example, imagine this scenario: | ||
1. I open a pull request that makes changes to two Terraform projects, in `dir1/` | ||
and `dir2/`. | ||
1. The plan for `dir2/` fails because my Terraform syntax is wrong. | ||
|
||
In this scenario, I can't run | ||
``` | ||
atlantis apply -d dir1 | ||
``` | ||
Even though that plan succeeded, because **all** plans must succeed for **any** plans | ||
to be saved. | ||
Once I fix the issue in `dir2`, I can push a new commit which will trigger an | ||
autoplan. Then I will be able to apply both plans. | ||
## Permissions | ||
The Atlantis VCS user must have the ability to merge pull requests. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package events_test | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/runatlantis/atlantis/server/events" | ||
"github.com/runatlantis/atlantis/server/events/models" | ||
. "github.com/runatlantis/atlantis/testing" | ||
) | ||
|
||
func TestCommandResult_HasErrors(t *testing.T) { | ||
cases := map[string]struct { | ||
cr events.CommandResult | ||
exp bool | ||
}{ | ||
"error": { | ||
cr: events.CommandResult{ | ||
Error: errors.New("err"), | ||
}, | ||
exp: true, | ||
}, | ||
"failure": { | ||
cr: events.CommandResult{ | ||
Failure: "failure", | ||
}, | ||
exp: true, | ||
}, | ||
"empty results list": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{}, | ||
}, | ||
exp: false, | ||
}, | ||
"successful plan": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
PlanSuccess: &models.PlanSuccess{}, | ||
}, | ||
}, | ||
}, | ||
exp: false, | ||
}, | ||
"successful apply": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
ApplySuccess: "success", | ||
}, | ||
}, | ||
}, | ||
exp: false, | ||
}, | ||
"single errored project": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
Error: errors.New("err"), | ||
}, | ||
}, | ||
}, | ||
exp: true, | ||
}, | ||
"single failed project": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
Failure: "failure", | ||
}, | ||
}, | ||
}, | ||
exp: true, | ||
}, | ||
"two successful projects": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
PlanSuccess: &models.PlanSuccess{}, | ||
}, | ||
{ | ||
ApplySuccess: "success", | ||
}, | ||
}, | ||
}, | ||
exp: false, | ||
}, | ||
"one successful, one failed project": { | ||
cr: events.CommandResult{ | ||
ProjectResults: []models.ProjectResult{ | ||
{ | ||
PlanSuccess: &models.PlanSuccess{}, | ||
}, | ||
{ | ||
Failure: "failed", | ||
}, | ||
}, | ||
}, | ||
exp: true, | ||
}, | ||
} | ||
|
||
for descrip, c := range cases { | ||
t.Run(descrip, func(t *testing.T) { | ||
Equals(t, c.exp, c.cr.HasErrors()) | ||
}) | ||
} | ||
} |
Oops, something went wrong.