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

doc: add guide for backporting PRs #11099

Closed
wants to merge 11 commits into from
5 changes: 4 additions & 1 deletion COLLABORATOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ LTS release.

When you send your pull request, consider including information about
whether your change is breaking. If you think your patch can be backported,
please feel free to include that information in the PR thread.
please feel free to include that information in the PR thread. For more
information on backporting, please see the [backporting guide][].

Several LTS related issue and PR labels have been provided:

Expand All @@ -364,3 +365,5 @@ When the LTS working group determines that a new LTS release is required,
selected commits will be picked from the staging branch to be included in the
release. This process of making a release will be a collaboration between the
LTS working group and the Release team.

[backporting guide]: doc/guides/backporting-to-release-lines.md
84 changes: 84 additions & 0 deletions doc/guides/backporting-to-release-lines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# How to backport a Pull Request to a Release Line
Copy link
Member

Choose a reason for hiding this comment

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

'Backport' to make it consistently titlecase eh?


## Staging branches

Each release line has a staging branch that the releaser will use as a scratch
pad while preparing a release. The branch name is formatted as follows:
`vN.x-staging` where `N` is the major release number.

### Active staging branches
Copy link
Member

Choose a reason for hiding this comment

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

Might be best to avoid embedding "current" versions in here as they won't stay current long and this doc would need to get updated constantly.


| Release Line | Staging Branch |
| ------------ | -------------- |
| `v7.x` | `v7.x-staging` |
| `v6.x` | `v6.x-staging` |
| `v4.x` | `v4.x-staging` |

## What needs to be backported?

When a release is being prepared, the releaser attempts to cherry-pick a
certain set of commits from the master branch to the release staging branch.
Copy link
Contributor

Choose a reason for hiding this comment

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

"certain" is vague, but elaborated on below, maybe state that criteria for consideration depends on the the target version (current or LTS)?

Copy link
Contributor

Choose a reason for hiding this comment

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

actually, not elaborated on below, I don't think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I hear ya. It is a bit difficult to find the middle ground between spilling my guts on cutting releases vs the actual intention of the guide. I'll improve this.

Copy link
Member

Choose a reason for hiding this comment

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

I think ideally this would link to the part of releases.md which talks about the criteria, not sure if there is currently anything in there to link to though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is not anything in the releases.md document regarding this. I'll work on documenting that more specifically as well.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that level of information belongs in this doc, if we can actually figure out what "certain" means then it belongs elsewhere anyway.

The criteria for consideration depends on the target version (Current vs. LTS).
If a cherry-pick does not land cleanly on the staging branch, the releaser
will mark the pull request with a particular label for that release line,
specifying to our tooling that this pull request should not be included. The
releaser will then add a comment that a backport is needed.

## What can be backported?

The "Current" release line (currently v7.x) is much more lenient than the LTS
Copy link
Contributor

Choose a reason for hiding this comment

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

s/(currently v7.x)/(v7.x as of Feb 2017)

Copy link
Member

Choose a reason for hiding this comment

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

Please drop the v in the version.

Copy link
Member

Choose a reason for hiding this comment

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

maybe just drop the (currently v7.x) as it is quickly going to be out of date.

release lines in what can be landed. Our LTS release lines
(currently v4.x and v6.x) require that commits live in a Current release for at
least 2 weeks before backporting. Please see the [`LTS Plan`][] for more
Copy link
Member

Choose a reason for hiding this comment

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

As I understand it, the two week rule doesn't apply to doc fixes and infrastructure changes (things that don't change what we ship). This is probably a question for @nodejs/lts, but either way we should probably be explicit here.

Refs: #11351 (comment) and nodejs/build#613 (comment)

cc/ @bnoordhuis @MylesBorins @misterdjules

Copy link
Member

Choose a reason for hiding this comment

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

The length of time is not set in stone as is based on the potential impact. A doc change has no impact on runtime stability so those, as long as they are relevant to the version, can pretty much land any time. A code change, however, should go through at least one current release cycle to ensure that there are no regressions reported. For changes to more sensitive parts of the code, the length of time may be longer. Anything that is semver-minor will typically be batched up and held much longer than semver-patch so that we have less frequency between LTS minors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on what James said, I think we should remove this part. How does one know what sensitive parts of the codebase are when submitting a backport PR? It's hard to document something that isn't concrete imo.

