diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 637aedc505d..ccdbe43ad2f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -61,3 +61,43 @@ 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) - completes and puts warnings inline in PR + + 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 + + - uses: actions-rs/clippy-check@v1.0.7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-targets --all-features -- -D warnings