Skip to content

Commit

Permalink
Auto merge of #6401 - ebroto:pin_to_a_nightly, r=<try>
Browse files Browse the repository at this point in the history
📌 Pin Clippy to a nightly 📌

changelog: none

Addresses partially #5561. As proposed there in [this comment](#5561 (comment)), this kicks off the process, to help us get acquainted with how the syncs should work, before working on improving the tooling.

Open questions:
* When performing a rustup, we will need to exclude the commits that were merged that same day, or else wait until that nightly is released. I did not update the documentation about this part, mainly because I'm not sure about how to do that.
* When should we perform the rustups now? My first idea is to do it at the same time we do the clippyups, to have a clear cadence and to avoid the two copies of the repo to diverge enough to make the process painful.
* Who does the rustups now? If we follow my previous idea and do both rustup and clippyup at the same time, it would be more work for `@flip1995` who currently does the clippyups. I would prefer to establish some kind of rotation to spead the work. Other ideas?
* I'm not sure if this affects the release process in any way.
* ???

`@rust-lang/clippy` thoughts?

r? `@flip1995`
  • Loading branch information
bors committed Dec 9, 2020
2 parents 6c70133 + 465bbd2 commit 3a78fc2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 101 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/clippy.yml
Expand Up @@ -52,13 +52,10 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cargo
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-v2-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu
- name: Master Toolchain Setup
run: bash setup-toolchain.sh

# Run
- name: Set LD_LIBRARY_PATH (Linux)
run: |
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/clippy_bors.yml
Expand Up @@ -101,15 +101,10 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cargo
key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }}
key: ${{ runner.os }}-${{ matrix.host }}-v2-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.host }}
- name: Master Toolchain Setup
run: bash setup-toolchain.sh
env:
HOST_TOOLCHAIN: ${{ matrix.host }}

# Run
- name: Set LD_LIBRARY_PATH (Linux)
if: runner.os == 'Linux'
Expand Down Expand Up @@ -188,13 +183,10 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cargo
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-v2-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu
- name: Master Toolchain Setup
run: bash setup-toolchain.sh

# Run
- name: Build Integration Test
run: cargo test --test integration --features integration --no-run
Expand Down Expand Up @@ -269,13 +261,10 @@ jobs:
uses: actions/cache@v2
with:
path: ~/.cargo
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }}
key: ${{ runner.os }}-x86_64-unknown-linux-gnu-v2-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-x86_64-unknown-linux-gnu
- name: Master Toolchain Setup
run: bash setup-toolchain.sh

