iterative/cml

Issue with PR auto-merging in github.

ruaultadrien opened this issue · 2 comments

Hello guys,

I am using CML to run my DVC pipeline everytime I merge into main using github actions:

Here is my action (omitting the launch-runner step):

  train:
    needs: launch-runner
    runs-on: [self-hosted, cml-runner]
    timeout-minutes: 2880
    steps:
      - uses: iterative/setup-cml@v1

      - uses: actions/checkout@v3

      - id: 'auth'
        uses: 'google-github-actions/auth@v1'
        with:
          credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DATA }}'      

      - name: Set up Python 3.10
        uses: actions/setup-python@v4
        with:
          python-version: "3.10"

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install pipenv
          pipenv install --dev --system --deploy

      - name: Train model, push data and create PR
        env:
          REPO_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
        run: |
          dvc pull --allow-missing
          dvc repro
          dvc push
          cml pr create . --merge

My issue is that it is failing at merging the code automatically. It looks like it is complaining about some settings in github related to allowing auto-merging. But the issue is that for the moment I don't want to allow auto-merge for all my PRs, especially user created ones because I would like the person that created the PR to merge it manually, to do some final check etc... Do you think that is possible and what do you recommend in terms of set up of the Github repository?

***"data":***"enablePullRequestAutoMerge":null***,"errors":[***"locations":[***"column":13,"line":8***],"message":"[\"Pull request Auto merge is not allowed for this repository\"]","path":["enablePullRequestAutoMerge"],"type":"UNPROCESSABLE"***],"headers":***"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-encoding":"gzip","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Wed, 05 Apr 2023 22:14:31 GMT","github-authentication-token-expiration":"2023-05-08 15:14:16 UTC","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"GitHub.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","transfer-encoding":"chunked","vary":"Accept-Encoding, Accept, X-Requested-With","x-accepted-oauth-scopes":"repo","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"8258:3A98:2C68D04:2CC8ED1:642DF2C7","x-oauth-scopes":"repo","x-ratelimit-limit":"5000","x-ratelimit-remaining":"4999","x-ratelimit-reset":"1680736471","x-ratelimit-resource":"graphql","x-ratelimit-used":"1","x-xss-protection":"0"***,"level":"error","message":"Request failed due to following response errors:\n - [\"Pull request Auto merge is not allowed for this repository\"]","name":"GraphqlResponseError","request":***"query":"\n          mutation autoMerge(\n            $pullRequestId: ID!\n            $mergeMethod: PullRequestMergeMethod\n            $commitHeadline: String\n            $commitBody: String\n          ) ***\n            enablePullRequestAutoMerge(\n              input: ***\n                pullRequestId: $pullRequestId\n                mergeMethod: $mergeMethod\n                commitHeadline: $commitHeadline\n                commitBody: $commitBody\n              ***\n            ) ***\n              clientMutationId\n            ***\n          ***\n        ","variables":***"mergeMethod":"MERGE","pullRequestId":"PR_kwDOIQ-mBs5Nt0W4"***,"response":***"data":***"enablePullRequestAutoMerge":null***,"errors":[***"locations":[***"column":13,"line":8***],"message":"[\"Pull request Auto merge is not allowed for this repository\"]","path":["enablePullRequestAutoMerge"],"type":"UNPROCESSABLE"***]***,"stack":"GraphqlResponseError: Request failed due to following response errors:\n - [\"Pull request Auto merge is not allowed for this repository\"]\n    at /snapshot/cml/node_modules/@octokit/graphql/dist-node/index.js:81:13\n    at async Github.prAutoMerge (/snapshot/cml/src/drivers/github.js:490:7)\n    at async Github.prCreate (/snapshot/cml/src/drivers/github.js:441:7)\n    at async CML.prCreate (/snapshot/cml/src/cml.js:611:17)\n    at async Object.exports.handler (/snapshot/cml/bin/cml/pr/create.js:18:16)"***

Hello, @ruaultadrien!

I'd suggest you to allow auto-merge in the repository settings but avoid using it on user-created pull requests.

Alternatively, you can drop the --merge option and manually merge your pull requests.

Note you may also want to take a look to required reviews in the repository branch protection settings.

Closing as stale; feel free to reopen if you have any additional questions or want to resume this conversation.