Skip to content

[update-checkout] Support cross-repo PRs for repositories pinned to a tag - #93019

Open
jakepetroules wants to merge 1 commit into
swiftlang:mainfrom
jakepetroules:jake-petroules/update-checkout-pr-tag-base
Open

jakepetroules wants to merge 1 commit into
swiftlang:mainfrom
jakepetroules:jake-petroules/update-checkout-pr-tag-base

Conversation

@jakepetroules

Copy link
Copy Markdown
Contributor

Cross-repo PR testing fails for any repository that the branch scheme pins to a tag instead of a branch. For example, @swift-ci Please Build Toolchain … with a swift-subprocess PR fails on every platform, because main pins swift-subprocess to the 1.0.0 tag:

[swift-subprocess] 'git ls-remote --exit-code --heads origin refs/heads/1.0.0' returned (2) with the following .
update-checkout failed, fix errors and try again

(from #93014)

get_pr_branch treats the repository's scheme entry as the PR's base branch, and checks whether the PR merge ref is stale against refs/heads/<entry>. When the entry is a tag (or a commit), there is no such branch, so ls-remote --exit-code exits with 2 and update-checkout aborts.

A tag or commit pin says nothing about which branch the PR targets. So when the scheme entry isn't a branch on the remote, update-checkout now skips the staleness check and the re-merge, and uses the PR merge ref as GitHub computed it against the PR's actual base branch. Other ls-remote failures are still raised. Behavior for branch pins is unchanged.

Testing:

  • Added test_checkout_pr_merge_ref_for_repo_pinned_to_tag and test_checkout_stale_pr_merge_ref_for_repo_pinned_to_tag. Both failed with the error above before this change.
  • All 83 tests in utils/update_checkout/run_tests.py pass.

… tag

When a cross-repo PR is requested, update-checkout uses the repository's
entry in the branch scheme as the PR's base branch, and checks whether the PR
merge ref is stale with `git ls-remote --exit-code --heads origin
refs/heads/<base>`. A scheme can pin a repository to a tag or commit instead
of a branch (e.g. swift-subprocess is pinned to the `1.0.0` tag on main), in
which case that command exits with status 2 and update-checkout fails, so a
toolchain can't be built with a PR for such a repository.

If the scheme entry is not a branch on the remote, there is no base branch
to check staleness against or to merge, so use the PR merge ref as GitHub
computed it against the PR's actual base branch.
@jakepetroules

Copy link
Copy Markdown
Contributor Author

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant