diff --git a/.github/workflows/clippy.yaml b/.github/workflows/clippy.yaml new file mode 100644 index 0000000..b2b3234 --- /dev/null +++ b/.github/workflows/clippy.yaml @@ -0,0 +1,54 @@ +name: Clippy Test + +on: + pull_request: + + +jobs: + git-diff: + runs-on: ubuntu-latest + name: 'Git Diff - Powered by Rust' + outputs: + DIFF_FILES: ${{ steps.git-diff.outputs.DIFF_FILES }} + DIFF_COUNT: ${{ steps.git-diff.outputs.DIFF_COUNT }} + steps: + - uses: actions/checkout@v4 + - uses: LuisLiraC/git-diff@v1.0.2 + id: git-diff + with: + patterns: '*.rs' + + clippy-test: + runs-on: ubuntu-latest + needs: [git-diff] + if: ${{ needs.git-diff.outputs.DIFF_COUNT != 0 }} + name: Run Tests + steps: + - uses: actions/checkout@v4 + + - name: Cache cargo registry + uses: actions/cache@v4 + with: + path: ~/.cargo/registry + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-registry- + + - name: Cache cargo index + uses: actions/cache@v4 + with: + path: ~/.cargo/git + key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-index- + + - name: Cache cargo build + uses: actions/cache@v4 + with: + path: target + key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo-build- + + - name: Run Tests + run: cargo clippy --color always -- -Dwarnings -W clippy::pedantic