pytorch
3a630d9e - [stronghold][bc-linter] Use merge to find the changes in the PR (#99958)

Commit
1 year ago
[stronghold][bc-linter] Use merge to find the changes in the PR (#99958) Fixes the issue with the PR base detection for bc-lint. See also #98538 The context: to lint PR for BC-breaking changes we need two commits with the history between them that accurately represents the changes, introduced in the PR (and **only** these changes). --- Previous attempts to achieve this failed due to the following reasons: 1. Use `github.event.pull_request.base.sha` and `github.event.pull_request.head.sha`. If the PR's base branch advances, the new commits will be included in the `github.event.pull_request.base.sha`, mixing with the changes, introduced by the PR. 2. Find a common ancestor between `github.event.pull_request.base.sha` and `github.event.pull_request.head.sha`, use it as a base commit. This approach fails as well, if the PR includes merge commits from the newest history of its base branch. Such commits will appear as the changes, introduced in the PR and thus interfere with BC-linting. --- Current approach (this PR): Perform a merge of the `github.event.pull_request.head.sha` onto the `github.event.pull_request.base.sha`, and use the new commit SHA as the new head. This approach should always accurately find the changes introduced in the linted PR. The only shortcoming is when the PR cannot be merged onto the HEAD of it's base branch. In this case the BC-linting is skipped (the linting will be performed when the PR is rebased and conflicts are resolve, which is requires anyway before the PR is accepted). --- ### Testing * [in a separate repo for experiments](https://github.com/izaitsevfb/pr-head-test/pull/2/checks) * [BC-linter failure (this PR)](https://github.com/pytorch/pytorch/actions/runs/4793434350/jobs/8525891436?pr=99958) * gh-stack test: [failure](https://github.com/pytorch/pytorch/pull/100004), [success ](https://github.com/pytorch/pytorch/pull/100003) Pull Request resolved: https://github.com/pytorch/pytorch/pull/99958 Approved by: https://github.com/osalpekar
Author
Committer
Parents
Loading