mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-11 07:34:18 +00:00
Book: add a ci chapter
This commit is contained in:
parent
4e6b55e9b8
commit
853d7eeed6
6 changed files with 58 additions and 23 deletions
|
@ -13,6 +13,10 @@
|
|||
- [Pendantic]()
|
||||
- [Nursery]()
|
||||
- [Cargo]()
|
||||
- [Continuous Integration](continuous_integration/README.md)
|
||||
- [Travis CI](continuous_integration/travis.md)
|
||||
- [GitHub Actions](continuous_integration/github_actions.md)
|
||||
- [Gitlab](continuous_integration/gitlab.md)
|
||||
- [Development](development/README.md)
|
||||
- [Basics](development/basics.md)
|
||||
- [Adding Lints](development/adding_lints.md)
|
||||
|
|
5
book/src/continuous_integration/README.md
Normal file
5
book/src/continuous_integration/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Continuous Integration
|
||||
|
||||
- [Travis CI](travis.md)
|
||||
- [Github Actions](github_actions.md)
|
||||
- [Gitlab](gitlab.md)
|
18
book/src/continuous_integration/github_actions.md
Normal file
18
book/src/continuous_integration/github_actions.md
Normal file
|
@ -0,0 +1,18 @@
|
|||
# GitHub Actions
|
||||
|
||||
## actions-rs
|
||||
|
||||
An easy way to get started with adding Clippy to GitHub Actions is
|
||||
the [actions-rs](https://github.com/actions-rs) [clippy-check](https://github.com/actions-rs/clippy-check):
|
||||
|
||||
```yml
|
||||
on: push
|
||||
name: Clippy check
|
||||
jobs:
|
||||
clippy_check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Run Clippy
|
||||
run: cargo clippy
|
||||
```
|
3
book/src/continuous_integration/gitlab.md
Normal file
3
book/src/continuous_integration/gitlab.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Gitlab
|
||||
|
||||
***placeholder***
|
25
book/src/continuous_integration/travis.md
Normal file
25
book/src/continuous_integration/travis.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Travis CI
|
||||
|
||||
You can add Clippy to Travis CI in the same way you use it locally:
|
||||
|
||||
```yml
|
||||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
before_script:
|
||||
- rustup component add clippy
|
||||
script:
|
||||
- cargo clippy
|
||||
# if you want the build job to fail when encountering warnings, use
|
||||
- cargo clippy -- -D warnings
|
||||
# in order to also check tests and non-default crate features, use
|
||||
- cargo clippy --all-targets --all-features -- -D warnings
|
||||
- cargo test
|
||||
# etc.
|
||||
```
|
||||
|
||||
Note that adding `-D warnings` will cause your build to fail if **any** warnings are found in your code.
|
||||
That includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to avoid this and only cause
|
||||
an error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command
|
||||
line. (You can swap `clippy::all` with the specific lint category you are targeting.)
|
|
@ -81,28 +81,8 @@ clippy-driver --edition 2018 -Cpanic=abort foo.rs
|
|||
|
||||
Note that `rustc` will still run, i.e. it will still emit the output files it normally does.
|
||||
|
||||
### Travis CI
|
||||
### Continuous Integration
|
||||
|
||||
You can add Clippy to Travis CI in the same way you use it locally:
|
||||
Adding Clippy to your continuous integration pipeline is a great way to automate the linting process. See the
|
||||
[Continuous Integration](continuous_integration) chapter for more information.
|
||||
|
||||
```yml
|
||||
language: rust
|
||||
rust:
|
||||
- stable
|
||||
- beta
|
||||
before_script:
|
||||
- rustup component add clippy
|
||||
script:
|
||||
- cargo clippy
|
||||
# if you want the build job to fail when encountering warnings, use
|
||||
- cargo clippy -- -D warnings
|
||||
# in order to also check tests and non-default crate features, use
|
||||
- cargo clippy --all-targets --all-features -- -D warnings
|
||||
- cargo test
|
||||
# etc.
|
||||
```
|
||||
|
||||
Note that adding `-D warnings` will cause your build to fail if **any** warnings are found in your code.
|
||||
That includes warnings found by rustc (e.g. `dead_code`, etc.). If you want to avoid this and only cause
|
||||
an error for Clippy warnings, use `#![deny(clippy::all)]` in your code or `-D clippy::all` on the command
|
||||
line. (You can swap `clippy::all` with the specific lint category you are targeting.)
|
||||
|
|
Loading…
Reference in a new issue