-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add option to opt-out from pull request completion #135
base: main
Are you sure you want to change the base?
Add option to opt-out from pull request completion #135
Conversation
Need to test this some more - it's a start for possible feedback. A bit unsure about the behaviour in case things go wrong as handled by |
.pipelines/pull.yml
Outdated
Write-Host "Pull Request created with Id: $prId" | ||
|
||
# If PR is not completed, then optionally complete it bypassing policy | ||
$completePullRequest = $env:AZOPS_COMPLETE_PULL_REQUEST -eq 'true' |
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.
Should probably do the opposite (compare with 'false') to keep consistent with old behaviour in case the variable is not set. And also consistent with the description in vars.yml.
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.
We like consistency, so please change that.
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.
Renamed the variable to AZOPS_SKIP_PR_COMPLETION
in an attempt to better communicate intent as opposed to default behaviour.
and some changes to logic and the variable name
From my initial tests I suppose this output is what would be hidden via the previous redirect but I need to verify this: The test cases included no variable (default) as well as switching the value between runs and with/without an existing 'automated' branch. |
@SimonWahlin did you have the chance to look at this one? |
@daltondhcp I did, but I see now that my review is still in pending state :( I had some comments on using --query on the az commands but that is now solved with ConvertTo-Json which is absolutely fine. Otherwise I think it looks good, but I have not had the opportunity to do any testing. We could consider trying to do a stream redirect of the error message from AZ CLI and exit more gracefully if we fail to complete the PR, but it's a bit of an edge case so I would be happy with the "PowerShell exited with code '1'" error message. |
I have some very minor adjustments on its way. I've done some basic testing for the default pipeline here but on a daily basis I use a variation of this with the pull pipeline split into two jobs instead of a single one. Also, as far as I understand this is not needed with GitHub Actions, right? Finally - here is a sample edge case - could possibly output some info on what to do next, but that might be for the wiki instead |
@jsandquist Ping me when you are satisfied and I'll do some tests on my side as well |
@SimonWahlin Finally updated it so ready for some tests on your side now hopefully. I refrained from splitting the pull pipeline into two jobs named 'pull' and 'merge' respectively - that might be another Pull Request at some point but complicates the setup somewhat. |
Finally sat down and tested this (sorry for the delay). It still sets the PR to auto-complete and will have no effect unless there is a branch policy requiring for example reviews. Maybe we should consider naming the setting AZOPS_SKIP_PR_POLICYBYPASS, or at least mention that in the comment in vars.yml. Other than that, it works as expected, setting the variable to true will not bypass branch policy, setting it to anything else than true or not setting it at all will still bypass any policies. |
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.
Looks good, but @daltondhcp has to decide what we should call the settings variable per my earlier comment
Good proposal. I'll adjust the code. |
Fix Azure/AzOps#741
Introducing a new variable AZOPS_SKIP_PR_COMPLETION
AZOPS_COMPLETE_PULL_REQUESTthat can be set totrue
to opt-out from pull request completion should your workflow require mandatory pull request reviews.false
Also converted two more steps to PowerShell following the work done in #120.