suzuki-shunsuke / issue

MIT License
4 stars 0 forks source link

Renovate の platformAutomerge を検証 #86

Closed suzuki-shunsuke closed 2 years ago

suzuki-shunsuke commented 2 years ago

以前期待通り動かなかった気がするが、改めて検証する。

https://docs.renovatebot.com/configuration-options/#platformautomerge

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge

suzuki-shunsuke commented 2 years ago

何も CI が走っていないからか automerge されない。

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/1

suzuki-shunsuke commented 2 years ago

CI pass したがマージされない。 branch の設定がしてないから? https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/3

DEBUG: GitHub-native automerge: not enabled in repo settings(branch="renovate/cli-cli-2.x")

https://app.renovatebot.com/dashboard#github/suzuki-shunsuke/test-renovate-platformautomerge/554977790

リポジトリの設定が必要?

https://github.com/renovatebot/renovate/blob/eccfa6514f719772d5d1f0353993f7644469841f/lib/platform/github/index.ts#L1469-L1475

  if (!config.autoMergeAllowed) {
    logger.debug(
      { prNumber },
      'GitHub-native automerge: not enabled in repo settings'
    );
    return;
  }

https://github.com/renovatebot/renovate/blob/eccfa6514f719772d5d1f0353993f7644469841f/lib/platform/github/index.ts#L256-L264

    const res = await githubApi.requestGraphql<{
      repository: GhRepo;
    }>(infoQuery, {
      variables: {
        owner: config.repositoryOwner,
        name: config.repositoryName,
      },
    });
    repo = res?.data?.repository;

https://docs.github.com/en/graphql/reference/objects#repository

autoMergeAllowed (Boolean!) | Whether or not Auto-merge can be enabled on pull requests in this repository.

そういえばこんなリポジトリの設定あったの忘れていた。

image

You can allow setting pull requests to merge automatically once all required reviews and status checks have passed. Allow auto-merge Waits for merge requirements to be met and then merges automatically.

https://docs.github.com/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request

suzuki-shunsuke commented 2 years ago

Allow auto-merge を有効化したが、マージされない。

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/4

失敗している

https://app.renovatebot.com/dashboard#github/suzuki-shunsuke/test-renovate-platformautomerge/554977867

DEBUG: GitHub-native automerge: fail(branch="renovate/cli-cli-2.x")
{
  "prNumber": 4,
  "errors": [
    {
      "type": "UNPROCESSABLE",
      "path": [
        "enablePullRequestAutoMerge"
      ],
      "locations": [
        {
          "line": 6,
          "column": 3
        }
      ],
      "message": "[\"Pull request is not in the correct state to enable auto-merge\"]"
    }
  ]
}

Web UI 上も automerge を有効化できる感じではない

image

これはすでに merge できる状態だからか。

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/automatically-merging-a-pull-request

Note: the option to enable auto-merge is shown only on pull requests that cannot be merged immediately.

suzuki-shunsuke commented 2 years ago

main branch に branch protection rule を作る。 なにも選ばずに Require status checks to pass before merging を有効化してみる

image

suzuki-shunsuke commented 2 years ago

automerge 有効化できない

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/5

image

suzuki-shunsuke commented 2 years ago

追加してみる。 GitHub Actions の場合、 job 名を選ぶのか? job 名重複したら status check どうなるんだろ。

image

suzuki-shunsuke commented 2 years ago

有効になった。

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/6

image

そしてマージされた。

image

suzuki-shunsuke commented 2 years ago

実現したいことは、実行されるすべての job が pass したら自動でマージされること。 branch protection rule で指定した job が pass した時点で他の job を無視してマージされたら困るが、 そのへんはどうなっているのか要確認。これは Renovate 関係なく、 GitHub の Automerge の仕様の話。

suzuki-shunsuke commented 2 years ago

必ず失敗する workflow を追加して検証

suzuki-shunsuke commented 2 years ago

CI こけてるのにマージされてしまった。

image

https://github.com/suzuki-shunsuke/test-renovate-platformautomerge/pull/7