name: "Clippy Security Analysis"
on:
pull_request:
branches: ["main"]
schedule:
- cron: "17 22 * * 0" workflow_dispatch:
push:
branches: ["main"]
permissions:
contents: read
security-events: write
actions: read
jobs:
clippy-sarif:
name: Clippy SARIF Analysis
runs-on: ubuntu-latest
env:
CLIPPY_SARIF_VERSION: "0.8.0"
SARIF_FMT_VERSION: "0.8.0"
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd with:
persist-credentials: false
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 with:
cache: true
- name: Install clippy-sarif
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 with:
tool: clippy-sarif@${{ env.CLIPPY_SARIF_VERSION }}
- name: Install sarif-fmt
uses: taiki-e/cache-cargo-install-action@417450f3c33ee20393705369577571770643d4c7 with:
tool: sarif-fmt@${{ env.SARIF_FMT_VERSION }}
- name: Run clippy with SARIF output
run: |
set -euo pipefail
cargo clippy \
--workspace \
--all-targets \
--all-features \
--message-format=json \
-- -W clippy::pedantic -W clippy::nursery -W clippy::cargo | \
clippy-sarif | \
tee rust-clippy-results.sarif | \
sarif-fmt
continue-on-error: true
- name: Upload SARIF results
if: >-
always()
&& hashFiles('rust-clippy-results.sarif') != ''
&& (
github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == github.repository
)
uses: github/codeql-action/upload-sarif@7211b7c8077ea37d8641b6271f6a365a22a5fbfa with:
sarif_file: rust-clippy-results.sarif
category: "clippy"
wait-for-processing: true