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

Allow "Mergeable" apply requirement to work #454

Closed
wants to merge 1 commit into from

Conversation

pratikmallya
Copy link
Contributor

@pratikmallya pratikmallya commented Feb 4, 2019

Get the Mergeable status of the PR before updating the
Status. This allows for the Status to be a required
Status for merging the PR. This allows us to use the
atlantis status as a Required status, which is the
configuration often used, since most deployments
want to ensure tf plans have all been successfully
applied before merging

Issue: #453

@codecov
Copy link

codecov bot commented Feb 4, 2019

Codecov Report

Merging #454 into master will decrease coverage by 0.02%.
The diff coverage is 60%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
- Coverage   70.78%   70.75%   -0.03%     
==========================================
  Files          63       63              
  Lines        3987     3991       +4     
==========================================
+ Hits         2822     2824       +2     
- Misses        970      971       +1     
- Partials      195      196       +1
Impacted Files Coverage Δ
server/events/models/models.go 89.61% <ø> (ø) ⬆️
server/events/project_command_runner.go 81.48% <100%> (ø) ⬆️
server/events/project_command_builder.go 84.54% <100%> (+0.07%) ⬆️
server/events/command_runner.go 69.93% <33.33%> (-0.79%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c6b87d...fd6070b. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 4, 2019

Codecov Report

Merging #454 into master will decrease coverage by <.01%.
The diff coverage is 40%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #454      +/-   ##
==========================================
- Coverage   70.53%   70.53%   -0.01%     
==========================================
  Files          63       63              
  Lines        4243     4245       +2     
==========================================
+ Hits         2993     2994       +1     
- Misses       1028     1029       +1     
  Partials      222      222
Impacted Files Coverage Δ
server/server.go 67.29% <ø> (-0.13%) ⬇️
server/events/models/models.go 85.26% <ø> (ø) ⬆️
server/events/project_command_builder.go 84.54% <100%> (+0.07%) ⬆️
server/events/command_runner.go 65.28% <33.33%> (-0.68%) ⬇️
server/events/project_command_runner.go 78.98% <33.33%> (+0.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a08cec9...09782c4. Read the comment docs.

@pratikmallya pratikmallya force-pushed the master branch 4 times, most recently from bcc0a2d to cf7cf56 Compare February 4, 2019 08:08
@pratikmallya
Copy link
Contributor Author

@lkysow the codecov decrease seems to be due to an additional code that logs a warning. Not sure if you want me to fix that

@pratikmallya pratikmallya force-pushed the master branch 2 times, most recently from a81a600 to b432ace Compare February 4, 2019 09:40
@lkysow
Copy link
Member

lkysow commented Feb 4, 2019

If an Atlantis apply fails, then even this change won't help since when we look up the merge status prior to the pull request, it will say non-mergeable, which will cause the apply to fail again... basically we're stuck in a loop.

@lkysow
Copy link
Member

lkysow commented Feb 4, 2019

I don't think it's possible to use the mergeable requirement and require the Atlantis status check.

@pratikmallya
Copy link
Contributor Author

Sure, but isn't the workflow to plan again?

@pratikmallya
Copy link
Contributor Author

ie apply -> apply fails -> plan -> apply again etc

@pratikmallya
Copy link
Contributor Author

So the tradeoff here seems to be that you lose the ability to reapply a failed plan. Which... is perhaps enforcing a best practice? : )

@lkysow
Copy link
Member

lkysow commented Feb 4, 2019

Oh, that's a good workaround.

server/events/project_command_runner.go Outdated Show resolved Hide resolved
server/events/command_runner.go Outdated Show resolved Hide resolved
server/events/command_runner.go Outdated Show resolved Hide resolved
server/events/models/models.go Outdated Show resolved Hide resolved
server/events/command_context.go Outdated Show resolved Hide resolved
@lkysow
Copy link
Member

lkysow commented Feb 5, 2019

If you apply and it fails because you didn't get reviewed, then you get stuck in the same situation and have to re-plan. So I still think it's not recommended to require the atlantis status to pass and use the mergeability requirement but this PR will make it less likely you get into a weird situation.

@pratikmallya
Copy link
Contributor Author

Please take a look @lkysow ; incorporated your suggestions

server/events/project_command_runner.go Show resolved Hide resolved
@@ -451,8 +458,6 @@ func TestDefaultProjectCommandRunner_Apply(t *testing.T) {
switch step {
case "approved":
mockApproved.VerifyWasCalledOnce().PullIsApproved(ctx.BaseRepo, ctx.Pull)
case "mergeable":
mockMergeable.VerifyWasCalledOnce().PullIsMergeable(ctx.BaseRepo, ctx.Pull)
case "init":
mockInit.VerifyWasCalledOnce().Run(ctx, nil, repoDir)
case "plan":
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a test case that tests your new code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would that work? Sorry, I'm not sure how this mocking framework works, but it seems like you're testing if a function is being called; whereas in the case of testing Mergeability, its just checking the value of ctx.PullMergeable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lkysow Added a test case to test the failure path. not sure if that's what you were asking for; lemme know

Copy link
Member

Choose a reason for hiding this comment

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

That's perfect

@pratikmallya pratikmallya force-pushed the master branch 2 times, most recently from 13b4f91 to f1bc44a Compare February 9, 2019 11:03
Get the Mergeable status of the PR before updating the
Status. This allows for the Status to be a required
Status for merging the PR. This allows us to use the
atlantis status as a Required status, which is the
configuration often used, since most deployments
want to ensure tf plans have all been successfully
applied before merging

Issue: runatlantis#453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants