Skip to content

Commit

Permalink
Add CI job for linting using cargo clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
echeran committed Jun 29, 2020
1 parent dbffa07 commit f7cd7c6
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,51 @@ jobs:
- name: Rust linter
# make this command fail if cargo fmt had to make changes
run: cargo fmt && git diff-index --exit-code HEAD

# Linting job (cargo-clippy)

lint:
runs-on: ubuntu-latest

needs: [build]

steps:
- uses: actions/checkout@v2

# Linting job > Cache steps

- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}

- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }}

# Linting job > Install and run clippy steps

- name: Install clippy
run: rustup component add clippy

# Run clippy first time to get warnings inserted inline in PR
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features

# Run clippy second time to fail job on warnings
- name: Fail clippy on warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets --all-features -- -D warnings

0 comments on commit f7cd7c6

Please sign in to comment.