realitydefender 0.1.8

Reality Defender SDK for Rust - Tools for detecting deepfakes and manipulated media
Documentation
name: Format, check, and test Rust SDK

on:
  workflow_call:
    inputs:
      is-release:
        default: false
        type: boolean
        description: Whether this is a release run or not.

jobs:
  check-format-test-rust-sdk:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          override: true
          components: rustfmt, clippy

      - name: Cache dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            ~/.cargo/bin/cargo-tarpaulin
            rust/target
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

      - name: Check formatting
        run: |
          cargo fmt --all -- --check

      - name: Lint with clippy
        run: |
          cargo clippy --no-deps -- -D warnings

      - name: Install cargo-tarpaulin
        run: |
          if ! command -v cargo-tarpaulin &> /dev/null; then
            cargo install cargo-tarpaulin
          fi

      - name: Generate coverage report
        run: |
          cargo tarpaulin --all-features --out Xml --output-dir ./

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./cobertura.xml
          flags: rust
          name: rust-sdk-codecov
          fail_ci_if_error: ${{ inputs.is-release }}

  sonarqube:
    name: SonarQube
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - name: SonarQube Scan
        uses: SonarSource/sonarqube-scan-action@v5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}