Book: add a ci chapter

This commit is contained in:
josh rotenberg 2021-08-03 13:05:20 -07:00 committed by Philipp Krones
parent 4e6b55e9b8
commit 853d7eeed6
No known key found for this signature in database
GPG key ID: 1CA0DF2AF59D68A5
6 changed files with 58 additions and 23 deletions

View file

@ -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)

View file

@ -0,0 +1,5 @@
# Continuous Integration
- [Travis CI](travis.md)
- [Github Actions](github_actions.md)
- [Gitlab](gitlab.md)

View 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
```

View file

@ -0,0 +1,3 @@
# Gitlab
***placeholder***

View 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.)

View file

@ -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.)