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

When GitHub/GitLab Auto-Merge Is Used with Atlantis Pre Workflow Hooks, the PR will be Merged Prematurely #3875

Closed
X-Guardian opened this issue Oct 19, 2023 · 1 comment · Fixed by #3880
Labels
bug Something isn't working

Comments

@X-Guardian
Copy link
Contributor

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Overview of the Issue

If the GitHub/GitLab auto-merge option is triggered for a PR and:

  1. An Atlantis pre-workflow hook is defined for the repo
  2. The pre-workflow hook is running for a plan or apply command
  3. All other PR merge conditions are satisfied (approval, CI checks etc),

Then the PR will be prematurely merged when the pre-workflow hook has finished rather than when the plan/apply pipelines have finished, causing either the plan or apply to fail or for plans from the PR to be left locked.

Reproduction Steps

  • Define a pre-workflow hook for a repo that takes some time to finish (giving the user chance to set the auto-merge on the PR):
repos:
  - id: /.*/
    pre_workflow_hooks:
      - description: Hook1
        run: |
          echo "Hook1"
          sleep 30s
  • Create a PR and satisfy any required merge conditions (approve, plan, apply etc).
  • Run a final plan or apply and select auto-merge on the PR whilst the pre-workflow hook is running.
  • The PR will merge when the pre-workflow hook has finished, and then the plan or apply will fail or leave locked plans.

Environment details

  • Atlantis version: 0.26.0

Additional Context

This happens because the plan or apply pipeline status is not set to 'pending' until after the pre workflow hooks are complete. This needs changing so that the relevant status is set to pending when the pre workflow hooks start.

@X-Guardian X-Guardian added the bug Something isn't working label Oct 19, 2023
@jamengual
Copy link
Contributor

@lukemassa, here is another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants