diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 470760b6d16..5d10101d637 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -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) diff --git a/book/src/continuous_integration/README.md b/book/src/continuous_integration/README.md new file mode 100644 index 00000000000..a28959de5c5 --- /dev/null +++ b/book/src/continuous_integration/README.md @@ -0,0 +1,5 @@ +# Continuous Integration + +- [Travis CI](travis.md) +- [Github Actions](github_actions.md) +- [Gitlab](gitlab.md) diff --git a/book/src/continuous_integration/github_actions.md b/book/src/continuous_integration/github_actions.md new file mode 100644 index 00000000000..070ef5b41c2 --- /dev/null +++ b/book/src/continuous_integration/github_actions.md @@ -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 +``` diff --git a/book/src/continuous_integration/gitlab.md b/book/src/continuous_integration/gitlab.md new file mode 100644 index 00000000000..bb5b755d5dd --- /dev/null +++ b/book/src/continuous_integration/gitlab.md @@ -0,0 +1,3 @@ +# Gitlab + +***placeholder*** diff --git a/book/src/continuous_integration/travis.md b/book/src/continuous_integration/travis.md new file mode 100644 index 00000000000..36e467f9858 --- /dev/null +++ b/book/src/continuous_integration/travis.md @@ -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.) diff --git a/book/src/installation_and_usage.md b/book/src/installation_and_usage.md index 190c8ed5342..8982e0f1037 100644 --- a/book/src/installation_and_usage.md +++ b/book/src/installation_and_usage.md @@ -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.)