From db1926f29e0ad02036322e40dc92fcf68e0a6bcc Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 20 Jan 2020 16:03:26 +0100 Subject: [PATCH 01/25] Add integration test GitHub action --- .github/workflows/integration.yml | 69 +++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 000000000000..fc05ee9b9210 --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,69 @@ +name: Integration + +on: + push: + branches: + - auto + - try + # Don't run integration tests, when only textfiles were modified + paths-ignore: + - 'COPYRIGHT' + - 'LICENSE-*' + - '**.md' + - '**.txt' + +env: + RUST_BACKTRACE: 1 + +jobs: + integration: + strategy: + fail-fast: false + matrix: + integration: + - 'rust-lang/rls' + - 'rust-lang/cargo' + - 'rust-lang/chalk' + - 'Geal/nom' + - 'rust-lang/rustfmt' + - 'hyperium/hyper' + - 'rust-itertools/itertools' + - 'serde-rs/serde' + - 'rust-lang/stdarch' + - 'rust-random/rand' + - 'rust-lang/futures-rs' + - 'Marwes/combine' + - 'rust-lang-nursery/failure' + - 'rust-lang/log' + - 'chronotope/chrono' + runs-on: ubuntu-latest + + steps: + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: x86_64-unknown-linux-gnu + profile: minimal + - name: Cache cargo dir + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-x86_64-unknown-linux-gnu + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Master Toolchain Setup + run: bash setup-toolchain.sh + + - name: Build + run: cargo build --features integration + - name: Test ${{ matrix.integration }} + run: cargo test --test integration --features integration + env: + INTEGRATION: ${{ matrix.integration }} + + - name: Run cargo-cache --autoclean + run: | + cargo install cargo-cache --debug + find ~/.cargo/bin ! -type d -exec strip {} \; + cargo cache --autoclean From 1f0b73ba49192e7fc881f9d296ad8c1ce80d7050 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 13:46:53 +0100 Subject: [PATCH 02/25] Add clippy_dev checks to GitHub Actions --- .github/workflows/clippy_dev.yml | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/clippy_dev.yml diff --git a/.github/workflows/clippy_dev.yml b/.github/workflows/clippy_dev.yml new file mode 100644 index 000000000000..d054b6ba750c --- /dev/null +++ b/.github/workflows/clippy_dev.yml @@ -0,0 +1,44 @@ +name: Clippy Dev Test + +on: + # Only run on paths, that get checked by the clippy_dev tool + push: + paths: + - 'CAHNGELOG.md' + - 'README.md' + - '**.stderr' + - '**.rs' + pull_request: + paths: + - 'CAHNGELOG.md' + - 'README.md' + - '**.stderr' + - '**.rs' + +env: + RUST_BACKTRACE: 1 + +jobs: + clippy_dev: + runs-on: ubuntu-latest + + steps: + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: x86_64-unknown-linux-gnu + profile: minimal + components: rustfmt + - name: Checkout + uses: actions/checkout@v2.0.0 + + - name: Build + run: cargo build --features deny-warnings + working-directory: clippy_dev + - name: Test limit-stderr-length + run: cargo dev --limit-stderr-length + - name: Test update_lints + run: cargo dev update_lints --check + - name: Test fmt + run: cargo dev fmt --check From df8297551b49548e9085070ff6b3887fadb3e56c Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 15:29:54 +0100 Subject: [PATCH 03/25] Add remark check to GHA --- .github/workflows/remark.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/remark.yml diff --git a/.github/workflows/remark.yml b/.github/workflows/remark.yml new file mode 100644 index 000000000000..8e311c75df08 --- /dev/null +++ b/.github/workflows/remark.yml @@ -0,0 +1,24 @@ +name: Remark + +on: + push: + paths: + - '**.md' + pull_request: + paths: + - '**.md' + +jobs: + remark: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Setup Node.js + uses: actions/setup-node@v1.1.0 + - name: Install remark + run: npm install remark-cli remark-lint remark-lint-maximum-line-length remark-preset-lint-recommended + + - name: Check *.md files + run: git ls-files -z '*.md' | xargs -0 -n 1 -I {} ./node_modules/.bin/remark {} -u lint -f > /dev/null From fd6ce30ccbe052eb2de0e4262a8d9cf1816b445e Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 16:32:25 +0100 Subject: [PATCH 04/25] Rename .remarkrc.json -> .remarkrc and fix file --- .remarkrc | 12 ++++++++++++ .remarkrc.json | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 .remarkrc delete mode 100644 .remarkrc.json diff --git a/.remarkrc b/.remarkrc new file mode 100644 index 000000000000..0ede7ac75cb6 --- /dev/null +++ b/.remarkrc @@ -0,0 +1,12 @@ +{ + "plugins": [ + "remark-preset-lint-recommended", + ["remark-lint-list-item-indent", false], + ["remark-lint-no-literal-urls", false], + ["remark-lint-no-shortcut-reference-link", false], + ["remark-lint-maximum-line-length", 120] + ], + "settings": { + "commonmark": true + } +} diff --git a/.remarkrc.json b/.remarkrc.json deleted file mode 100644 index 22bae13ccf88..000000000000 --- a/.remarkrc.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "plugins": { - "lint": { - "table-pipes": false, - "table-pipe-alignment": false, - "maximum-line-length": 120 - } - }, - "settings": { - "commonmark": true - } -} From a3d541715f652e6557f4401792126d5547aec70c Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 16:39:58 +0100 Subject: [PATCH 05/25] Fix markdown Files Rendered: [CHANGELOG.md](https://github.com/flip1995/rust-clippy/blob/gha/CHANGELOG.md) [CODE_OF_CONDUCT.md](https://github.com/flip1995/rust-clippy/blob/gha/CODE_OF_CONDUCT.md) [CONTRIBUTING.md](https://github.com/flip1995/rust-clippy/blob/gha/CONTRIBUTING.md) [README.md](https://github.com/flip1995/rust-clippy/blob/gha/README.md) [clippy_dummy/PUBLISH.md](https://github.com/flip1995/rust-clippy/blob/gha/clippy_dummy/PUBLISH.md) [doc/adding_lints.md](https://github.com/flip1995/rust-clippy/blob/gha/doc/adding_lints.md) [etc/relicense/RELICENSE_DOCUMENTATION.md](https://github.com/flip1995/rust-clippy/blob/gha/etc/relicense/RELICENSE_DOCUMENTATION.md) --- CHANGELOG.md | 105 ++++++++++++----------- CODE_OF_CONDUCT.md | 60 +++++++++---- CONTRIBUTING.md | 64 ++++++++------ README.md | 16 ++-- clippy_dummy/PUBLISH.md | 8 +- doc/adding_lints.md | 11 ++- etc/relicense/RELICENSE_DOCUMENTATION.md | 75 +++++++++++----- 7 files changed, 213 insertions(+), 126 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb3b518cd8f4..85203e569e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -203,29 +203,29 @@ Released 2019-07-04 [eb9f9b1...082cfa7](https://github.com/rust-lang/rust-clippy/compare/eb9f9b1...082cfa7) - * New lints: [`find_map`], [`filter_map_next`] [#4039](https://github.com/rust-lang/rust-clippy/pull/4039) - * New lint: [`path_buf_push_overwrite`] [#3954](https://github.com/rust-lang/rust-clippy/pull/3954) - * Move `path_buf_push_overwrite` to the nursery [#4013](https://github.com/rust-lang/rust-clippy/pull/4013) - * Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101) - * Allow allowing of [`toplevel_ref_arg`] lint [#4007](https://github.com/rust-lang/rust-clippy/pull/4007) - * Fix false negative in [`or_fun_call`] pertaining to nested constructors [#4084](https://github.com/rust-lang/rust-clippy/pull/4084) - * Fix false positive in [`or_fn_call`] pertaining to enum variant constructors [#4018](https://github.com/rust-lang/rust-clippy/pull/4018) - * Fix false positive in [`useless_let_if_seq`] pertaining to interior mutability [#4035](https://github.com/rust-lang/rust-clippy/pull/4035) - * Fix false positive in [`redundant_closure`] pertaining to non-function types [#4008](https://github.com/rust-lang/rust-clippy/pull/4008) - * Fix false positive in [`let_and_return`] pertaining to attributes on `let`s [#4024](https://github.com/rust-lang/rust-clippy/pull/4024) - * Fix false positive in [`module_name_repetitions`] lint pertaining to attributes [#4006](https://github.com/rust-lang/rust-clippy/pull/4006) - * Fix false positive on [`assertions_on_constants`] pertaining to `debug_assert!` [#3989](https://github.com/rust-lang/rust-clippy/pull/3989) - * Improve suggestion in [`map_clone`] to suggest `.copied()` where applicable [#3970](https://github.com/rust-lang/rust-clippy/pull/3970) [#4043](https://github.com/rust-lang/rust-clippy/pull/4043) - * Improve suggestion for [`search_is_some`] [#4049](https://github.com/rust-lang/rust-clippy/pull/4049) - * Improve suggestion applicability for [`naive_bytecount`] [#3984](https://github.com/rust-lang/rust-clippy/pull/3984) - * Improve suggestion applicability for [`while_let_loop`] [#3975](https://github.com/rust-lang/rust-clippy/pull/3975) - * Improve diagnostics for [`too_many_arguments`] [#4053](https://github.com/rust-lang/rust-clippy/pull/4053) - * Improve diagnostics for [`cast_lossless`] [#4021](https://github.com/rust-lang/rust-clippy/pull/4021) - * Deal with macro checks in desugarings better [#4082](https://github.com/rust-lang/rust-clippy/pull/4082) - * Add macro check for [`unnecessary_cast`] [#4026](https://github.com/rust-lang/rust-clippy/pull/4026) - * Remove [`approx_constant`]'s documentation's "Known problems" section. [#4027](https://github.com/rust-lang/rust-clippy/pull/4027) - * Fix ICE in [`suspicious_else_formatting`] [#3960](https://github.com/rust-lang/rust-clippy/pull/3960) - * Fix ICE in [`decimal_literal_representation`] [#3931](https://github.com/rust-lang/rust-clippy/pull/3931) +* New lints: [`find_map`], [`filter_map_next`] [#4039](https://github.com/rust-lang/rust-clippy/pull/4039) +* New lint: [`path_buf_push_overwrite`] [#3954](https://github.com/rust-lang/rust-clippy/pull/3954) +* Move `path_buf_push_overwrite` to the nursery [#4013](https://github.com/rust-lang/rust-clippy/pull/4013) +* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101) +* Allow allowing of [`toplevel_ref_arg`] lint [#4007](https://github.com/rust-lang/rust-clippy/pull/4007) +* Fix false negative in [`or_fun_call`] pertaining to nested constructors [#4084](https://github.com/rust-lang/rust-clippy/pull/4084) +* Fix false positive in [`or_fun_call`] pertaining to enum variant constructors [#4018](https://github.com/rust-lang/rust-clippy/pull/4018) +* Fix false positive in [`useless_let_if_seq`] pertaining to interior mutability [#4035](https://github.com/rust-lang/rust-clippy/pull/4035) +* Fix false positive in [`redundant_closure`] pertaining to non-function types [#4008](https://github.com/rust-lang/rust-clippy/pull/4008) +* Fix false positive in [`let_and_return`] pertaining to attributes on `let`s [#4024](https://github.com/rust-lang/rust-clippy/pull/4024) +* Fix false positive in [`module_name_repetitions`] lint pertaining to attributes [#4006](https://github.com/rust-lang/rust-clippy/pull/4006) +* Fix false positive on [`assertions_on_constants`] pertaining to `debug_assert!` [#3989](https://github.com/rust-lang/rust-clippy/pull/3989) +* Improve suggestion in [`map_clone`] to suggest `.copied()` where applicable [#3970](https://github.com/rust-lang/rust-clippy/pull/3970) [#4043](https://github.com/rust-lang/rust-clippy/pull/4043) +* Improve suggestion for [`search_is_some`] [#4049](https://github.com/rust-lang/rust-clippy/pull/4049) +* Improve suggestion applicability for [`naive_bytecount`] [#3984](https://github.com/rust-lang/rust-clippy/pull/3984) +* Improve suggestion applicability for [`while_let_loop`] [#3975](https://github.com/rust-lang/rust-clippy/pull/3975) +* Improve diagnostics for [`too_many_arguments`] [#4053](https://github.com/rust-lang/rust-clippy/pull/4053) +* Improve diagnostics for [`cast_lossless`] [#4021](https://github.com/rust-lang/rust-clippy/pull/4021) +* Deal with macro checks in desugarings better [#4082](https://github.com/rust-lang/rust-clippy/pull/4082) +* Add macro check for [`unnecessary_cast`] [#4026](https://github.com/rust-lang/rust-clippy/pull/4026) +* Remove [`approx_constant`]'s documentation's "Known problems" section. [#4027](https://github.com/rust-lang/rust-clippy/pull/4027) +* Fix ICE in [`suspicious_else_formatting`] [#3960](https://github.com/rust-lang/rust-clippy/pull/3960) +* Fix ICE in [`decimal_literal_representation`] [#3931](https://github.com/rust-lang/rust-clippy/pull/3931) ## Rust 1.35 @@ -234,27 +234,27 @@ Released 2019-05-20 [1fac380..37f5c1e](https://github.com/rust-lang/rust-clippy/compare/1fac380...37f5c1e) - * New lint: [`drop_bounds`] to detect `T: Drop` bounds - * Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101) - * Rename `cyclomatic_complexity` to [`cognitive_complexity`], start work on making lint more practical for Rust code - * Move [`get_unwrap`] to the restriction category - * Improve suggestions for [`iter_cloned_collect`] - * Improve suggestions for [`cast_lossless`] to suggest suffixed literals - * Fix false positives in [`print_with_newline`] and [`write_with_newline`] pertaining to raw strings - * Fix false positive in [`needless_range_loop`] pertaining to structs without a `.iter()` - * Fix false positive in [`bool_comparison`] pertaining to non-bool types - * Fix false positive in [`redundant_closure`] pertaining to differences in borrows - * Fix false positive in [`option_map_unwrap_or`] on non-copy types - * Fix false positives in [`missing_const_for_fn`] pertaining to macros and trait method impls - * Fix false positive in [`needless_pass_by_value`] pertaining to procedural macros - * Fix false positive in [`needless_continue`] pertaining to loop labels - * Fix false positive for [`boxed_local`] pertaining to arguments moved into closures - * Fix false positive for [`use_self`] in nested functions - * Fix suggestion for [`expect_fun_call`] (https://github.com/rust-lang/rust-clippy/pull/3846) - * Fix suggestion for [`explicit_counter_loop`] to deal with parenthesizing range variables - * Fix suggestion for [`single_char_pattern`] to correctly escape single quotes - * Avoid triggering [`redundant_closure`] in macros - * ICE fixes: [#3805](https://github.com/rust-lang/rust-clippy/pull/3805), [#3772](https://github.com/rust-lang/rust-clippy/pull/3772), [#3741](https://github.com/rust-lang/rust-clippy/pull/3741) +* New lint: [`drop_bounds`] to detect `T: Drop` bounds +* Split [`redundant_closure`] into [`redundant_closure`] and [`redundant_closure_for_method_calls`] [#4110](https://github.com/rust-lang/rust-clippy/pull/4101) +* Rename `cyclomatic_complexity` to [`cognitive_complexity`], start work on making lint more practical for Rust code +* Move [`get_unwrap`] to the restriction category +* Improve suggestions for [`iter_cloned_collect`] +* Improve suggestions for [`cast_lossless`] to suggest suffixed literals +* Fix false positives in [`print_with_newline`] and [`write_with_newline`] pertaining to raw strings +* Fix false positive in [`needless_range_loop`] pertaining to structs without a `.iter()` +* Fix false positive in [`bool_comparison`] pertaining to non-bool types +* Fix false positive in [`redundant_closure`] pertaining to differences in borrows +* Fix false positive in [`option_map_unwrap_or`] on non-copy types +* Fix false positives in [`missing_const_for_fn`] pertaining to macros and trait method impls +* Fix false positive in [`needless_pass_by_value`] pertaining to procedural macros +* Fix false positive in [`needless_continue`] pertaining to loop labels +* Fix false positive for [`boxed_local`] pertaining to arguments moved into closures +* Fix false positive for [`use_self`] in nested functions +* Fix suggestion for [`expect_fun_call`] (https://github.com/rust-lang/rust-clippy/pull/3846) +* Fix suggestion for [`explicit_counter_loop`] to deal with parenthesizing range variables +* Fix suggestion for [`single_char_pattern`] to correctly escape single quotes +* Avoid triggering [`redundant_closure`] in macros +* ICE fixes: [#3805](https://github.com/rust-lang/rust-clippy/pull/3805), [#3772](https://github.com/rust-lang/rust-clippy/pull/3772), [#3741](https://github.com/rust-lang/rust-clippy/pull/3741) ## Rust 1.34 @@ -551,7 +551,7 @@ Released 2018-09-13 ## 0.0.181 * Rustup to *rustc 1.25.0-nightly (97520ccb1 2018-01-21)* * New lints: [`else_if_without_else`], [`option_option`], [`unit_arg`], [`unnecessary_fold`] -* Removed [`unit_expr`] +* Removed `unit_expr` * Various false positive fixes for [`needless_pass_by_value`] ## 0.0.180 @@ -597,11 +597,13 @@ Released 2018-09-13 ## 0.0.167 * Rustup to *rustc 1.23.0-nightly (90ef3372e 2017-10-29)* -* New lints: [`const_static_lifetime`], [`erasing_op`], [`fallible_impl_from`], [`println_empty_string`], [`useless_asref`] +* New lints: `const_static_lifetime`, [`erasing_op`], [`fallible_impl_from`], [`println_empty_string`], [`useless_asref`] ## 0.0.166 * Rustup to *rustc 1.22.0-nightly (b7960878b 2017-10-18)* -* New lints: [`explicit_write`], [`identity_conversion`], [`implicit_hasher`], [`invalid_ref`], [`option_map_or_none`], [`range_minus_one`], [`range_plus_one`], [`transmute_int_to_bool`], [`transmute_int_to_char`], [`transmute_int_to_float`] +* New lints: [`explicit_write`], [`identity_conversion`], [`implicit_hasher`], [`invalid_ref`], [`option_map_or_none`], + [`range_minus_one`], [`range_plus_one`], [`transmute_int_to_bool`], [`transmute_int_to_char`], + [`transmute_int_to_float`] ## 0.0.165 * Rust upgrade to rustc 1.22.0-nightly (0e6f4cf51 2017-09-27) @@ -636,7 +638,7 @@ Released 2018-09-13 ## 0.0.157 - 2017-09-04 * Update to *rustc 1.22.0-nightly (981ce7d8d 2017-09-03)* -* New lint: [`unit_expr`] +* New lint: `unit_expr` ## 0.0.156 - 2017-09-03 * Update to *rustc 1.22.0-nightly (744dd6c1d 2017-09-02)* @@ -884,7 +886,7 @@ Released 2018-09-13 lint groups: [`filter_next`], [`for_loop_over_option`], [`for_loop_over_result`] and [`match_overlapping_arm`]. You should now be able to `#[allow/deny]` them individually and they are available directly - through [`cargo clippy`]. + through `cargo clippy`. ## 0.0.87 — 2016-08-31 * Rustup to *rustc 1.13.0-nightly (eac41469d 2016-08-30)* @@ -897,7 +899,7 @@ Released 2018-09-13 ## 0.0.85 — 2016-08-19 * Fix ICE with [`useless_attribute`] -* [`useless_attribute`] ignores [`unused_imports`] on `use` statements +* [`useless_attribute`] ignores `unused_imports` on `use` statements ## 0.0.84 — 2016-08-18 * Rustup to *rustc 1.13.0-nightly (aef6971ca 2016-08-17)* @@ -936,7 +938,7 @@ Released 2018-09-13 ## 0.0.77 — 2016-06-21 * Rustup to *rustc 1.11.0-nightly (5522e678b 2016-06-20)* -* New lints: [`stutter`] and [`iter_nth`] +* New lints: `stutter` and [`iter_nth`] ## 0.0.76 — 2016-06-10 * Rustup to *rustc 1.11.0-nightly (7d2f75a95 2016-06-09)* @@ -1056,6 +1058,7 @@ Released 2018-09-13 [pull3665]: https://github.com/rust-lang/rust-clippy/pull/3665 [adding_lints]: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md + [`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons [`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index d70b2b52aca1..dec13e44a17f 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,35 +6,65 @@ A version of this document [can be found online](https://www.rust-lang.org/condu **Contact**: [rust-mods@rust-lang.org](mailto:rust-mods@rust-lang.org) -* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality, or other similar characteristic. -* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and welcoming environment for all. +* We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, + gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, + religion, nationality, or other similar characteristic. +* On IRC, please avoid using overtly sexual nicknames or other nicknames that might detract from a friendly, safe and + welcoming environment for all. * Please be kind and courteous. There's no need to be mean or rude. -* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer. -* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and see how it works. -* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We interpret the term "harassment" as including the definition in the Citizen Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. -* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a safe place for you and we've got your back. +* Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and + numerous costs. There is seldom a right answer. +* Please keep unstructured critique to a minimum. If you have solid ideas you want to experiment with, make a fork and + see how it works. +* We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior. We + interpret the term "harassment" as including the definition in the Citizen + Code of Conduct; if you have any lack of clarity about what might be included in that concept, please read their + definition. In particular, we don't tolerate behavior that excludes people in socially marginalized groups. +* Private harassment is also unacceptable. No matter who you are, if you feel you have been or are being harassed or + made uncomfortable by a community member, please contact one of the channel ops or any of the [Rust moderation + team][mod_team] immediately. Whether you're a regular contributor or a newcomer, we care about making this community a + safe place for you and we've got your back. * Likewise any spamming, trolling, flaming, baiting or other attention-stealing behavior is not welcome. ## Moderation -These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, please contact the [Rust moderation team][mod_team]. +These are the policies for upholding our community's standards of conduct. If you feel that a thread needs moderation, +please contact the [Rust moderation team][mod_team]. -1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) +1. Remarks that violate the Rust standards of conduct, including hateful, hurtful, oppressive, or exclusionary remarks, + are not allowed. (Cursing is allowed, but never targeting another user, and never in a hateful manner.) 2. Remarks that moderators find inappropriate, whether listed in the code of conduct or not, are also not allowed. 3. Moderators will first respond to such remarks with a warning. 4. If the warning is unheeded, the user will be "kicked," i.e., kicked out of the communication channel to cool off. 5. If the user comes back and continues to make trouble, they will be banned, i.e., indefinitely excluded. -6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended party a genuine apology. -7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a different moderator, **in private**. Complaints about bans in-channel are not allowed. -8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate situation, they should expect less leeway than others. +6. Moderators may choose at their discretion to un-ban the user if it was a first offense and they offer the offended + party a genuine apology. +7. If a moderator bans someone and you think it was unjustified, please take it up with that moderator, or with a + different moderator, **in private**. Complaints about bans in-channel are not allowed. +8. Moderators are held to a higher standard than other community members. If a moderator creates an inappropriate + situation, they should expect less leeway than others. -In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can drive people away from the community entirely. +In the Rust community we strive to go the extra step to look out for each other. Don't just aim to be technically +unimpeachable, try to be your best self. In particular, avoid flirting with offensive or sensitive issues, particularly +if they're off-topic; this all too often leads to unnecessary fights, hurt feelings, and damaged trust; worse, it can +drive people away from the community entirely. -And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good there was something you could've communicated better — remember that it's your responsibility to make your fellow Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their trust. +And if someone takes issue with something you said or did, resist the urge to be defensive. Just stop doing what it was +they complained about and apologize. Even if you feel you were misinterpreted or unfairly accused, chances are good +there was something you could've communicated better — remember that it's your responsibility to make your fellow +Rustaceans comfortable. Everyone wants to get along and we are all here first and foremost because we want to talk about +cool technology. You will find that people will be eager to assume good intent and forgive as long as you earn their +trust. -The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, #rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org (users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. +The enforcement policies listed above apply to all official Rust venues; including official IRC channels (#rust, +#rust-internals, #rust-tools, #rust-libs, #rustc, #rust-beginners, #rust-docs, #rust-community, #rust-lang, and #cargo); +GitHub repositories under rust-lang, rust-lang-nursery, and rust-lang-deprecated; and all forums under rust-lang.org +(users.rust-lang.org, internals.rust-lang.org). For other projects adopting the Rust Code of Conduct, please contact the +maintainers of those projects for enforcement. If you wish to use this code of conduct for your own project, consider +explicitly mentioning your moderation policy or making a copy with your own moderation policy so as to avoid confusion. -*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the [Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* +*Adapted from the [Node.js Policy on Trolling](http://blog.izs.me/post/30036893703/policy-on-trolling) as well as the +[Contributor Covenant v1.3.0](https://www.contributor-covenant.org/version/1/3/0/).* [mod_team]: https://www.rust-lang.org/team.html#Moderation-team diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4a828051185f..4d5da53e5bb7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,14 @@ Hello fellow Rustacean! Great to see your interest in compiler internals and lints! -**First**: if you're unsure or afraid of _anything_, just ask or submit the issue or pull request anyway. You won't be yelled at for giving it your best effort. The worst that can happen is that you'll be politely asked to change something. We appreciate any sort of contributions, and don't want a wall of rules to get in the way of that. +**First**: if you're unsure or afraid of _anything_, just ask or submit the issue or pull request anyway. You won't be +yelled at for giving it your best effort. The worst that can happen is that you'll be politely asked to change +something. We appreciate any sort of contributions, and don't want a wall of rules to get in the way of that. -Clippy welcomes contributions from everyone. There are many ways to contribute to Clippy and the following document explains how -you can contribute and how to get started. -If you have any questions about contributing or need help with anything, feel free to ask questions on issues or -visit the `#clippy` IRC channel on `irc.mozilla.org` or meet us in `#clippy` on [Discord](https://discord.gg/rust-lang). +Clippy welcomes contributions from everyone. There are many ways to contribute to Clippy and the following document +explains how you can contribute and how to get started. If you have any questions about contributing or need help with +anything, feel free to ask questions on issues or visit the `#clippy` IRC channel on `irc.mozilla.org` or meet us in +`#clippy` on [Discord](https://discord.gg/rust-lang). All contributors are expected to follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html). @@ -49,12 +51,12 @@ matching of the syntax tree structure, and are generally easier than [`T-middle`](https://github.com/rust-lang/rust-clippy/labels/T-middle) issues, which involve types and resolved paths. -[`T-AST`](https://github.com/rust-lang/rust-clippy/labels/T-AST) issues will generally need you to match against a predefined syntax structure. To figure out -how this syntax structure is encoded in the AST, it is recommended to run `rustc -Z ast-json` on an -example of the structure and compare with the -[nodes in the AST docs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast). Usually -the lint will end up to be a nested series of matches and ifs, -[like so](https://github.com/rust-lang/rust-clippy/blob/de5ccdfab68a5e37689f3c950ed1532ba9d652a0/src/misc.rs#L34). +[`T-AST`](https://github.com/rust-lang/rust-clippy/labels/T-AST) issues will generally need you to match against a +predefined syntax structure. To figure out how this syntax structure is encoded in the AST, it is recommended to run +`rustc -Z ast-json` on an example of the structure and compare with the [nodes in the AST +docs](https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast). Usually the lint will end up to be a nested series of +matches and ifs, [like +so](https://github.com/rust-lang/rust-clippy/blob/de5ccdfab68a5e37689f3c950ed1532ba9d652a0/src/misc.rs#L34). [`E-medium`](https://github.com/rust-lang/rust-clippy/labels/E-medium) issues are generally pretty easy too, though it's recommended you work on an E-easy issue first. They are mostly classified @@ -68,9 +70,9 @@ an AST expression). `match_def_path()` in Clippy's `utils` module can also be us ## Writing code -Have a look at the [docs for writing lints](doc/adding_lints.md) for more details. [Llogiq's blog post on lints](https://llogiq.github.io/2015/06/04/workflows.html) is also a nice primer -to lint-writing, though it does get into advanced stuff and may be a bit -outdated. +Have a look at the [docs for writing lints](doc/adding_lints.md) for more details. [Llogiq's blog post on +lints](https://llogiq.github.io/2015/06/04/workflows.html) is also a nice primer to lint-writing, though it does get +into advanced stuff and may be a bit outdated. If you want to add a new lint or change existing ones apart from bugfixing, it's also a good idea to give the [stability guarantees][rfc_stability] and @@ -79,9 +81,11 @@ quick read. ## How Clippy works -Clippy is a [rustc compiler plugin][compiler_plugin]. The main entry point is at [`src/lib.rs`][main_entry]. In there, the lint registration is delegated to the [`clippy_lints`][lint_crate] crate. +Clippy is a [rustc compiler plugin][compiler_plugin]. The main entry point is at [`src/lib.rs`][main_entry]. In there, +the lint registration is delegated to the [`clippy_lints`][lint_crate] crate. -[`clippy_lints/src/lib.rs`][lint_crate_entry] imports all the different lint modules and registers them with the rustc plugin registry. For example, the [`else_if_without_else`][else_if_without_else] lint is registered like this: +[`clippy_lints/src/lib.rs`][lint_crate_entry] imports all the different lint modules and registers them with the rustc +plugin registry. For example, the [`else_if_without_else`][else_if_without_else] lint is registered like this: ```rust // ./clippy_lints/src/lib.rs @@ -103,9 +107,12 @@ pub fn register_plugins(reg: &mut rustc_driver::plugin::Registry) { } ``` -The [`plugin::PluginRegistry`][plugin_registry] provides two methods to register lints: [register_early_lint_pass][reg_early_lint_pass] and [register_late_lint_pass][reg_late_lint_pass]. -Both take an object that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in every single lint. -It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `cargo dev update_lints` and you don't have to add anything by hand. When you are writing your own lint, you can use that script to save you some time. +The [`plugin::PluginRegistry`][plugin_registry] provides two methods to register lints: +[register_early_lint_pass][reg_early_lint_pass] and [register_late_lint_pass][reg_late_lint_pass]. Both take an object +that implements an [`EarlyLintPass`][early_lint_pass] or [`LateLintPass`][late_lint_pass] respectively. This is done in +every single lint. It's worth noting that the majority of `clippy_lints/src/lib.rs` is autogenerated by `cargo dev +update_lints` and you don't have to add anything by hand. When you are writing your own lint, you can use that script to +save you some time. ```rust // ./clippy_lints/src/else_if_without_else.rs @@ -123,18 +130,25 @@ impl EarlyLintPass for ElseIfWithoutElse { } ``` -The difference between `EarlyLintPass` and `LateLintPass` is that the methods of the `EarlyLintPass` trait only provide AST information. The methods of the `LateLintPass` trait are executed after type checking and contain type information via the `LateContext` parameter. +The difference between `EarlyLintPass` and `LateLintPass` is that the methods of the `EarlyLintPass` trait only provide +AST information. The methods of the `LateLintPass` trait are executed after type checking and contain type information +via the `LateContext` parameter. -That's why the `else_if_without_else` example uses the `register_early_lint_pass` function. Because the [actual lint logic][else_if_without_else] does not depend on any type information. +That's why the `else_if_without_else` example uses the `register_early_lint_pass` function. Because the [actual lint +logic][else_if_without_else] does not depend on any type information. ## Fixing build failures caused by Rust -Clippy will sometimes fail to build from source because building it depends on unstable internal Rust features. Most of the times we have to adapt to the changes and only very rarely there's an actual bug in Rust. Fixing build failures caused by Rust updates, can be a good way to learn about Rust internals. +Clippy will sometimes fail to build from source because building it depends on unstable internal Rust features. Most of +the times we have to adapt to the changes and only very rarely there's an actual bug in Rust. Fixing build failures +caused by Rust updates, can be a good way to learn about Rust internals. -In order to find out why Clippy does not work properly with a new Rust commit, you can use the [rust-toolstate commit history][toolstate_commit_history]. -You will then have to look for the last commit that contains `test-pass -> build-fail` or `test-pass` -> `test-fail` for the `clippy-driver` component. [Here][toolstate_commit] is an example. +In order to find out why Clippy does not work properly with a new Rust commit, you can use the [rust-toolstate commit +history][toolstate_commit_history]. You will then have to look for the last commit that contains `test-pass -> +build-fail` or `test-pass` -> `test-fail` for the `clippy-driver` component. [Here][toolstate_commit] is an example. -The commit message contains a link to the PR. The PRs are usually small enough to discover the breaking API change and if they are bigger, they likely include some discussion that may help you to fix Clippy. +The commit message contains a link to the PR. The PRs are usually small enough to discover the breaking API change and +if they are bigger, they likely include some discussion that may help you to fix Clippy. To check if Clippy is available for a specific target platform, you can check the [rustup component history][rustup_component_history]. diff --git a/README.md b/README.md index b68eb3ed7fab..000eef961c55 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ Only the following of those categories are enabled by default: Other categories need to be enabled in order for their lints to be executed. -The [lint list](https://rust-lang.github.io/rust-clippy/master/index.html) also contains "restriction lints", which are for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used very selectively, if at all. +The [lint list](https://rust-lang.github.io/rust-clippy/master/index.html) also contains "restriction lints", which are +for things which are usually not considered "bad", but may be useful to turn on in specific cases. These should be used +very selectively, if at all. Table of contents: @@ -140,15 +142,16 @@ line. (You can swap `clippy::all` with the specific lint category you are target ## Configuration -Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a basic `variable = value` mapping eg. +Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`. It contains a basic `variable = +value` mapping eg. ```toml blacklisted-names = ["toto", "tata", "titi"] cognitive-complexity-threshold = 30 ``` -See the [list of lints](https://rust-lang.github.io/rust-clippy/master/index.html) for more information about which lints can be configured and the -meaning of the variables. +See the [list of lints](https://rust-lang.github.io/rust-clippy/master/index.html) for more information about which +lints can be configured and the meaning of the variables. To deactivate the “for further information visit *lint-link*” message you can define the `CLIPPY_DISABLE_DOCS_LINKS` environment variable. @@ -169,7 +172,10 @@ You can add options to your code to `allow`/`warn`/`deny` Clippy lints: Note: `deny` produces errors instead of warnings. -If you do not want to include your lint levels in your code, you can globally enable/disable lints by passing extra flags to Clippy during the run: `cargo clippy -- -A clippy::lint_name` will run Clippy with `lint_name` disabled and `cargo clippy -- -W clippy::lint_name` will run it with that enabled. This also works with lint groups. For example you can run Clippy with warnings for all lints enabled: `cargo clippy -- -W clippy::pedantic` +If you do not want to include your lint levels in your code, you can globally enable/disable lints by passing extra +flags to Clippy during the run: `cargo clippy -- -A clippy::lint_name` will run Clippy with `lint_name` disabled and +`cargo clippy -- -W clippy::lint_name` will run it with that enabled. This also works with lint groups. For example you +can run Clippy with warnings for all lints enabled: `cargo clippy -- -W clippy::pedantic` ## Contributing diff --git a/clippy_dummy/PUBLISH.md b/clippy_dummy/PUBLISH.md index 535f11bd2ee4..8e420ec959a2 100644 --- a/clippy_dummy/PUBLISH.md +++ b/clippy_dummy/PUBLISH.md @@ -1,4 +1,6 @@ -This is a dummy crate to publish to crates.io. It primarily exists to ensure that folks trying to install clippy from crates.io get redirected to the `rustup` technique. +This is a dummy crate to publish to crates.io. It primarily exists to ensure +that folks trying to install clippy from crates.io get redirected to the +`rustup` technique. -Before publishing, be sure to rename `clippy_dummy` to `clippy` in `Cargo.toml`, it has a different name to avoid workspace issues. - \ No newline at end of file +Before publishing, be sure to rename `clippy_dummy` to `clippy` in `Cargo.toml`, +it has a different name to avoid workspace issues. diff --git a/doc/adding_lints.md b/doc/adding_lints.md index 99178c2d75b9..8c8784f0e00f 100644 --- a/doc/adding_lints.md +++ b/doc/adding_lints.md @@ -167,12 +167,12 @@ declare_clippy_lint! { ``` * The section of lines prefixed with `///` constitutes the lint documentation -section. This is the default documentation style and will be displayed at -https://rust-lang.github.io/rust-clippy/master/index.html. + section. This is the default documentation style and will be displayed at + https://rust-lang.github.io/rust-clippy/master/index.html. * `FOO_FUNCTIONS` is the name of our lint. Be sure to follow the [lint naming -guidelines][lint_naming] here when naming your lint. In short, the name should -state the thing that is being checked for and read well when used with -`allow`/`warn`/`deny`. + guidelines][lint_naming] here when naming your lint. In short, the name should + state the thing that is being checked for and read well when used with + `allow`/`warn`/`deny`. * `pedantic` sets the lint level to `Allow`. The exact mapping can be found [here][category_level_mapping] * The last part should be a text that explains what exactly is wrong with the @@ -443,7 +443,6 @@ don't hesitate to ask on Discord, IRC or in the issue/PR. [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints [category_level_mapping]: https://github.com/rust-lang/rust-clippy/blob/bd23cb89ec0ea63403a17d3fc5e50c88e38dd54f/clippy_lints/src/lib.rs#L43 [declare_clippy_lint]: https://github.com/rust-lang/rust-clippy/blob/a71acac1da7eaf667ab90a1d65d10e5cc4b80191/clippy_lints/src/lib.rs#L39 -[compilation_stages]: https://rust-lang.github.io/rustc-guide/high-level-overview.html#the-main-stages-of-compilation [check_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/lint/trait.EarlyLintPass.html#method.check_fn [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 diff --git a/etc/relicense/RELICENSE_DOCUMENTATION.md b/etc/relicense/RELICENSE_DOCUMENTATION.md index 847e66e65e35..fcd7abbf3f16 100644 --- a/etc/relicense/RELICENSE_DOCUMENTATION.md +++ b/etc/relicense/RELICENSE_DOCUMENTATION.md @@ -1,36 +1,69 @@ -This repository was previously licensed under MPL-2.0, however in #3093 ([archive](http://web.archive.org/web/20181005185227/https://github.com/rust-lang-nursery/rust-clippy/issues/3093), [screenshot](https://user-images.githubusercontent.com/1617736/46573505-5b856880-c94b-11e8-9a14-981c889b4981.png)) we relicensed it to the Rust license (dual licensed as Apache v2 / MIT) +This repository was previously licensed under MPL-2.0, however in #3093 +([archive](http://web.archive.org/web/20181005185227/https://github.com/rust-lang-nursery/rust-clippy/issues/3093), +[screenshot](https://user-images.githubusercontent.com/1617736/46573505-5b856880-c94b-11e8-9a14-981c889b4981.png)) we +relicensed it to the Rust license (dual licensed as Apache v2 / MIT) At the time, the contributors were those listed in contributors.txt. -We opened a bunch of issues asking for an explicit relicensing approval. Screenshots of all these issues at the time of relicensing are archived on GitHub. We also have saved Wayback Machine copies of these: +We opened a bunch of issues asking for an explicit relicensing approval. Screenshots of all these issues at the time of +relicensing are archived on GitHub. We also have saved Wayback Machine copies of these: - - #3094 ([archive](http://web.archive.org/web/20181005191247/https://github.com/rust-lang-nursery/rust-clippy/issues/3094), [screenshot](https://user-images.githubusercontent.com/1617736/46573506-5b856880-c94b-11e8-8a44-51cb40bc16ee.png)) - - #3095 ([archive](http://web.archive.org/web/20181005184416/https://github.com/rust-lang-nursery/rust-clippy/issues/3095), [screenshot](https://user-images.githubusercontent.com/1617736/46573507-5c1dff00-c94b-11e8-912a-4bd6b5f838f5.png)) - - #3096 ([archive](http://web.archive.org/web/20181005184802/https://github.com/rust-lang-nursery/rust-clippy/issues/3096), [screenshot](https://user-images.githubusercontent.com/1617736/46573508-5c1dff00-c94b-11e8-9425-2464f7260ff0.png)) - - #3097 ([archive](http://web.archive.org/web/20181005184821/https://github.com/rust-lang-nursery/rust-clippy/issues/3097), [screenshot](https://user-images.githubusercontent.com/1617736/46573509-5c1dff00-c94b-11e8-8ba2-53f687984fe7.png)) - - #3098 ([archive](http://web.archive.org/web/20181005184900/https://github.com/rust-lang-nursery/rust-clippy/issues/3098), [screenshot](https://user-images.githubusercontent.com/1617736/46573510-5c1dff00-c94b-11e8-8f64-371698401c60.png)) - - #3099 ([archive](http://web.archive.org/web/20181005184901/https://github.com/rust-lang-nursery/rust-clippy/issues/3099), [screenshot](https://user-images.githubusercontent.com/1617736/46573511-5c1dff00-c94b-11e8-8e20-7d0eeb392b95.png)) - - #3100 ([archive](http://web.archive.org/web/20181005184901/https://github.com/rust-lang-nursery/rust-clippy/issues/3100), [screenshot](https://user-images.githubusercontent.com/1617736/46573512-5c1dff00-c94b-11e8-8a13-7d758ed3563d.png)) - - #3230 ([archive](http://web.archive.org/web/20181005184903/https://github.com/rust-lang-nursery/rust-clippy/issues/3230), [screenshot](https://user-images.githubusercontent.com/1617736/46573513-5cb69580-c94b-11e8-86b1-14ce82741e5c.png)) +- #3094 + ([archive](http://web.archive.org/web/20181005191247/https://github.com/rust-lang-nursery/rust-clippy/issues/3094), + [screenshot](https://user-images.githubusercontent.com/1617736/46573506-5b856880-c94b-11e8-8a44-51cb40bc16ee.png)) +- #3095 + ([archive](http://web.archive.org/web/20181005184416/https://github.com/rust-lang-nursery/rust-clippy/issues/3095), + [screenshot](https://user-images.githubusercontent.com/1617736/46573507-5c1dff00-c94b-11e8-912a-4bd6b5f838f5.png)) +- #3096 + ([archive](http://web.archive.org/web/20181005184802/https://github.com/rust-lang-nursery/rust-clippy/issues/3096), + [screenshot](https://user-images.githubusercontent.com/1617736/46573508-5c1dff00-c94b-11e8-9425-2464f7260ff0.png)) +- #3097 + ([archive](http://web.archive.org/web/20181005184821/https://github.com/rust-lang-nursery/rust-clippy/issues/3097), + [screenshot](https://user-images.githubusercontent.com/1617736/46573509-5c1dff00-c94b-11e8-8ba2-53f687984fe7.png)) +- #3098 + ([archive](http://web.archive.org/web/20181005184900/https://github.com/rust-lang-nursery/rust-clippy/issues/3098), + [screenshot](https://user-images.githubusercontent.com/1617736/46573510-5c1dff00-c94b-11e8-8f64-371698401c60.png)) +- #3099 + ([archive](http://web.archive.org/web/20181005184901/https://github.com/rust-lang-nursery/rust-clippy/issues/3099), + [screenshot](https://user-images.githubusercontent.com/1617736/46573511-5c1dff00-c94b-11e8-8e20-7d0eeb392b95.png)) +- #3100 + ([archive](http://web.archive.org/web/20181005184901/https://github.com/rust-lang-nursery/rust-clippy/issues/3100), + [screenshot](https://user-images.githubusercontent.com/1617736/46573512-5c1dff00-c94b-11e8-8a13-7d758ed3563d.png)) +- #3230 + ([archive](http://web.archive.org/web/20181005184903/https://github.com/rust-lang-nursery/rust-clippy/issues/3230), + [screenshot](https://user-images.githubusercontent.com/1617736/46573513-5cb69580-c94b-11e8-86b1-14ce82741e5c.png)) The usernames of commenters on these issues can be found in relicense_comments.txt There are a couple people in relicense_comments.txt who are not found in contributors.txt: - - @EpocSquadron has [made minor text contributions to the README](https://github.com/rust-lang/rust-clippy/commits?author=EpocSquadron) which have since been overwritten, and doesn't count - - @JayKickliter [agreed to the relicense on their pull request](https://github.com/rust-lang/rust-clippy/pull/3195#issuecomment-423781016) ([archive](https://web.archive.org/web/20181005190730/https://github.com/rust-lang/rust-clippy/pull/3195), [screenshot](https://user-images.githubusercontent.com/1617736/46573514-5cb69580-c94b-11e8-8ffb-05a5bd02e2cc.png) -) - - @sanmai-NL's [contribution](https://github.com/rust-lang/rust-clippy/commits?author=sanmai-NL) is a minor one-word addition which doesn't count for copyright assignment - - @zmt00's [contributions](https://github.com/rust-lang/rust-clippy/commits?author=zmt00) are minor typo fixes and don't count - - @VKlayd has [nonminor contributions](https://github.com/rust-lang/rust-clippy/commits?author=VKlayd) which we rewrote (see below) - - @wartman4404 has [nonminor contributions](https://github.com/rust-lang/rust-clippy/commits?author=wartman4404) which we rewrote (see below) +- @EpocSquadron has [made minor text contributions to the + README](https://github.com/rust-lang/rust-clippy/commits?author=EpocSquadron) which have since been overwritten, and + doesn't count +- @JayKickliter [agreed to the relicense on their pull + request](https://github.com/rust-lang/rust-clippy/pull/3195#issuecomment-423781016) + ([archive](https://web.archive.org/web/20181005190730/https://github.com/rust-lang/rust-clippy/pull/3195), + [screenshot](https://user-images.githubusercontent.com/1617736/46573514-5cb69580-c94b-11e8-8ffb-05a5bd02e2cc.png) +- @sanmai-NL's [contribution](https://github.com/rust-lang/rust-clippy/commits?author=sanmai-NL) is a minor one-word + addition which doesn't count for copyright assignment +- @zmt00's [contributions](https://github.com/rust-lang/rust-clippy/commits?author=zmt00) are minor typo fixes and don't + count +- @VKlayd has [nonminor contributions](https://github.com/rust-lang/rust-clippy/commits?author=VKlayd) which we rewrote + (see below) +- @wartman4404 has [nonminor contributions](https://github.com/rust-lang/rust-clippy/commits?author=wartman4404) which + we rewrote (see below) -Two of these contributors had nonminor contributions (#2184, #427) requiring a rewrite, carried out in #3251 ([archive](http://web.archive.org/web/20181005192411/https://github.com/rust-lang-nursery/rust-clippy/pull/3251), [screenshot](https://user-images.githubusercontent.com/1617736/46573515-5cb69580-c94b-11e8-86e5-b456452121b2.png) -) -First, I (Manishearth) removed the lints they had added. I then documented at a high level what the lints did in #3251, asking for co-maintainers who had not seen the code for the lints to rewrite them. #2814 was rewritten by @phansch, and #427 was rewritten by @oli-obk, who did not recall having previously seen the code they were rewriting. +Two of these contributors had nonminor contributions (#2184, #427) requiring a rewrite, carried out in #3251 +([archive](http://web.archive.org/web/20181005192411/https://github.com/rust-lang-nursery/rust-clippy/pull/3251), +[screenshot](https://user-images.githubusercontent.com/1617736/46573515-5cb69580-c94b-11e8-86e5-b456452121b2.png)) + +First, I (Manishearth) removed the lints they had added. I then documented at a high level what the lints did in #3251, +asking for co-maintainers who had not seen the code for the lints to rewrite them. #2814 was rewritten by @phansch, and +#427 was rewritten by @oli-obk, who did not recall having previously seen the code they were rewriting. ------ -Since this document was written, @JayKickliter and @sanmai-ML added their consent in #3230 ([archive](http://web.archive.org/web/20181006171926/https://github.com/rust-lang-nursery/rust-clippy/issues/3230)) +Since this document was written, @JayKickliter and @sanmai-ML added their consent in #3230 +([archive](http://web.archive.org/web/20181006171926/https://github.com/rust-lang-nursery/rust-clippy/issues/3230)) From 29c1eaebbf532b27073420d3be90710c451e7799 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 18:43:57 +0100 Subject: [PATCH 06/25] Add Clippy Test (bors) to GHA --- .github/workflows/clippy_bors.yml | 146 ++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 .github/workflows/clippy_bors.yml diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml new file mode 100644 index 000000000000..6a6d58410f95 --- /dev/null +++ b/.github/workflows/clippy_bors.yml @@ -0,0 +1,146 @@ +name: Clippy Test (bors) + +on: + push: + branches: [auto, try] + # Don't run Clippy tests, when only textfiles were modified + paths-ignore: + - 'COPYRIGHT' + - 'LICENSE-*' + - '**.md' + - '**.txt' + +env: + RUST_BACKTRACE: 1 + CARGO_TARGET_DIR: '${{ github.workspace }}/target' + GHA_CI: 1 + +jobs: + base: + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + host: [x86_64-unknown-linux-gnu, i686-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc] + exclude: + - os: ubuntu-latest + host: x86_64-apple-darwin + - os: ubuntu-latest + host: x86_64-pc-windows-msvc + - os: macos-latest + host: x86_64-unknown-linux-gnu + - os: macos-latest + host: i686-unknown-linux-gnu + - os: macos-latest + host: x86_64-pc-windows-msvc + - os: windows-latest + host: x86_64-unknown-linux-gnu + - os: windows-latest + host: i686-unknown-linux-gnu + - os: windows-latest + host: x86_64-apple-darwin + + runs-on: ${{ matrix.os }} + + steps: + - name: Install dependencies (Linux-i686) + run: | + sudo dpkg --add-architecture i386 + sudo apt-get update + sudo apt-get install gcc-multilib libssl-dev:i386 libgit2-dev:i386 + if: matrix.host == 'i686-unknown-linux-gnu' + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: ${{ matrix.host }} + profile: minimal + - name: Cache cargo dir + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-${{ matrix.host }} + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Master Toolchain Setup + run: bash setup-toolchain.sh + env: + HOST_TOOLCHAIN: ${{ matrix.host }} + shell: bash + + - name: Set LD_LIBRARY_PATH (Linux) + if: runner.os == 'Linux' + run: | + SYSROOT=$(rustc --print sysroot) + echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" + - name: Link rustc dylib (MacOS) + if: runner.os == 'macOS' + run: | + SYSROOT=$(rustc --print sysroot) + sudo mkdir -p /usr/local/lib + sudo find "${SYSROOT}/lib" -maxdepth 1 -name '*dylib' -exec ln -s {} /usr/local/lib \; + - name: Set PATH (Windows) + if: runner.os == 'Windows' + run: | + $sysroot = rustc --print sysroot + $env:PATH += ';' + $sysroot + '\bin' + echo "::set-env name=PATH::$env:PATH" + - name: Build + run: cargo build --features deny-warnings + shell: bash + - name: Test + run: cargo test --features deny-warnings + shell: bash + - name: Test clippy_lints + run: cargo test --features deny-warnings + shell: bash + working-directory: clippy_lints + - name: Test rustc_tools_util + run: cargo test --features deny-warnings + shell: bash + working-directory: rustc_tools_util + - name: Test clippy_dev + run: cargo test --features deny-warnings + shell: bash + working-directory: clippy_dev + - name: Test cargo-clippy + run: ../target/debug/cargo-clippy + shell: bash + working-directory: clippy_workspace_tests + - name: Test clippy-driver + run: | + ( + set -ex + # Check sysroot handling + sysroot=$(./target/debug/clippy-driver --print sysroot) + test "$sysroot" = "$(rustc --print sysroot)" + + if [[ ${{ runner.os }} == "Windows" ]]; then + desired_sysroot=C:/tmp + else + desired_sysroot=/tmp + fi + sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) + test "$sysroot" = $desired_sysroot + + sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) + test "$sysroot" = $desired_sysroot + + # Make sure this isn't set - clippy-driver should cope without it + unset CARGO_MANIFEST_DIR + + # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 + # FIXME: How to match the clippy invocation in compile-test.rs? + ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 + sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr + diff normalized.stderr tests/ui/cstring.stderr + + # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR + ) + shell: bash + + - name: Run cargo-cache --autoclean + run: | + cargo install cargo-cache --debug + /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \; + cargo cache --autoclean + shell: bash From afe1ef270e0f05fa325a235e89b9a51ecea30c83 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 18:44:30 +0100 Subject: [PATCH 07/25] Ignore fmt test in GHA CI This is already checked by clippy_dev.yml GHA --- tests/fmt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fmt.rs b/tests/fmt.rs index 2e33c3ed5e5b..e2675fa09683 100644 --- a/tests/fmt.rs +++ b/tests/fmt.rs @@ -3,7 +3,7 @@ use std::process::Command; #[test] fn fmt() { - if option_env!("RUSTC_TEST_SUITE").is_some() { + if option_env!("RUSTC_TEST_SUITE").is_some() || option_env!("GHA_CI").is_some() { return; } From 9765f5c52b37d8b3c843829ca4b3ec908e0d3c7b Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 21 Jan 2020 21:40:40 +0100 Subject: [PATCH 08/25] Check if changelog exists --- .github/workflows/clippy_bors.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 6a6d58410f95..2267b46f9fc1 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -16,7 +16,30 @@ env: GHA_CI: 1 jobs: + changelog: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + with: + ref: ${{ github.ref }} + - name: Check Changelog + run: | + MESSAGE=$(git log --format=%B -n 1) + PR=$(echo "$MESSAGE" | grep -o "#[0-9]*" | head -1 | sed -e 's/^#//') + output=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \ + python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ + grep "^changelog: " | \ + sed "s/changelog: //g") + if [[ -z "$output" ]]; then + echo "ERROR: PR body must contain 'changelog: ...'" + exit 1 + elif [[ "$output" = "none" ]]; then + echo "WARNING: changelog is 'none'" + fi base: + needs: changelog strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] From 22fe18df9a4524652a47a3d8c27834096a8c6e26 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 22 Jan 2020 14:56:08 +0100 Subject: [PATCH 09/25] Get {RUSTUP,MULTIRUST}_{HOME,TOOLCHAIN} from runtime environment Keep the fallback to compile-time environment --- src/driver.rs | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 27ff7fa9116e..f6c2411ee5b1 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -281,6 +281,17 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) { } } +fn toolchain_path(home: Option, toolchain: Option) -> Option { + home.and_then(|home| { + toolchain.map(|toolchain| { + let mut path = PathBuf::from(home); + path.push("toolchains"); + path.push(toolchain); + path + }) + }) +} + pub fn main() { rustc_driver::init_rustc_env_logger(); lazy_static::initialize(&ICE_HOOK); @@ -301,22 +312,21 @@ pub fn main() { // - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN // - sysroot from rustc in the path // - compile-time environment + // - SYSROOT + // - RUSTUP_HOME, MULTIRUST_HOME, RUSTUP_TOOLCHAIN, MULTIRUST_TOOLCHAIN let sys_root_arg = arg_value(&orig_args, "--sysroot", |_| true); let have_sys_root_arg = sys_root_arg.is_some(); let sys_root = sys_root_arg .map(PathBuf::from) .or_else(|| std::env::var("SYSROOT").ok().map(PathBuf::from)) .or_else(|| { - let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME")); - let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN")); - home.and_then(|home| { - toolchain.map(|toolchain| { - let mut path = PathBuf::from(home); - path.push("toolchains"); - path.push(toolchain); - path - }) - }) + let home = std::env::var("RUSTUP_HOME") + .or_else(|_| std::env::var("MULTIRUST_HOME")) + .ok(); + let toolchain = std::env::var("RUSTUP_TOOLCHAIN") + .or_else(|_| std::env::var("MULTIRUST_TOOLCHAIN")) + .ok(); + toolchain_path(home, toolchain) }) .or_else(|| { Command::new("rustc") @@ -328,6 +338,15 @@ pub fn main() { .map(|s| PathBuf::from(s.trim())) }) .or_else(|| option_env!("SYSROOT").map(PathBuf::from)) + .or_else(|| { + let home = option_env!("RUSTUP_HOME") + .or(option_env!("MULTIRUST_HOME")) + .map(ToString::to_string); + let toolchain = option_env!("RUSTUP_TOOLCHAIN") + .or(option_env!("MULTIRUST_TOOLCHAIN")) + .map(ToString::to_string); + toolchain_path(home, toolchain) + }) .map(|pb| pb.to_string_lossy().to_string()) .expect("need to specify SYSROOT env var during clippy compilation, or use rustup or multirust"); From 2dd6c532a6ef0612fa36292230f6cf557ac16a57 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 22 Jan 2020 17:06:13 +0100 Subject: [PATCH 10/25] Add Clippy Test to GHA --- .github/workflows/clippy.yml | 98 ++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .github/workflows/clippy.yml diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 000000000000..ae1148e96cb9 --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,98 @@ +name: Clippy Test + +on: + push: + # Ignore bors branches, since they are covered by `clippy_bors.yml` + branches-ignore: [auto, try] + # Don't run Clippy tests, when only textfiles were modified + paths-ignore: + - 'COPYRIGHT' + - 'LICENSE-*' + - '**.md' + - '**.txt' + pull_request: + # Don't run Clippy tests, when only textfiles were modified + paths-ignore: + - 'COPYRIGHT' + - 'LICENSE-*' + - '**.md' + - '**.txt' + +env: + RUST_BACKTRACE: 1 + CARGO_TARGET_DIR: '${{ github.workspace }}/target' + GHA_CI: 1 + +jobs: + base: + runs-on: ubuntu-latest + + steps: + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: x86_64-unknown-linux-gnu + profile: minimal + - name: Cache cargo dir + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-x86_64-unknown-linux-gnu + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Master Toolchain Setup + run: bash setup-toolchain.sh + + - name: Set LD_LIBRARY_PATH (Linux) + run: | + SYSROOT=$(rustc --print sysroot) + echo "::set-env name=LD_LIBRARY_PATH::${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" + - name: Build + run: cargo build --features deny-warnings + - name: Test + run: cargo test --features deny-warnings + - name: Test clippy_lints + run: cargo test --features deny-warnings + working-directory: clippy_lints + - name: Test rustc_tools_util + run: cargo test --features deny-warnings + working-directory: rustc_tools_util + - name: Test clippy_dev + run: cargo test --features deny-warnings + working-directory: clippy_dev + - name: Test cargo-clippy + run: ../target/debug/cargo-clippy + working-directory: clippy_workspace_tests + - name: Test clippy-driver + run: | + ( + set -ex + # Check sysroot handling + sysroot=$(./target/debug/clippy-driver --print sysroot) + test "$sysroot" = "$(rustc --print sysroot)" + + desired_sysroot=/tmp + sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) + test "$sysroot" = $desired_sysroot + + sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) + test "$sysroot" = $desired_sysroot + + # Make sure this isn't set - clippy-driver should cope without it + unset CARGO_MANIFEST_DIR + + # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 + # FIXME: How to match the clippy invocation in compile-test.rs? + ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 + sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr + diff normalized.stderr tests/ui/cstring.stderr + + # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR + ) + + - name: Run cargo-cache --autoclean + run: | + cargo install cargo-cache --debug + find ~/.cargo/bin ! -type d -exec strip {} \; + cargo cache --autoclean From 7baf7de017fb204333498688325b61ccba69eabb Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 22 Jan 2020 20:00:41 +0100 Subject: [PATCH 11/25] Move integration tests in clippy_bors.yml Some call it the integration integration --- .github/workflows/clippy_bors.yml | 55 +++++++++++++++++++++++- .github/workflows/integration.yml | 69 ------------------------------- 2 files changed, 54 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/integration.yml diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 2267b46f9fc1..423fdb9c3da6 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -3,7 +3,7 @@ name: Clippy Test (bors) on: push: branches: [auto, try] - # Don't run Clippy tests, when only textfiles were modified + # Don't run tests, when only textfiles were modified paths-ignore: - 'COPYRIGHT' - 'LICENSE-*' @@ -167,3 +167,56 @@ jobs: /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \; cargo cache --autoclean shell: bash + integration: + needs: changelog + strategy: + fail-fast: false + matrix: + integration: + - 'rust-lang/rls' + - 'rust-lang/cargo' + - 'rust-lang/chalk' + - 'Geal/nom' + - 'rust-lang/rustfmt' + - 'hyperium/hyper' + - 'rust-itertools/itertools' + - 'serde-rs/serde' + - 'rust-lang/stdarch' + - 'rust-random/rand' + - 'rust-lang/futures-rs' + - 'Marwes/combine' + - 'rust-lang-nursery/failure' + - 'rust-lang/log' + - 'chronotope/chrono' + + runs-on: ubuntu-latest + + steps: + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: x86_64-unknown-linux-gnu + profile: minimal + - name: Cache cargo dir + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-x86_64-unknown-linux-gnu + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Master Toolchain Setup + run: bash setup-toolchain.sh + + - name: Build + run: cargo build --features integration + - name: Test ${{ matrix.integration }} + run: cargo test --test integration --features integration + env: + INTEGRATION: ${{ matrix.integration }} + + - name: Run cargo-cache --autoclean + run: | + cargo install cargo-cache --debug + find ~/.cargo/bin ! -type d -exec strip {} \; + cargo cache --autoclean diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml deleted file mode 100644 index fc05ee9b9210..000000000000 --- a/.github/workflows/integration.yml +++ /dev/null @@ -1,69 +0,0 @@ -name: Integration - -on: - push: - branches: - - auto - - try - # Don't run integration tests, when only textfiles were modified - paths-ignore: - - 'COPYRIGHT' - - 'LICENSE-*' - - '**.md' - - '**.txt' - -env: - RUST_BACKTRACE: 1 - -jobs: - integration: - strategy: - fail-fast: false - matrix: - integration: - - 'rust-lang/rls' - - 'rust-lang/cargo' - - 'rust-lang/chalk' - - 'Geal/nom' - - 'rust-lang/rustfmt' - - 'hyperium/hyper' - - 'rust-itertools/itertools' - - 'serde-rs/serde' - - 'rust-lang/stdarch' - - 'rust-random/rand' - - 'rust-lang/futures-rs' - - 'Marwes/combine' - - 'rust-lang-nursery/failure' - - 'rust-lang/log' - - 'chronotope/chrono' - runs-on: ubuntu-latest - - steps: - - name: rust-toolchain - uses: actions-rs/toolchain@v1.0.3 - with: - toolchain: nightly - target: x86_64-unknown-linux-gnu - profile: minimal - - name: Cache cargo dir - uses: actions/cache@v1 - with: - path: ~/.cargo - key: ${{ runner.os }}-x86_64-unknown-linux-gnu - - name: Checkout - uses: actions/checkout@v2.0.0 - - name: Master Toolchain Setup - run: bash setup-toolchain.sh - - - name: Build - run: cargo build --features integration - - name: Test ${{ matrix.integration }} - run: cargo test --test integration --features integration - env: - INTEGRATION: ${{ matrix.integration }} - - - name: Run cargo-cache --autoclean - run: | - cargo install cargo-cache --debug - find ~/.cargo/bin ! -type d -exec strip {} \; - cargo cache --autoclean From 462503f30f2e5aca39ece6246a886dc252a4af50 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Wed, 22 Jan 2020 21:00:31 +0100 Subject: [PATCH 12/25] Add deployment to GHA --- .github/workflows/deploy.yml | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000000..100adbadd5ab --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,72 @@ +name: Deploy + +on: + push: + branches: master + release: + types: [created] + +env: + TARGET_BRANCH: 'gh-pages' + SHA: '${{ github.sha }}' + SSH_REPO: 'git@github.com:${{ github.repository }}.git' + TAG_NAME: '${{ github.event.release.GITHUB_REF }}' + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Checkout + uses: actions/checkout@v2.0.0 + with: + ref: ${{ env.TARGET_BRANCH }} + path: 'out' + - name: Deploy + run: | + set -ex + + echo "Removing the current docs for master" + rm -rf out/master/ || exit 0 + + echo "Making the docs for master" + mkdir out/master/ + cp util/gh-pages/index.html out/master + python ./util/export.py out/master/lints.json + + if [[ -n $TAG_NAME ]]; then + echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it" + cp -r out/master "out/$TAG_NAME" + rm -f out/current + ln -s "$TAG_NAME" out/current + fi + + # Generate version index that is shown as root index page + cp util/gh-pages/versions.html out/index.html + + cd out + cat <<-EOF | python - > versions.json + import os, json + print json.dumps([ + dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir) + ]) + EOF + + # Now let's go have some fun with the cloned repo + git config user.name "GHA CI" + git config user.email "gha@ci.invalid" + + if git diff --exit-code --quiet; then + echo "No changes to the output on this push; exiting." + exit 0 + fi + + git add . + git commit -m "Automatic deploy to GitHub Pages: ${SHA}" + + eval "$(ssh-agent -s)" + ssh-add - <<< "${{ secrets.DEPLOY_KEY }}" + + git push "$SSH_REPO" "$TARGET_BRANCH" From 9a4b937c130943e837c68edeb0dea075a5478ed5 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 10:36:51 +0100 Subject: [PATCH 13/25] Cleanup --- .gitignore | 2 +- tests/compile-test.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f1f4fa4e242a..adf5e8feddf4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Used by Travis to be able to push: +# Used by CI to be able to push: /.github/deploy_key out diff --git a/tests/compile-test.rs b/tests/compile-test.rs index 5c05e74dcb6d..866777734337 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -88,7 +88,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { config.mode = cfg_mode; config.build_base = if rustc_test_suite().is_some() { - // we don't need access to the stderr files on travis + // we don't need access to the stderr files on CI let mut path = PathBuf::from(env!("OUT_DIR")); path.push("test_build_base"); path From e767ffa588239f37478c8ba5db108678fe0175e8 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 10:22:02 +0100 Subject: [PATCH 14/25] Add GHA badge to README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 000eef961c55..685f75c6fdee 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![Build Status](https://travis-ci.com/rust-lang/rust-clippy.svg?branch=master)](https://travis-ci.com/rust-lang/rust-clippy) [![Windows Build status](https://ci.appveyor.com/api/projects/status/id677xpw1dguo7iw?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/rust-clippy) +[![Build Status](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg)](https://github.com/rust-lang/rust-clippy/actions) [![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license) A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code. From 54e22864166c2595a4427f47015900cff39b0b57 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 14:40:37 +0100 Subject: [PATCH 15/25] Cancle builds on new commits --- .github/workflows/clippy.yml | 3 +++ .github/workflows/clippy_bors.yml | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index ae1148e96cb9..7997344aabd0 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -28,6 +28,9 @@ jobs: runs-on: ubuntu-latest steps: + - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master + with: + github_token: "${{ secrets.github_token }}" - name: rust-toolchain uses: actions-rs/toolchain@v1.0.3 with: diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 423fdb9c3da6..83b6f44f2ec9 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -20,6 +20,9 @@ jobs: runs-on: ubuntu-latest steps: + - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master + with: + github_token: "${{ secrets.github_token }}" - name: Checkout uses: actions/checkout@v2.0.0 with: @@ -65,6 +68,9 @@ jobs: runs-on: ${{ matrix.os }} steps: + - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master + with: + github_token: "${{ secrets.github_token }}" - name: Install dependencies (Linux-i686) run: | sudo dpkg --add-architecture i386 @@ -192,6 +198,9 @@ jobs: runs-on: ubuntu-latest steps: + - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master + with: + github_token: "${{ secrets.github_token }}" - name: rust-toolchain uses: actions-rs/toolchain@v1.0.3 with: From 9af59c02e7cf0445684f4942b723844e11789aba Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 15:47:11 +0100 Subject: [PATCH 16/25] Limit parallel jobs on try/r+ runs Rate limit of 60 applies org wide, let's not spam. Thanks pietroalbini for the hint --- .github/workflows/clippy_bors.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 83b6f44f2ec9..c559de330ab0 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -177,23 +177,24 @@ jobs: needs: changelog strategy: fail-fast: false + max-parallel: 6 matrix: integration: - - 'rust-lang/rls' - 'rust-lang/cargo' + - 'rust-lang/rls' - 'rust-lang/chalk' - - 'Geal/nom' - 'rust-lang/rustfmt' - - 'hyperium/hyper' - - 'rust-itertools/itertools' - - 'serde-rs/serde' + - 'Marwes/combine' + - 'Geal/nom' - 'rust-lang/stdarch' + - 'serde-rs/serde' + - 'hyperium/hyper' - 'rust-random/rand' - 'rust-lang/futures-rs' - - 'Marwes/combine' + - 'chronotope/chrono' + - 'rust-itertools/itertools' - 'rust-lang-nursery/failure' - 'rust-lang/log' - - 'chronotope/chrono' runs-on: ubuntu-latest From 4b804943e329d96df91f64d5c09c1c3e567a2a50 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 24 Jan 2020 14:34:25 +0100 Subject: [PATCH 17/25] Sort output of export.py script --- util/export.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/export.py b/util/export.py index e8fc4d84ea4f..5d1bd60acf3d 100755 --- a/util/export.py +++ b/util/export.py @@ -71,7 +71,9 @@ def main(): outfile = sys.argv[1] if len(sys.argv) > 1 else "util/gh-pages/lints.json" with open(outfile, "w") as fp: - json.dump(list(lints.values()), fp, indent=2) + lints = list(lints.values()) + lints.sort(key=lambda x: x['id']) + json.dump(lints, fp, indent=2) log.info("wrote JSON for great justice") From e9fff12b54af64e7e78303da8f01bedcd85e2ce7 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 10:21:13 +0100 Subject: [PATCH 18/25] [WIP] Remove Travis+AppVeyor badges --- Cargo.toml | 4 ---- README.md | 2 -- 2 files changed, 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 84b96a329140..4999928b2d54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,10 +18,6 @@ build = "build.rs" edition = "2018" publish = false -[badges] -travis-ci = { repository = "rust-lang/rust-clippy" } -appveyor = { repository = "rust-lang/rust-clippy" } - [[bin]] name = "cargo-clippy" test = false diff --git a/README.md b/README.md index 685f75c6fdee..482073ea1671 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Clippy -[![Build Status](https://travis-ci.com/rust-lang/rust-clippy.svg?branch=master)](https://travis-ci.com/rust-lang/rust-clippy) -[![Windows Build status](https://ci.appveyor.com/api/projects/status/id677xpw1dguo7iw?svg=true)](https://ci.appveyor.com/project/rust-lang-libs/rust-clippy) [![Build Status](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test/badge.svg)](https://github.com/rust-lang/rust-clippy/actions) [![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license) From 4ad2ca0da41452b9c5045a9739e70d364ae14a06 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 23 Jan 2020 10:26:00 +0100 Subject: [PATCH 19/25] [WIP] Remove old CI files --- .github/deploy.sh | 81 -------------------- .github/deploy_key.enc | Bin 1680 -> 0 bytes .travis.yml | 166 ----------------------------------------- appveyor.yml | 34 +-------- ci/base-tests.sh | 55 -------------- 5 files changed, 2 insertions(+), 334 deletions(-) delete mode 100755 .github/deploy.sh delete mode 100644 .github/deploy_key.enc delete mode 100644 .travis.yml delete mode 100755 ci/base-tests.sh diff --git a/.github/deploy.sh b/.github/deploy.sh deleted file mode 100755 index 19dc4017166c..000000000000 --- a/.github/deploy.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -# Automatically deploy on gh-pages - -set -ex - -SOURCE_BRANCH="master" -TARGET_BRANCH="gh-pages" - -# Save some useful information -REPO=$(git config remote.origin.url) -SSH_REPO=${REPO/https:\/\/github.com\//git@github.com:} -SHA=$(git rev-parse --verify HEAD) - -# Clone the existing gh-pages for this repo into out/ -git clone --quiet --single-branch --branch "$TARGET_BRANCH" "$REPO" out - -echo "Removing the current docs for master" -rm -rf out/master/ || exit 0 - -echo "Making the docs for master" -mkdir out/master/ -cp util/gh-pages/index.html out/master -python ./util/export.py out/master/lints.json - -if [[ -n "$TRAVIS_TAG" ]]; then - echo "Save the doc for the current tag ($TRAVIS_TAG) and point current/ to it" - cp -r out/master "out/$TRAVIS_TAG" - rm -f out/current - ln -s "$TRAVIS_TAG" out/current -fi - -# Generate version index that is shown as root index page -cp util/gh-pages/versions.html out/index.html -pushd out - -cat <<-EOF | python - > versions.json -import os, json -print json.dumps([ - dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir) -]) -EOF -popd - -# Pull requests and commits to other branches shouldn't try to deploy, just build to verify -if [[ "$TRAVIS_PULL_REQUEST" != "false" ]] || [[ "$TRAVIS_BRANCH" != "$SOURCE_BRANCH" ]]; then - # Tags should deploy - if [[ -z "$TRAVIS_TAG" ]]; then - echo "Generated, won't push" - exit 0 - fi -fi - -# Now let's go have some fun with the cloned repo -cd out -git config user.name "Travis CI" -git config user.email "travis@ci.invalid" - -if git diff --exit-code --quiet; then - echo "No changes to the output on this push; exiting." - exit 0 -fi -cd - - -# Get the deploy key by using Travis's stored variables to decrypt deploy_key.enc -ENCRYPTION_LABEL=e3a2d77100be -ENCRYPTED_KEY_VAR="encrypted_${ENCRYPTION_LABEL}_key" -ENCRYPTED_IV_VAR="encrypted_${ENCRYPTION_LABEL}_iv" -ENCRYPTED_KEY=${!ENCRYPTED_KEY_VAR} -ENCRYPTED_IV=${!ENCRYPTED_IV_VAR} -openssl aes-256-cbc -K "$ENCRYPTED_KEY" -iv "$ENCRYPTED_IV" -in .github/deploy_key.enc -out .github/deploy_key -d -chmod 600 .github/deploy_key -eval "$(ssh-agent -s)" -ssh-add .github/deploy_key - -cd out -git add . -git commit -m "Automatic deploy to GitHub Pages: ${SHA}" - -# Now that we're all set up, we can push. -git push "$SSH_REPO" "$TARGET_BRANCH" diff --git a/.github/deploy_key.enc b/.github/deploy_key.enc deleted file mode 100644 index 48cb3f5a1276dfdacef1d54cecd1ded0911738a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1680 zcmV;B25vF7u9N_L=w*TIYn1;MzUesW5ej2=oot?d>%{ zy=pH1(l$5zhk3TM$4_n%!q&1t*9w&T&t=Or-GHPK7bN}_feZhHHdR&H%g~fu8 z*f}0Udo-cU!f_}8=ay!LF^mdI-0d?3(@?B;SSW!+ZL5c1PDks2hcD%mUhf*AEOX!_ zOU@QB+)7ilyfBZ@cukZ)uLi1?TTviJa`BQYlNl6Da9f2!Pf__3o}Qy4{g+q6JG{|X z+A#u1gC(!>8kL`2OyiC4;APXVtcaHcyi!y#2EUg}LC-1QuNf2M$VV_Qpc>Ayfw7C# zISG~sUT6PTwLQn+MX8?=|y&G%V&|B`{XdC$vN{4|BAg7kQMQGf;rb+Pm`@V z^b+_}7%S_}=u!yQ{Nf|AGIWo=L@GlBv_z@Z+0SxYr>ha8hBE1?2hZ zUKy{$<<@oNXK5pO9&73B(mCVj6wakA2nQn?yqa9+MU;Dxzg%SciEkCP9zKm=*>ds% zn*2Sa4Xd4N-sF8rai#Y0TX*W|J0jZiv1SiSR~c?_-YTNA{J&;RU23E_>b?*pTJy*7 z>PCKgIytqqVbithll=TrYGbq4%|TM)1w&y@zRzrz%31DkcGw8X$|ww4cS-pp0oNbN z?;|O#9hZ*?6N~+667GvUz4+`r(Wthq`*j5|J$Trypc_ZabAI<>%S!^^sXHDK{DJI1 zlTb(%P1I=Ol}!hRe7KTcreEM$M>2e#CTt4_hu(5k?iEDE`md3E@^BjY&f5(%Cxu(0 z(=jt`&cM9Tx2^zK-vOHed{#^*O>CBZ|0G#Qw6kF>xYN-)CJ7>+HUoS~ zS}JCM8U8<9+~9-jPUAT<`@anfUP*q7T@Kak`g)q#G?;0fRCz6R3uU!^+a&NzZU@ig z!jg?*@Q~Q|^9fB6L{znl`E+2BVZp90UUcdb(J&U~TjmLd)d{0jn!;B*el6~m3Oj?7 zsyeBGF=A;5d9NJMt1n{&+LBBHH)B-7(+PBjowmB09RR<;{~;1bC%e*r$DS|-z2;En z@aL4dJw8CVYaj-V*!^Xddy?8T#+va<*+eJFGKJ5)80i*w+0^727+sFl#;k zp75P8*|UXDP9s@lStLfJ>?pk{=C%zFCgBqq(BB8f&pyzGDLapcLTE$W>)Xm1c+=Ga zXWh0Z##ii8_0#-OOrb&6%CB-Z+`$$*AXOyUcSuzN&vPYOEbeWtwY6X_bUtNd5s&e! zR8I+m7eWFHJ>bgUka?fw1AD-xAbKYNVBOXwR^@-sTNf*2f-yl>LkwLrC+< ztT-MogUA9+gjY&w6#fDTb?NjUx9O2_g3;QOC_9z-C5)`}qGa*PConYj9K_^4)XjbW z{(BKxnQj9py|JC4q>z!`t>f_GPTFf^LK$c5x4^>`gLX+j(&LbA927@TPjlF-HRKWQY0!(*fj-a`OQ@%|218fm aw@mexo81x=`|RI})%;EfbOs3kDMvfxY($g* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index bd3003d45977..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,166 +0,0 @@ -dist: xenial -language: bash -git: - depth: 1 - quiet: true - -branches: - # Don't build these branches - except: - # Used by bors - - trying.tmp - - staging.tmp - -cache: - directories: - - $HOME/.cargo -before_cache: - - cargo install cargo-cache --debug - - find $HOME/.cargo/bin/ ! -type d -exec strip {} \; - - cargo cache --autoclean - -env: - global: - - RUST_BACKTRACE=1 - - secure: "OKulfkA5OGd/d1IhvBKzRkHQwMcWjzrzbimo7+5NhkUkWxndAzl+719TB3wWvIh1i2wXXrEXsyZkXM5FtRrHm55v1VKQ5ibjEvFg1w3NIg81iDyoLq186fLqywvxGkOAFPrsePPsBj5USd5xvhwwbrjO6L7/RK6Z8shBwOSc41s=" - -before_install: - - export CARGO_TARGET_DIR="$TRAVIS_BUILD_DIR/target" - - | - case "$TRAVIS_OS_NAME" in - linux ) HOST=x86_64-unknown-linux-gnu;; - osx ) HOST=x86_64-apple-darwin;; - windows ) HOST=x86_64-pc-windows-msvc;; - esac - - curl -sSL https://sh.rustup.rs | sh -s -- -y --default-host="$HOST" --default-toolchain=nightly --profile=minimal - - export PATH="$HOME/.cargo/bin:$PATH" -install: - - | - if [[ -z ${INTEGRATION} ]]; then - if ! rustup component add rustfmt; then - TARGET=$(rustc -Vv | awk '/host/{print $2}') - NIGHTLY=$(curl -s "https://rust-lang.github.io/rustup-components-history/${TARGET}/rustfmt") - curl -sSL "https://static.rust-lang.org/dist/${NIGHTLY}/rustfmt-nightly-${TARGET}.tar.xz" | \ - tar -xJf - --strip-components=3 -C ~/.cargo/bin - rm -rf ~/.cargo/bin/doc - fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - . $HOME/.nvm/nvm.sh - nvm install stable - nvm use stable - npm install remark-cli remark-lint - elif [[ "$TRAVIS_OS_NAME" == "windows" ]]; then - choco install windows-sdk-10.1 - fi - fi - -# disabling the integration tests in forks should be done with -# if: fork = false -# but this is currently buggy travis-ci/travis-ci#9118 -matrix: - fast_finish: true - include: - # Builds that are executed for every PR - - os: linux - # i686 toolchain could run on x86_64 system. - - os: linux - env: HOST_TOOLCHAIN=i686-unknown-linux-gnu - addons: - apt: - packages: - - gcc-multilib - - libssl-dev:i386 # openssl dev in Cargo.toml - if: branch IN (auto, try) - - os: windows - env: CARGO_INCREMENTAL=0 OS_WINDOWS=true - - # Builds that are only executed when a PR is r+ed or a try build is started - # We don't want to run these always because they go towards - # the build limit within the Travis rust-lang account. - # The jobs are approximately sorted by execution time - - os: osx - if: branch IN (auto, try) - - env: INTEGRATION=rust-lang/rls - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/cargo - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/chalk - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=Geal/nom - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/rustfmt - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=hyperium/hyper - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-itertools/itertools - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - # FIXME: rustc ICE on `serde_test_suite` - # - env: INTEGRATION=serde-rs/serde - # if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/stdarch - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-random/rand - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/futures-rs - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=Marwes/combine - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang-nursery/failure - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=rust-lang/log - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - - env: INTEGRATION=chronotope/chrono - if: repo =~ /^rust-lang\/rust-clippy$/ AND branch IN (auto, try) - allow_failures: - - os: windows - env: CARGO_INCREMENTAL=0 OS_WINDOWS=true - -before_script: - - | - if [[ "$TRAVIS_BRANCH" == "auto" ]] || [[ "$TRAVIS_BRANCH" == "try" ]]; then - PR=$(echo "$TRAVIS_COMMIT_MESSAGE" | grep -o "#[0-9]*" | head -1 | sed 's/^#//g') - output=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -s "https://api.github.com/repos/rust-lang/rust-clippy/pulls/$PR" | \ - python -c "import sys, json; print(json.load(sys.stdin)['body'])" | \ - grep "^changelog: " | \ - sed "s/changelog: //g") - if [[ -z "$output" ]]; then - echo "ERROR: PR body must contain 'changelog: ...'" - exit 1 - elif [[ "$output" = "none" ]]; then - echo "WARNING: changelog is 'none'" - fi - fi - - | - rm rust-toolchain - ./setup-toolchain.sh - - | - SYSROOT=$(rustc --print sysroot) - case "$TRAVIS_OS_NAME" in - windows ) export PATH="${SYSROOT}/bin:${PATH}" ;; - linux ) export LD_LIBRARY_PATH="${SYSROOT}/lib${LD_LIBRARY_PATH+:${LD_LIBRARY_PATH}}" ;; - osx ) - # See - sudo mkdir -p /usr/local/lib - sudo find "$SYSROOT/lib" -maxdepth 1 -name '*.dylib' -exec ln -s {} /usr/local/lib \; - ;; - esac - -script: - - | - if [[ -n ${INTEGRATION} ]]; then - cargo test --test integration --features integration && sleep 5 - else - ./ci/base-tests.sh && sleep 5 - fi - -after_success: - - | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - set -e - if [[ -z ${INTEGRATION} ]]; then - ./.github/deploy.sh - else - echo "Not deploying, because we're in an integration test run" - fi - set +e - fi diff --git a/appveyor.yml b/appveyor.yml index bf6133e98a06..fe6745997ede 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,44 +3,14 @@ environment: PROJECT_NAME: rust-clippy RUST_BACKTRACE: 1 matrix: - #- TARGET: i686-pc-windows-gnu - #- TARGET: i686-pc-windows-msvc - #- TARGET: x86_64-pc-windows-gnu - TARGET: x86_64-pc-windows-msvc branches: - # Only build AppVeyor on r+ and try branch only: - - auto - - try - -cache: - - '%USERPROFILE%\.cargo' -# before cache -after_test: - - cargo install cargo-cache --debug - - cargo cache --autoclean - -install: - - curl -sSf -o rustup-init.exe https://win.rustup.rs/ - - rustup-init.exe -y --default-host %TARGET% --default-toolchain nightly --profile=minimal - - set PATH=%USERPROFILE%\.cargo\bin;%PATH% - - rustup component add rustfmt --toolchain nightly & exit 0 # Format test handles missing rustfmt - - del rust-toolchain - - cargo install rustup-toolchain-install-master - - rustup-toolchain-install-master -f -n master -c rustc-dev - - rustup override set master - - rustc -V - - cargo -V - -# Build settings, not to be confused with "before_build" and "after_build". -build: false + - dummy_dummy_dummy build_script: - - cargo build --features deny-warnings - -test_script: - - cargo test --features deny-warnings + - echo "Dummy" notifications: - provider: Email diff --git a/ci/base-tests.sh b/ci/base-tests.sh deleted file mode 100755 index 125a566271d0..000000000000 --- a/ci/base-tests.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -set -ex - -echo "Running clippy base tests" - -PATH=$PATH:./node_modules/.bin -if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - remark -f ./*.md -f doc/*.md > /dev/null -fi -# build clippy in debug mode and run tests -cargo build --features deny-warnings -cargo test --features deny-warnings - -(cd clippy_lints && cargo test --features deny-warnings) -(cd rustc_tools_util && cargo test --features deny-warnings) -(cd clippy_dev && cargo test --features deny-warnings) - -# make sure clippy can be called via ./path/to/cargo-clippy -( - cd clippy_workspace_tests - ../target/debug/cargo-clippy -) - -# Perform various checks for lint registration -cargo dev update_lints --check -cargo dev --limit-stderr-length - -# Check running clippy-driver without cargo -( - # Check sysroot handling - sysroot=$(./target/debug/clippy-driver --print sysroot) - test "$sysroot" = "$(rustc --print sysroot)" - - if [[ -z "$OS_WINDOWS" ]]; then - desired_sysroot=/tmp - else - desired_sysroot=C:/tmp - fi - sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) - test "$sysroot" = $desired_sysroot - - sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) - test "$sysroot" = $desired_sysroot - - # Make sure this isn't set - clippy-driver should cope without it - unset CARGO_MANIFEST_DIR - - # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 - # FIXME: How to match the clippy invocation in compile-test.rs? - ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 - sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr - diff normalized.stderr tests/ui/cstring.stderr - - # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR -) From f411625740923a1a9070e6019b9825c88d31d3b9 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Sun, 26 Jan 2020 15:13:14 +0100 Subject: [PATCH 20/25] Extract driver test --- .github/driver.sh | 29 ++++++++++++++++++++++++++++ .github/workflows/clippy.yml | 28 +++------------------------ .github/workflows/clippy_bors.yml | 32 +++---------------------------- 3 files changed, 35 insertions(+), 54 deletions(-) create mode 100644 .github/driver.sh diff --git a/.github/driver.sh b/.github/driver.sh new file mode 100644 index 000000000000..eb81e45a64ea --- /dev/null +++ b/.github/driver.sh @@ -0,0 +1,29 @@ +#! /bin/bash + +set -ex + +# Check sysroot handling +sysroot=$(./target/debug/clippy-driver --print sysroot) +test "$sysroot" = "$(rustc --print sysroot)" + +if [[ ${OS} == "Windows" ]]; then + desired_sysroot=C:/tmp +else + desired_sysroot=/tmp +fi +sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) +test "$sysroot" = $desired_sysroot + +sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) +test "$sysroot" = $desired_sysroot + +# Make sure this isn't set - clippy-driver should cope without it +unset CARGO_MANIFEST_DIR + +# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 +# FIXME: How to match the clippy invocation in compile-test.rs? +./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 +sed -e "s,tests/ui,\$DIR," -e "/= help/d" cstring.stderr > normalized.stderr +diff normalized.stderr tests/ui/cstring.stderr + +# TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 7997344aabd0..9661f826abd3 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -68,31 +68,9 @@ jobs: run: ../target/debug/cargo-clippy working-directory: clippy_workspace_tests - name: Test clippy-driver - run: | - ( - set -ex - # Check sysroot handling - sysroot=$(./target/debug/clippy-driver --print sysroot) - test "$sysroot" = "$(rustc --print sysroot)" - - desired_sysroot=/tmp - sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) - test "$sysroot" = $desired_sysroot - - sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) - test "$sysroot" = $desired_sysroot - - # Make sure this isn't set - clippy-driver should cope without it - unset CARGO_MANIFEST_DIR - - # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 - # FIXME: How to match the clippy invocation in compile-test.rs? - ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 - sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr - diff normalized.stderr tests/ui/cstring.stderr - - # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR - ) + run: bash .github/driver.sh + env: + OS: ${{ runner.os }} - name: Run cargo-cache --autoclean run: | diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index c559de330ab0..8d2e46ed4caa 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -136,36 +136,10 @@ jobs: shell: bash working-directory: clippy_workspace_tests - name: Test clippy-driver - run: | - ( - set -ex - # Check sysroot handling - sysroot=$(./target/debug/clippy-driver --print sysroot) - test "$sysroot" = "$(rustc --print sysroot)" - - if [[ ${{ runner.os }} == "Windows" ]]; then - desired_sysroot=C:/tmp - else - desired_sysroot=/tmp - fi - sysroot=$(./target/debug/clippy-driver --sysroot $desired_sysroot --print sysroot) - test "$sysroot" = $desired_sysroot - - sysroot=$(SYSROOT=$desired_sysroot ./target/debug/clippy-driver --print sysroot) - test "$sysroot" = $desired_sysroot - - # Make sure this isn't set - clippy-driver should cope without it - unset CARGO_MANIFEST_DIR - - # Run a lint and make sure it produces the expected output. It's also expected to exit with code 1 - # FIXME: How to match the clippy invocation in compile-test.rs? - ./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/cstring.rs 2> cstring.stderr && exit 1 - sed -e 's,tests/ui,$DIR,' -e '/= help/d' cstring.stderr > normalized.stderr - diff normalized.stderr tests/ui/cstring.stderr - - # TODO: CLIPPY_CONF_DIR / CARGO_MANIFEST_DIR - ) + run: bash .github/driver.sh shell: bash + env: + OS: ${{ runner.os }} - name: Run cargo-cache --autoclean run: | From 9e5c010e519cc7de0bfe00d6232bf79c9c6e09ec Mon Sep 17 00:00:00 2001 From: flip1995 Date: Sun, 26 Jan 2020 15:40:53 +0100 Subject: [PATCH 21/25] Extract deployment --- .github/deploy.sh | 43 ++++++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 43 +----------------------------------- 2 files changed, 44 insertions(+), 42 deletions(-) create mode 100644 .github/deploy.sh diff --git a/.github/deploy.sh b/.github/deploy.sh new file mode 100644 index 000000000000..d96c69392a1e --- /dev/null +++ b/.github/deploy.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +set -ex + +echo "Removing the current docs for master" +rm -rf out/master/ || exit 0 + +echo "Making the docs for master" +mkdir out/master/ +cp util/gh-pages/index.html out/master +python ./util/export.py out/master/lints.json + +if [[ -n $TAG_NAME ]]; then + echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it" + cp -r out/master "out/$TAG_NAME" + rm -f out/current + ln -s "$TAG_NAME" out/current +fi + +# Generate version index that is shown as root index page +cp util/gh-pages/versions.html out/index.html + +cd out +cat <<-EOF | python - > versions.json +import os, json +print json.dumps([ + dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir) +]) +EOF + +# Now let's go have some fun with the cloned repo +git config user.name "GHA CI" +git config user.email "gha@ci.invalid" + +if git diff --exit-code --quiet; then + echo "No changes to the output on this push; exiting." + exit 0 +fi + +git add . +git commit -m "Automatic deploy to GitHub Pages: ${SHA}" + +git push "$SSH_REPO" "$TARGET_BRANCH" diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 100adbadd5ab..a3c9b1784a18 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -26,47 +26,6 @@ jobs: path: 'out' - name: Deploy run: | - set -ex - - echo "Removing the current docs for master" - rm -rf out/master/ || exit 0 - - echo "Making the docs for master" - mkdir out/master/ - cp util/gh-pages/index.html out/master - python ./util/export.py out/master/lints.json - - if [[ -n $TAG_NAME ]]; then - echo "Save the doc for the current tag ($TAG_NAME) and point current/ to it" - cp -r out/master "out/$TAG_NAME" - rm -f out/current - ln -s "$TAG_NAME" out/current - fi - - # Generate version index that is shown as root index page - cp util/gh-pages/versions.html out/index.html - - cd out - cat <<-EOF | python - > versions.json - import os, json - print json.dumps([ - dir for dir in os.listdir(".") if not dir.startswith(".") and os.path.isdir(dir) - ]) - EOF - - # Now let's go have some fun with the cloned repo - git config user.name "GHA CI" - git config user.email "gha@ci.invalid" - - if git diff --exit-code --quiet; then - echo "No changes to the output on this push; exiting." - exit 0 - fi - - git add . - git commit -m "Automatic deploy to GitHub Pages: ${SHA}" - eval "$(ssh-agent -s)" ssh-add - <<< "${{ secrets.DEPLOY_KEY }}" - - git push "$SSH_REPO" "$TARGET_BRANCH" + bash .github/deploy.sh From ff9e96de42b06181451e1f5620242bc29bf2a239 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Thu, 30 Jan 2020 17:03:45 +0100 Subject: [PATCH 22/25] Allow non-ascii characters in changelog check --- .github/workflows/clippy_bors.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index 8d2e46ed4caa..b0dd71812b9d 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -41,6 +41,8 @@ jobs: elif [[ "$output" = "none" ]]; then echo "WARNING: changelog is 'none'" fi + env: + PYTHONIOENCODING: 'utf-8' base: needs: changelog strategy: From 0bfe00ff9a37890750a6f7800c0ebbd4867f431f Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 31 Jan 2020 14:42:44 +0100 Subject: [PATCH 23/25] Build Clippy before running integration tests --- .github/workflows/clippy_bors.yml | 56 ++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index b0dd71812b9d..e5c570828f9a 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -149,8 +149,50 @@ jobs: /usr/bin/find ~/.cargo/bin ! -type d -exec strip {} \; cargo cache --autoclean shell: bash - integration: + integration_build: needs: changelog + runs-on: ubuntu-latest + + steps: + - uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master + with: + github_token: "${{ secrets.github_token }}" + - name: rust-toolchain + uses: actions-rs/toolchain@v1.0.3 + with: + toolchain: nightly + target: x86_64-unknown-linux-gnu + profile: minimal + - name: Cache cargo dir + uses: actions/cache@v1 + with: + path: ~/.cargo + key: ${{ runner.os }}-x86_64-unknown-linux-gnu + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Master Toolchain Setup + run: bash setup-toolchain.sh + + - name: Build Integration Test + run: cargo test --test integration --features integration --no-run + - name: Extract Binaries + run: | + DIR=$CARGO_TARGET_DIR/debug + find $DIR ! -executable -o -type d ! -path $DIR | xargs rm -rf + mv $DIR/integration-* $DIR/integration + - name: Upload Binaries + uses: actions/upload-artifact@v1 + with: + name: target + path: target + + - name: Run cargo-cache --autoclean + run: | + cargo install cargo-cache --debug + find ~/.cargo/bin ! -type d -exec strip {} \; + cargo cache --autoclean + integration: + needs: integration_build strategy: fail-fast: false max-parallel: 6 @@ -194,12 +236,18 @@ jobs: - name: Master Toolchain Setup run: bash setup-toolchain.sh - - name: Build - run: cargo build --features integration + - name: Download target dir + uses: actions/download-artifact@v1 + with: + name: target + path: target + - name: Make Binaries Executable + run: chmod +x $CARGO_TARGET_DIR/debug/* - name: Test ${{ matrix.integration }} - run: cargo test --test integration --features integration + run: $CARGO_TARGET_DIR/debug/integration env: INTEGRATION: ${{ matrix.integration }} + RUSTUP_TOOLCHAIN: master - name: Run cargo-cache --autoclean run: | From 55c33e6f1eadaf2a5cb019ea275cf0a1a9d4aad9 Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 31 Jan 2020 14:43:02 +0100 Subject: [PATCH 24/25] Add two more error causes to integration test --- tests/integration.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integration.rs b/tests/integration.rs index d14ced8ad4e7..74f9a854dc1f 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -59,6 +59,10 @@ fn integration_test() { panic!("query stack during panic in the output"); } else if stderr.contains("E0463") { panic!("error: E0463"); + } else if stderr.contains("E0514") { + panic!("incompatible crate versions"); + } else if stderr.contains("failed to run `rustc` to learn about target-specific information") { + panic!("couldn't find librustc_driver, consider setting `LD_LIBRARY_PATH`"); } match output.status.code() { From ff4940321892aedec6003db5be14f1279b2cc05d Mon Sep 17 00:00:00 2001 From: flip1995 Date: Fri, 31 Jan 2020 14:44:55 +0100 Subject: [PATCH 25/25] Use hash of Cargo.lock file in cache name --- .github/workflows/clippy.yml | 10 +++++++--- .github/workflows/clippy_bors.yml | 30 +++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 9661f826abd3..b4bd9f540bd1 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -37,13 +37,17 @@ jobs: toolchain: nightly target: x86_64-unknown-linux-gnu profile: minimal + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Run cargo update + run: cargo update - name: Cache cargo dir uses: actions/cache@v1 with: path: ~/.cargo - key: ${{ runner.os }}-x86_64-unknown-linux-gnu - - name: Checkout - uses: actions/checkout@v2.0.0 + key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-x86_64-unknown-linux-gnu - name: Master Toolchain Setup run: bash setup-toolchain.sh diff --git a/.github/workflows/clippy_bors.yml b/.github/workflows/clippy_bors.yml index e5c570828f9a..3603ad76a692 100644 --- a/.github/workflows/clippy_bors.yml +++ b/.github/workflows/clippy_bors.yml @@ -85,13 +85,17 @@ jobs: toolchain: nightly target: ${{ matrix.host }} profile: minimal + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Run cargo update + run: cargo update - name: Cache cargo dir uses: actions/cache@v1 with: path: ~/.cargo - key: ${{ runner.os }}-${{ matrix.host }} - - name: Checkout - uses: actions/checkout@v2.0.0 + key: ${{ runner.os }}-${{ matrix.host }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.host }} - name: Master Toolchain Setup run: bash setup-toolchain.sh env: @@ -163,13 +167,17 @@ jobs: toolchain: nightly target: x86_64-unknown-linux-gnu profile: minimal + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Run cargo update + run: cargo update - name: Cache cargo dir uses: actions/cache@v1 with: path: ~/.cargo - key: ${{ runner.os }}-x86_64-unknown-linux-gnu - - name: Checkout - uses: actions/checkout@v2.0.0 + key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-x86_64-unknown-linux-gnu - name: Master Toolchain Setup run: bash setup-toolchain.sh @@ -226,13 +234,17 @@ jobs: toolchain: nightly target: x86_64-unknown-linux-gnu profile: minimal + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Run cargo update + run: cargo update - name: Cache cargo dir uses: actions/cache@v1 with: path: ~/.cargo - key: ${{ runner.os }}-x86_64-unknown-linux-gnu - - name: Checkout - uses: actions/checkout@v2.0.0 + key: ${{ runner.os }}-x86_64-unknown-linux-gnu-${{ hashFiles('Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-x86_64-unknown-linux-gnu - name: Master Toolchain Setup run: bash setup-toolchain.sh