Skip to content

Commit 74aaeb7

Browse files
committed
Update book for backport, release and sync
Those were outdated anyway. Now with switching to Josh, the documentation should also be updated, as a lot of things got simplified. This updates the documentation on how to do syncs with josh, how to do releases and how to do backports.
1 parent 993d8ae commit 74aaeb7

File tree

3 files changed

+193
-195
lines changed

3 files changed

+193
-195
lines changed

book/src/development/infrastructure/backport.md

Lines changed: 82 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,68 +5,107 @@ Backports in Clippy are rare and should be approved by the Clippy team. For
55
example, a backport is done, if a crucial ICE was fixed or a lint is broken to a
66
point, that it has to be disabled, before landing on stable.
77

8-
Backports are done to the `beta` branch of Clippy. Backports to stable Clippy
9-
releases basically don't exist, since this would require a Rust point release,
10-
which is almost never justifiable for a Clippy fix.
8+
> Note: If you think a PR should be backported you can label it with
9+
> `beta-nominated`. This has to be done before the Thursday the week before the
10+
> release.
1111
12+
## Filtering PRs to backport
1213

13-
## Backport the changes
14+
First, find all labeled PRs using [this filter][beta-accepted-prs].
15+
16+
Next, look at each PR individually. There are a few things to check. Those need
17+
some explanation and are quite subjective. Good judgement is required.
18+
19+
1. **Is the fix worth a backport?**
20+
21+
This is really subjective. An ICE fix usually is. Moving a lint to a _lower_
22+
group usually as well. An FP fix usually not (on its own). If a backport is
23+
done anyway, FP fixes might also be included. If the PR has a lot of changes,
24+
backports must be considered more carefully.
25+
26+
2. **Is the issue that was fixed by the PR in `beta` already?**
27+
28+
Maybe the issue being fixed didn't make it to `beta` in the Rust repo, yet.
29+
If that's the case, and the fix is already synced to the Rust repo, the fix
30+
doesn't need to be backported. If the fix PR is not synced yet, the fix PR
31+
either needs to be "backported" to the Rust `master` branch or to `beta` in
32+
the next backport cycle.
33+
34+
3. **Is the fix already synced to `master`?**
35+
36+
The fix must already be synced to the Rust `master` branch. Otherwise, the
37+
next `beta` will be missing this fix again. If it is not yet in `master` it
38+
should probably not be backported. If the backport is really important, do an
39+
out-of-cycle sync first. However, the out-of-cycle sync should be small,
40+
because the changes in that sync will get right into `beta`, without being
41+
tested in `nightly` first.
42+
43+
[beta-accepted-prs]: https://github.com/rust-lang/rust-clippy/issues?q=label%3Abeta-nominated
44+
45+
## Preparation
46+
47+
> Note: All commands in this chapter will be run in the Rust clone.
48+
49+
Follow the instructions in [defining remotes] to define the `clippy-upstream`
50+
remote in the Rust repository.
1451

15-
Backports are done on the beta branch of the Clippy repository.
52+
After that, fetch the remote with
1653

1754
```bash
18-
# Assuming the current directory corresponds to the Clippy repository
19-
$ git checkout beta
20-
$ git checkout -b backport
21-
$ git cherry-pick <SHA> # `<SHA>` is the commit hash of the commit(s), that should be backported
22-
$ git push origin backport
55+
$ git fetch clippy-upstream master
2356
```
2457

25-
Now you should test that the backport passes all the tests in the Rust
26-
repository. You can do this with:
58+
Then, switch to the `beta` branch:
2759

2860
```bash
29-
# Assuming the current directory corresponds to the Rust repository
30-
$ git checkout beta
31-
# Make sure to change `your-github-name` to your github name in the following command
32-
$ git subtree pull -p src/tools/clippy https://github.com/<your-github-name>/rust-clippy backport
33-
$ ./x.py test src/tools/clippy
61+
$ git switch beta
62+
$ git fetch upstream
63+
$ git reset --hard upstream/beta
3464
```
3565

36-
Should the test fail, you can fix Clippy directly in the Rust repository. This
37-
has to be first applied to the Clippy beta branch and then again synced to the
38-
Rust repository, though. The easiest way to do this is:
66+
[defining remotes]: release.md#defining-remotes
67+
68+
## Backport the changes
69+
70+
When `bors` merges a PR, the PR is closed with the message
71+
72+
> `bors` merged commit `<sha1>` into `rust-lang:master`
73+
74+
This `<sha1>` is the commit that needs to be backported. To do that, run the
75+
following command in the clone of the **Rust repository**:
3976

4077
```bash
41-
# In the Rust repository
42-
$ git diff --patch --relative=src/tools/clippy > clippy.patch
43-
# In the Clippy repository
44-
$ git apply /path/to/clippy.patch
45-
$ git add -u
46-
$ git commit -m "Fix rustup fallout"
47-
$ git push origin backport
78+
$ git cherry-pick -m 1 `<sha1>`
4879
```
4980

50-
After this, you can open a PR to the `beta` branch of the Clippy repository.
81+
Do this for all PRs that should be backported.
5182

83+
## Open PR in the Rust repository
5284

53-
## Update Clippy in the Rust Repository
85+
Next, open the PR for the backport. Make sure, the PR is opened towards the
86+
`beta` branch and not the `master` branch. The PR description should look like
87+
this:
5488

55-
This step must be done, **after** the PR of the previous step was merged.
89+
```
90+
[beta] Clippy backports
5691
57-
After the backport landed in the Clippy repository, the branch has to be synced
58-
back to the beta branch of the Rust repository.
92+
r? @Mark-Simulacrum
5993
60-
```bash
61-
# Assuming the current directory corresponds to the Rust repository
62-
$ git checkout beta
63-
$ git checkout -b clippy_backport
64-
$ git subtree pull -p src/tools/clippy https://github.com/rust-lang/rust-clippy beta
65-
$ git push origin clippy_backport
94+
Backports:
95+
- <Link to the Clippy PR>
96+
- ...
97+
98+
<Short summary what is backported and why>
6699
```
67100

68-
Make sure to test the backport in the Rust repository before opening a PR. This
69-
is done with `./x.py test src/tools/clippy`. If that passes all tests, open a PR
70-
to the `beta` branch of the Rust repository. In this PR you should tag the
71-
Clippy team member, that agreed to the backport or the `@rust-lang/clippy` team.
72-
Make sure to add `[beta]` to the title of the PR.
101+
Mark is from the release team and they ultimately have to merge the PR before
102+
branching a new `beta` version. Tag them to take care of the backport. Next,
103+
list all the backports and give a short summary what's backported and why it is
104+
worth backporting this.
105+
106+
## Relabel backported PRs
107+
108+
When a PR is backported to Rust `beta`, label the PR with `beta-accepted`. This
109+
will then get picked up when [writing the changelog].
110+
111+
[writing the changelog]: changelog_update.md#31-include-beta-accepted-prs

book/src/development/infrastructure/release.md

Lines changed: 51 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,89 +7,89 @@ Clippy is released together with stable Rust releases. The dates for these
77
releases can be found at the [Rust Forge]. This document explains the necessary
88
steps to create a Clippy release.
99

10-
1. [Remerge the `beta` branch](#remerge-the-beta-branch)
11-
2. [Update the `beta` branch](#update-the-beta-branch)
12-
3. [Find the Clippy commit](#find-the-clippy-commit)
13-
4. [Tag the stable commit](#tag-the-stable-commit)
14-
5. [Update `CHANGELOG.md`](#update-changelogmd)
15-
16-
> _NOTE:_ This document is for stable Rust releases, not for point releases. For
17-
> point releases, step 1. and 2. should be enough.
10+
1. [Defining Remotes](#defining-remotes)
11+
1. [Bump Version](#bump-version)
12+
1. [Find the Clippy commit](#find-the-clippy-commit)
13+
1. [Update the `beta` branch](#update-the-beta-branch)
14+
1. [Update the `stable` branch](#update-the-stable-branch)
15+
1. [Tag the stable commit](#tag-the-stable-commit)
16+
1. [Update `CHANGELOG.md`](#update-changelogmd)
1817

1918
[Rust Forge]: https://forge.rust-lang.org/
2019

21-
## Remerge the `beta` branch
22-
23-
This step is only necessary, if since the last release something was backported
24-
to the beta Rust release. The remerge is then necessary, to make sure that the
25-
Clippy commit, that was used by the now stable Rust release, persists in the
26-
tree of the Clippy repository.
20+
## Defining Remotes
2721

28-
To find out if this step is necessary run
22+
You may want to define the `upstream` remote of the Clippy project to simplify
23+
the following steps. However, this is optional and you can replace `upstream`
24+
with the full URL instead.
2925

3026
```bash
31-
# Assumes that the local master branch of rust-lang/rust-clippy is up-to-date
32-
$ git fetch upstream
33-
$ git branch master --contains upstream/beta
27+
$ git remote add upstream [email protected]:rust-lang/rust-clippy
3428
```
3529

36-
If this command outputs `master`, this step is **not** necessary.
30+
## Bump Version
3731

38-
```bash
39-
# Assuming `HEAD` is the current `master` branch of rust-lang/rust-clippy
40-
$ git checkout -b backport_remerge
41-
$ git merge upstream/beta
42-
$ git diff # This diff has to be empty, otherwise something with the remerge failed
43-
$ git push origin backport_remerge # This can be pushed to your fork
32+
When a release needs to be done, `cargo test` will fail, if the versions in the
33+
`Cargo.toml` are not correct. During that sync, the versions need to be bumped.
34+
This is done by running:
35+
36+
```
37+
$ cargo dev release bump_version
4438
```
4539

46-
After this, open a PR to the master branch. In this PR, the commit hash of the
47-
`HEAD` of the `beta` branch must exist. In addition to that, no files should be
48-
changed by this PR.
40+
This will increase the version number of each relevant `Cargo.toml` file. After
41+
that, just commit the updated files with:
4942

50-
## Update the `beta` branch
43+
```bash
44+
# XX should be exchanged with the corresponding version
45+
$ git commit -m "Bump Clippy version -> 0.1.XX" **/*Cargo.toml
46+
```
47+
48+
## Find the Clippy commit
5149

52-
This step must be done **after** the PR of the previous step was merged.
50+
For both, updating the `beta` and the `stable` branch, the first step is to find
51+
the Clippy commit of the last Clippy sync done in the respective Rust branch.
5352

54-
First, the Clippy commit of the `beta` branch of the Rust repository has to be
55-
determined.
53+
Running the following command will get the commit for the specified branch:
5654

5755
```bash
58-
# Assuming the current directory corresponds to the Rust repository
59-
$ git fetch upstream
60-
$ git checkout upstream/beta
61-
$ BETA_SHA=$(git log --oneline -- src/tools/clippy/ | grep -o "Merge commit '[a-f0-9]*' into .*" | head -1 | sed -e "s/Merge commit '\([a-f0-9]*\)' into .*/\1/g")
56+
$ SHA=$(cargo dev release commit /path/to/rust <branch>)
6257
```
6358

64-
After finding the Clippy commit, the `beta` branch in the Clippy repository can
65-
be updated.
59+
Where the `/path/to/rust` is a relative path to a Rust clone and the `<branch>`
60+
is one of `stable`, `beta`, or `master`.
61+
62+
## Update the `beta` branch
63+
64+
After getting the commit of the `beta` branch, the `beta` branch in the Clippy
65+
repository can be updated.
6666

6767
```bash
68-
# Assuming the current directory corresponds to the Clippy repository
6968
$ git checkout beta
70-
$ git reset --hard $BETA_SHA
69+
$ git reset --hard $SHA
7170
$ git push upstream beta
7271
```
7372

74-
## Find the Clippy commit
73+
## Update the `stable` branch
7574

76-
The first step is to tag the Clippy commit, that is included in the stable Rust
77-
release. This commit can be found in the Rust repository.
75+
After getting the commit of the `stable` branch, the `stable` branch in the
76+
Clippy repository can be updated.
7877

7978
```bash
80-
# Assuming the current directory corresponds to the Rust repository
81-
$ git fetch upstream # `upstream` is the `rust-lang/rust` remote
82-
$ git checkout 1.XX.0 # XX should be exchanged with the corresponding version
83-
$ SHA=$(git log --oneline -- src/tools/clippy/ | grep -o "Merge commit '[a-f0-9]*' into .*" | head -1 | sed -e "s/Merge commit '\([a-f0-9]*\)' into .*/\1/g")
79+
$ git checkout stable
80+
$ git reset --hard $SHA
81+
$ git push upstream stable
8482
```
8583

86-
## Tag the stable commit
84+
## Tag the `stable` commit
8785

88-
After finding the Clippy commit, it can be tagged with the release number.
86+
After updating the `stable` branch, tag the HEAD commit and push it to the
87+
Clippy repo.
88+
89+
> Note: Only push the tag, once the Deploy GitHub action of the `beta` branch is
90+
> finished. Otherwise the deploy for the tag might fail.
8991
9092
```bash
91-
# Assuming the current directory corresponds to the Clippy repository
92-
$ git checkout $SHA
9393
$ git tag rust-1.XX.0 # XX should be exchanged with the corresponding version
9494
$ git push upstream rust-1.XX.0 # `upstream` is the `rust-lang/rust-clippy` remote
9595
```
@@ -98,22 +98,6 @@ After this, the release should be available on the Clippy [release page].
9898

9999
[release page]: https://github.com/rust-lang/rust-clippy/releases
100100

101-
## Update the `stable` branch
102-
103-
At this step you should have already checked out the commit of the `rust-1.XX.0`
104-
tag. Updating the stable branch from here is as easy as:
105-
106-
```bash
107-
# Assuming the current directory corresponds to the Clippy repository and the
108-
# commit of the just created rust-1.XX.0 tag is checked out.
109-
$ git push upstream rust-1.XX.0:stable # `upstream` is the `rust-lang/rust-clippy` remote
110-
```
111-
112-
> _NOTE:_ Usually there are no stable backports for Clippy, so this update
113-
> should be possible without force pushing or anything like this. If there
114-
> should have happened a stable backport, make sure to re-merge those changes
115-
> just as with the `beta` branch.
116-
117101
## Update `CHANGELOG.md`
118102

119103
For this see the document on [how to update the changelog].

0 commit comments

Comments
 (0)