# Download
- name: Download target dir
uses: actions/download-artifact@v1
Expand Down
43 changes: 23 additions & 20 deletions CONTRIBUTING.md
Expand Up @@ -182,18 +182,26 @@ That's why the `else_if_without_else` example uses the `register_early_pass` fun
[early_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
[late_lint_pass]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.LateLintPass.html

## Fixing build failures caused by Rust
## Syncing changes between Clippy and [`rust-lang/rust`]

Clippy currently gets built with `rustc` of the `rust-lang/rust` `master`
branch. Most of the times we have to adapt to the changes and only very rarely
there's an actual bug in Rust.
Clippy currently gets built with a pinned nightly version.

If you decide to make Clippy work again with a Rust commit that breaks it, you
have to sync the `rust-lang/rust-clippy` repository with the `subtree` copy of
Clippy in the `rust-lang/rust` repository.
In the `rust-lang/rust` repository, where rustc resides, there's a copy of Clippy
that compiler hackers modify from time to time to adapt to changes in the unstable
API of the compiler.

For general information about `subtree`s in the Rust repository see [Rust's
`CONTRIBUTING.md`][subtree].
We need to sync these changes back to this repository periodically, and the changes
made to this repository in the meantime also need to be synced to the `rust-lang/rust` repository.

To avoid flooding the `rust-lang/rust` PR queue, this two-way sync process is done
in a bi-weekly basis if there's no urgent changes. This is done starting on the day of
the Rust stable release and then every other week. That way we guarantee that we keep
this repo up to date with the latest compiler API, and every feature in Clippy is available
for 2 weeks in nightly, before it can get to beta. For reference, the first sync
following this cadence was performed the 2020-08-27.

This process is described in detail in the following sections. For general information
about `subtree`s in the Rust repository see [Rust's `CONTRIBUTING.md`][subtree].

### Patching git-subtree to work with big repos

Expand Down Expand Up @@ -222,13 +230,14 @@ This shell has a hardcoded recursion limit set to 1000. In order to make this pr
you need to force the script to run `bash` instead. You can do this by editing the first
line of the `git-subtree` script and changing `sh` to `bash`.

### Performing the sync
### Performing the sync from [`rust-lang/rust`] to Clippy

Here is a TL;DR version of the sync process (all of the following commands have
to be run inside the `rust` directory):

1. Clone the [`rust-lang/rust`] repository
2. Sync the changes to the rust-copy of Clippy to your Clippy fork:
1. Clone the [`rust-lang/rust`] repository or make sure it is up to date.
2. Checkout the commit from the latest available nightly. You can get it using `rustup check`.
3. Sync the changes to the rust-copy of Clippy to your Clippy fork:
```bash
# Make sure to change `your-github-name` to your github name in the following command
git subtree push -P src/tools/clippy git@github.com:your-github-name/rust-clippy sync-from-rust
Expand All @@ -246,17 +255,11 @@ to be run inside the `rust` directory):
git checkout sync-from-rust
git merge upstream/master
```
3. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
4. Open a PR to `rust-lang/rust-clippy` and wait for it to get merged (to
accelerate the process ping the `@rust-lang/clippy` team in your PR and/or
~~annoy~~ ask them in the [Zulip] stream.)

### Syncing back changes in Clippy to [`rust-lang/rust`]

To avoid flooding the [`rust-lang/rust`] PR queue, changes in Clippy's repo are synced back
in a bi-weekly basis if there's no urgent changes. This is done starting on the day of
the Rust stable release and then every other week. That way we guarantee that
every feature in Clippy is available for 2 weeks in nightly, before it can get to beta.
For reference, the first sync following this cadence was performed the 2020-08-27.
### Performing the sync from Clippy to [`rust-lang/rust`]

All of the following commands have to be run inside the `rust` directory.

Expand Down
30 changes: 4 additions & 26 deletions doc/basics.md
@@ -1,16 +1,14 @@
# Basics for hacking on Clippy

This document explains the basics for hacking on Clippy. Besides others, this
includes how to set-up the development environment, how to build and how to test
Clippy. For a more in depth description on the codebase take a look at [Adding
Lints] or [Common Tools].
includes how to build and test Clippy. For a more in depth description on
the codebase take a look at [Adding Lints] or [Common Tools].

[Adding Lints]: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md
[Common Tools]: https://github.com/rust-lang/rust-clippy/blob/master/doc/common_tools_writing_lints.md

- [Basics for hacking on Clippy](#basics-for-hacking-on-clippy)
- [Get the code](#get-the-code)
- [Setup](#setup)
- [Building and Testing](#building-and-testing)
- [`cargo dev`](#cargo-dev)
- [PR](#pr)
Expand All @@ -36,31 +34,11 @@ git checkout master
git rebase upstream/master
# push to the master branch of your fork
git push
```

## Setup

Next we need to setup the toolchain to compile Clippy. Since Clippy heavily
relies on compiler internals it is build with the latest rustc master. To get
this toolchain, you can just use the `setup-toolchain.sh` script or use
`rustup-toolchain-install-master`:

```bash
bash setup-toolchain.sh
# OR
cargo install rustup-toolchain-install-master
# For better IDE integration also add `-c rustfmt -c rust-src` (optional)
rustup-toolchain-install-master -f -n master -c rustc-dev -c llvm-tools
rustup override set master
```

_Note:_ Sometimes you may get compiler errors when building Clippy, even if you
didn't change anything. Normally those will be fixed by a maintainer in a few hours.
```

## Building and Testing

Once the `master` toolchain is installed, you can build and test Clippy like
every other Rust project:
You can build and test Clippy like every other Rust project:

```bash
cargo build # builds Clippy
Expand Down
4 changes: 3 additions & 1 deletion rust-toolchain
@@ -1 +1,3 @@
nightly
[toolchain]
channel = "nightly-2020-12-09"
components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"]
36 changes: 0 additions & 36 deletions setup-toolchain.sh

This file was deleted.

0 comments on commit 3a78fc2

Please sign in to comment.