Copy link
Member

Choose a reason for hiding this comment

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

It's definitely a grey area, but people do talk about the two week rule, so I think we should try and document it somehow, even if we have to say that it's quite subjective.

information. After that time, if the commit can be cherry-picked cleanly from
master, then nothing needs to be done. If not, a backport pull request will
need to be submitted.

## How to submit a backport pull request

For these steps, let's assume that a backport is needed for the v7.x release
line. All commands will use the v7.x-staging branch as the target branch.
In order to submit a backport pull request to another branch, simply replace
that with the staging branch for the targeted release line.

* Checkout the staging branch for the targeted release line
* Make sure that the local staging branch is up to date with the remote
* Create a new branch off of the staging branch

```shell
# Assuming your fork of Node.js is checked out in $NODE_DIR,
# the origin remote points to your fork, and the upstream remote points
# to git://github.com/nodejs/node
cd $NODE_DIR
Copy link
Member

Choose a reason for hiding this comment

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

Might be easier to just say something like:

git clone -o upstream https://github.com/nodejs/node.git && cd node
git remote add fork [email protected]:$USER/node.git
git fetch --all

I'd find it easier to understand, and it doubles as a guide for someone not sure about setting up multiple remotes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, although I would think that origin is more common than fork

Copy link
Member

Choose a reason for hiding this comment

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

I like to be specific in instructions, origin can end up being upstream or fork.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Okay fair enough, makes sense to keep it consistent then.

git checkout v7.x-staging
git pull -r upstream v7.x-staging
# We want to backport pr #10157
git checkout -b backport-10157-to-v7.x
```

* After creating the branch, apply the changes to the branch.

```shell
git cherry-pick $SHA # Use your commit hash
```

Copy link
Member

Choose a reason for hiding this comment

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

At this point do we need to say what you should expect to see and how to fix it up? I assume that following this guide is only needed if the cherry-pick is going to fail (I'm also assuming that $SHA is for the original commit that went into master)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll clarify. Yes, this guide is for when the releaser cannot cleanly cherry-pick the commit and requests a backport.

* The commit message should be as close as possible to the commit message on the
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK I have never changed the original commit message. You can add content to the end of it... but the original message should not chage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there are definitely cases where the commit message should change. Especially when the original commit relies on something that is breaking.

Copy link
Contributor

Choose a reason for hiding this comment

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

To be more specific, the original message should be preserved, that does not preclude adding additional information

Copy link
Contributor

Choose a reason for hiding this comment

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

To be more specific, the original message should be preserved, that does not preclude adding additional information

master branch, unless the commit has to be different due to dependencies that
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, this means the metadata(PR urls, reviewers, etc) should remain the same as the original commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the case of a backport, I don't think it should. I'll clarify that.

are not present in the targeted release line.
* Push the changes to your fork and open a pull request.
Copy link
Member

Choose a reason for hiding this comment

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

There should probably be a:

  • Make sure make -j4 test still passes.

above this line, see #11797 (comment)

* Be sure to target the `v7.x-staging` branch in the pull request.

### Helpful Hints

* Please include the backport target in the pull request title in the following
format: `(v7.x backport) <commit title>`
* Ex. `(v4.x backport) process: improve performance of nextTick`
* Please include the text `Backport of #<pull request number>` in the
pull request description. This will link to the original pull request.

In the event the backport pull request is different than the original,
the backport pull request should be reviewed the same way a new pull request
is reviewed. When each commit is landed, the new reviewers and the new PR-URL
should be used.

[`LTS Plan`]: https://github.com/nodejs/LTS#lts-plan
Copy link
Member

@gibfahn gibfahn Feb 16, 2017

Choose a reason for hiding this comment

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

Is there a reason you used [`LTS Plan`] rather than: [LTS Plan]? It looks a bit odd to me.