Skip to content
This repository has been archived by the owner on Dec 12, 2020. It is now read-only.

[Question] automerging #184

Closed
piotr-s-brainhub opened this issue Mar 13, 2019 · 10 comments
Closed

[Question] automerging #184

piotr-s-brainhub opened this issue Mar 13, 2019 · 10 comments
Assignees

Comments

@piotr-s-brainhub
Copy link

piotr-s-brainhub commented Mar 13, 2019

Which Renovate are you using? App

Which platform are you using? GitHub

What is your question?

I would like to configure in this way:

  • renovate is able to merge only to some selected branches e.g. develop
  • renovate is able to merge without any approval even if a given repo requires at least one or more approvals
  • renovate isn't able to push to other protected branches e.g. master

Ideally for a given organization the first PR for a given version e.g. [email protected] should require an approval and if another PR (in a different repo) has all the versions previously approved, it should be automerged.

Here renovatebot/renovate#846 I was proposed to ask a question in config-help. I found #152 but it seems to not answer my questions.

@rarkins
Copy link
Collaborator

rarkins commented Mar 13, 2019

renovate is able to merge only to some selected branches e.g. develop

Renovate will only merge to the base branches you configure it to, and only to the ones that GitHub permits it to. Don't configure automerge on branches you don't want, and if configure GitHub branch protection if you want to be extra careful.

renovate is able to merge without any approval even if a given repo requires at least one more approvals

This is not possible because it's GitHub that enforces this rule, not GitHub. If you mandate PR approvals, then any Renovate PR needs approval. But you can install the companion app Renovate Approve and it will auto-approve any Renovate PR that is set to automerge, so you don't have to.

renovate isn't able to push to other protected branches e.g. master

Same answer as the first point. Renovate won't push/automerge unless you configure it to, and can only do that if you don't protect the branch.

ideally for a given organization the first PR for a given version e.g. [email protected] should require an approval and if another PR (in a different repo) has all the versions previously approved, it should be automerged

This is a good suggestion, but could not be done via GitHub's interface so would need to be done via the Dashboard.

@piotr-s-brainhub
Copy link
Author

piotr-s-brainhub commented Mar 13, 2019

@rarkins

it's GitHub that enforces this rule, not GitHub

I guess you mean it's GitHub that enforces this rule, not renovate

This is a good suggestion, but could not be done via GitHub's interface so would need to be done via the Dashboard.

It could be via the Dashboard but renovate-approve could work in such a way that it doesn't approve if no human has approved a given version but approves if a human has approved a given version.

@piotr-s-brainhub
Copy link
Author

@rarkins

should such a renovate.json work?

{
  "commitMessagePrefix": "[renovate] ",
  "groupName": "all dependencies",
  "labels": [
    "renovate"
  ],
  "npmToken": "<redacted>",
  "packageRules": [
    {
      "packagePatterns": [
        "^@dmx/"
      ],
      "schedule": "at any time",
      "automerge": true
    },
    {
      "managers": [
        "circleci"
      ],
      "schedule": "at any time",
      "automerge": true
    }
  ],
  "rangeStrategy": "bump",
  "schedule": "before 3am on the first day of the month",
  "automerge": false
}

expected rules:

  • automerge all ^@dmx/ packages
  • automerge all CircleCI dependencies
  • don't automerge any other dependencies

@rarkins
Copy link
Collaborator

rarkins commented Mar 13, 2019

Yes I think that's right. Beware though that you'll automerge major dependencies too, so I suggest adding a third package rule disabling major automerge using updateTypes.

@piotr-s-brainhub
Copy link
Author

@rarkins

unfortunately neither the renovate.json from the previous comment nor the following one works:

{
  "automerge": true,
  "commitMessagePrefix": "[renovate] ",
  "groupName": "all dependencies",
  "labels": [
    "renovate"
  ],
  "major": {
    "automerge": false
  },
  "npmToken": "<redacted>",
  "packageRules": [
    {
      "packagePatterns": [
        "^@dmx/"
      ],
      "schedule": "at any time"
    },
    {
      "managers": [
        "circleci"
      ],
      "schedule": "at any time"
    }
  ],
  "rangeStrategy": "bump",
  "schedule": "before 3am on the first day of the month"
}

e.g. renovate opened this PR https://github.com/dmx-io/core-microservice/pull/42 and it doesn't merge it though it displays Automerge: Enabled.
I have installed renovate-approve-bot

@piotr-s-brainhub
Copy link
Author

Screen Shot 2019-03-13 at 22 15 33

@rarkins
Copy link
Collaborator

rarkins commented Mar 13, 2019

The approve bot is only triggered on PR creation and you probably installed it after that PR was created. Please close that PR but try leaving the branch so that it doesn't need to be tested again, you will hopefully see a new PR and this time the bot will approve like this:

image

Then you need to wait for the next run and it should automerge if other tests have passed.

@piotr-s-brainhub
Copy link
Author

piotr-s-brainhub commented Mar 13, 2019

@rarkins

Now renovate-approve approves but renovate still doesn't merge.
Does it wait some time until it merges?

Btw. I have 2 other questions:

  • is it possible renovate-approve to give 2 approvals? temporarily I changed the requirements from 2 approvals to only one but I would like to keep required 2 approvals to merge
  • does renovate merge if initially the build fails but after retry, it passes?

@rarkins
Copy link
Collaborator

rarkins commented Mar 13, 2019

Does it wait some time until it merges?

Renovate runs hourly, so you will need to wait for the next run (or something else that triggers a run).

is it possible renovate-approve to give 2 approvals? temporarily I changed the requirements from 2 approvals to only one but I would like to keep required 2 approvals to merge

This is not possible according to GitHub, i.e. a single user or bot always counts as 1. We'd need yet another bot.

does renovate merge if initially the build fails but after retry, it passes?

Yes, so long as nobody else had to add a commit in order to get it to pass.

@piotr-s-brainhub
Copy link
Author

Thanks, renovate finally merged a PR.
Maybe I'll try to setup another GitHub app based on https://github.com/renovatebot/renovate-approve-bot in order to get the second approval.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants