Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit any conflicts during v1 backport to simplify release process #1032

Merged
merged 6 commits into from
Apr 26, 2022

Conversation

henrymercer
Copy link
Contributor

@henrymercer henrymercer commented Apr 14, 2022

Merge conflicts can occur during the v2 -> v1 backport due to differences between the v2 and v1 releases (e.g. the Node version). Currently the process for dealing with these is fixing the v2 -> v1 backport branch manually and opening the PR yourself, however this is a bit of a pain.

This PR modifies the process: automation now checks in any unresolved conflicts and alert maintainers in the PR description of which files contain conflicts and need fixing. Then all maintainers need to do is push a commit that fixes the conflicts. One method of doing this that maintains clean Git history is fixing up the merge commit with git commit --fixup <merge commit SHA> and git rebase -i --autosquash --rebase-merges releases/v1. We will favour adding a new commit to resolve the merge conflicts instead of amending the merge commit — while the latter leads to clearer git history, the former significantly improves the ease of PR review. When a maintainer needs to resolve conflicts as part of the release process, per standard practice, they should request review of their changes from another maintainer before merging the PR and continuing with the release.

Example checklist for a backport PR with conflicts (this is backlinked below for maintainers):

image

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

The process of creating the v1 release can run into merge conflicts. We
commit the unresolved conflicts so a maintainer can easily resolve them
(vs erroring and requiring maintainers to reconstruct the release
manually).
@henrymercer henrymercer requested a review from a team as a code owner April 14, 2022 16:41
Copy link
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, the automatically generated PR will be in draft mode and not run any jobs. If a user marks the PR as ready-for-review, checks will run and (presumably) some checks will fail due to merge conflicts.

I guess, maybe that's not true if the merge conflict is in a file that we don't compile or run (eg- CHANGELOG.md). Is this a likely possibility that one of the files with merge conflicts through this backporting process will not cause a workflow failure?

In general, I'd like to avoid having the only check against merge conflicts be in the form of the checklist in the PR, since PR checklists are easy to ignore. Though, I'm willing to believe that this will only happen in a handful of files that we execute anyway and would already cause some sort of failure.

@henrymercer
Copy link
Contributor Author

henrymercer commented Apr 14, 2022

That's a fair comment. It shouldn't be likely, but it's definitely a possibility that a file like CHANGELOG.md could contain a merge conflict during the release process. One thing we could do is introduce a PR check that asserts that there aren't any merge conflict markers.

It might also be reasonable to require that any releases containing merge conflicts are reviewed by someone other than the person who fixed the merge conflict.

@aeisenberg
Copy link
Contributor

Yep. That's one solution I had in mind. It doesn't need to be implemented now. I'm not even sure if it's necessary. If the only merge conflicts will be in workflows that are run on every PR, then it's not necessary.

@cklin
Copy link
Contributor

cklin commented Apr 14, 2022

I agree with what Andrew said.

May I suggest that you add the git commands from this PR description into the generated description in case of a conflict? I am one of those people who needs to look up how to use Git every time I need to do something unusual, so having the commands in the generated PR description would really help me a lot.

@henrymercer
Copy link
Contributor Author

Thinking about it again, I wonder whether it's more useful to sacrifice clean git history in favour of making a separate commit to fix the merge conflicts. This would make it clear what conflicts we needed to fix manually and aid PR review, since maintainers should just be able to review the commit fixing the conflicts instead of the whole merge commit. What do you think?

@henrymercer
Copy link
Contributor Author

I added a workflow to check for git conflict markers. Here's an example of it failing: https://github.com/github/codeql-action/runs/6029239038?check_suite_focus=true.

@henrymercer henrymercer force-pushed the henrymercer/handle-merge-conflicts-in-releases branch from 30b3365 to 4fd6d94 Compare April 14, 2022 18:54
This check is primarily intended to validate that any merge conflicts in
the v2 -> v1 backport PR are fixed before the PR is merged.
@henrymercer henrymercer force-pushed the henrymercer/handle-merge-conflicts-in-releases branch from 4fd6d94 to 5b5ed44 Compare April 14, 2022 19:05
@cklin
Copy link
Contributor

cklin commented Apr 14, 2022

Thinking about it again, I wonder whether it's more useful to sacrifice clean git history in favour of making a separate commit to fix the merge conflicts.

In my mind, having a separate conflict fix commit in the PR would not affect the v2-to-v1 merge automation because the v1 commit that is being reverted by automation is the last PR merge commit, so that revert should cover all commits that are in that PR. Is that correct?

If so, then I think having a separate merge conflict fix PR would not be a big deal.

…ge commit

This gives us slightly messier git history, but more importantly makes
reviewing substantially easier.
@henrymercer
Copy link
Contributor Author

In my mind, having a separate conflict fix commit in the PR would not affect the v2-to-v1 merge automation because the v1 commit that is being reverted by automation is the last PR merge commit, so that revert should cover all commits that are in that PR. Is that correct?

That's correct, yes. Let's do separate fix commits.

@henrymercer henrymercer requested review from aeisenberg and cklin April 25, 2022 16:02
Copy link
Contributor

@cklin cklin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you for putting it together! 🙏

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.

3 participants