From 25ceadc62780d7a1bf10693f9ef9b164864ff52a Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Fri, 26 Jun 2020 15:10:51 -0700 Subject: [PATCH 1/5] Add CI job for linting using cargo clippy --- .github/workflows/build-test.yml | 48 ++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 637aedc505d..c78d09bee4e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -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 From bc416a3aad657a350fb8da91b3e5ec27319dafee Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Sun, 28 Jun 2020 18:47:21 -0700 Subject: [PATCH 2/5] Make clippy step exit on warnings using CLI instead of actions-rs action --- .github/workflows/build-test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c78d09bee4e..12a42359c42 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -104,8 +104,7 @@ jobs: args: --all-targets --all-features # Run clippy second time to fail job on warnings + # cargo clean should not be necessary, but empirically, it is on Github + # (but not locally in CLI?). poss ex: https://github.com/rust-lang/rust-clippy/issues/4612 - name: Fail clippy on warnings - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-targets --all-features -- -D warnings + run: cargo clean && cargo clippy --all-targets --all-features -- -D warnings From eec4b8774cbe221928a60322937f4555b5f8b823 Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Sun, 28 Jun 2020 19:26:59 -0700 Subject: [PATCH 3/5] Keep UI inline clippy warnings while still fail job on warnings --- .github/workflows/build-test.yml | 43 +++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 12a42359c42..3644ae836d7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -62,7 +62,7 @@ jobs: # make this command fail if cargo fmt had to make changes run: cargo fmt && git diff-index --exit-code HEAD - # Linting job (cargo-clippy) + # Linting job permissive (cargo-clippy) - completes and puts warnings inline in PR lint: runs-on: ubuntu-latest @@ -72,7 +72,7 @@ jobs: steps: - uses: actions/checkout@v2 - # Linting job > Cache steps + # Linting job permissive > Cache steps - name: Cache cargo registry uses: actions/cache@v1 @@ -92,7 +92,7 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }} - # Linting job > Install and run clippy steps + # Linting job permissive > Install and run clippy steps - name: Install clippy run: rustup component add clippy @@ -103,8 +103,43 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} args: --all-targets --all-features + # Linting job strict (cargo-clippy) + + lint_strict: + runs-on: ubuntu-latest + + needs: [build] + + steps: + - uses: actions/checkout@v2 + + # Linting job strict > 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 strict > Install and run clippy steps + + - name: Install clippy + run: rustup component add clippy + # Run clippy second time to fail job on warnings - # cargo clean should not be necessary, but empirically, it is on Github + # `cargo clean` should not be necessary, but empirically, it is needed during Github Actions # (but not locally in CLI?). poss ex: https://github.com/rust-lang/rust-clippy/issues/4612 - name: Fail clippy on warnings run: cargo clean && cargo clippy --all-targets --all-features -- -D warnings From e35ed963d2c3ef7686aae31a4be782c63d96b3b1 Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Wed, 1 Jul 2020 11:59:40 -0700 Subject: [PATCH 4/5] Remove caching in clippy linter job to prevent confusing clippy --- .github/workflows/build-test.yml | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 3644ae836d7..a68d230962a 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -113,33 +113,11 @@ jobs: steps: - uses: actions/checkout@v2 - # Linting job strict > 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 strict > Install and run clippy steps - name: Install clippy run: rustup component add clippy - # Run clippy second time to fail job on warnings - # `cargo clean` should not be necessary, but empirically, it is needed during Github Actions - # (but not locally in CLI?). poss ex: https://github.com/rust-lang/rust-clippy/issues/4612 + # avoid caching to prevent confusing cargo clippy - name: Fail clippy on warnings - run: cargo clean && cargo clippy --all-targets --all-features -- -D warnings + run: cargo clippy --all-targets --all-features -- -D warnings From 278ab845ea733fe255e1173a039b0d2fe3d96f2a Mon Sep 17 00:00:00 2001 From: Elango Cheran Date: Wed, 8 Jul 2020 12:59:00 -0700 Subject: [PATCH 5/5] Use latest version of clippy action to get strict mode --- .github/workflows/build-test.yml | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index a68d230962a..ccdbe43ad2f 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -62,7 +62,7 @@ jobs: # make this command fail if cargo fmt had to make changes run: cargo fmt && git diff-index --exit-code HEAD - # Linting job permissive (cargo-clippy) - completes and puts warnings inline in PR + # Linting job (cargo-clippy) - completes and puts warnings inline in PR lint: runs-on: ubuntu-latest @@ -72,7 +72,7 @@ jobs: steps: - uses: actions/checkout@v2 - # Linting job permissive > Cache steps + # Linting job > Cache steps - name: Cache cargo registry uses: actions/cache@v1 @@ -92,32 +92,12 @@ jobs: path: target key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.toml') }} - # Linting job permissive > Install and run clippy steps + # 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 + - uses: actions-rs/clippy-check@v1.0.7 with: token: ${{ secrets.GITHUB_TOKEN }} - args: --all-targets --all-features - - # Linting job strict (cargo-clippy) - - lint_strict: - runs-on: ubuntu-latest - - needs: [build] - - steps: - - uses: actions/checkout@v2 - - # Linting job strict > Install and run clippy steps - - - name: Install clippy - run: rustup component add clippy - - # avoid caching to prevent confusing cargo clippy - - name: Fail clippy on warnings - run: cargo clippy --all-targets --all-features -- -D warnings + args: --all-targets --all-features -- -D warnings