name: Rust

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:

    runs-on: ubuntu-22.04

    steps:
    - uses: actions/checkout@v4

    - name: Install toolchain
      uses: dtolnay/rust-toolchain@1.79.0

    - name: Build
      run: cargo build --verbose --all-targets

    - name: Run tests
      # avoid running the bench_ci, for which there is a separate github
      # workflow
      run: cargo test --verbose --examples --tests --bench bench


  coverage:
    name: Coverage
    runs-on: ubuntu-22.04
    container:
      image: xd009642/tarpaulin:0.28.0-slim
      options: --security-opt seccomp=unconfined
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@1.79.0

      - name: Generate code coverage
        run: |
          cargo tarpaulin --engine llvm --verbose --timeout 120 --exclude-files shootout --exclude-files benches --exclude-files fuzz --out Lcov -- --test-threads 1

      - name: upload to Coveralls
        uses: coverallsapp/github-action@v2.3.0
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          path-to-lcov: './lcov.info'


  clippy:
    name: Lint 📎
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Install toolchain
        uses: dtolnay/rust-toolchain@1.79.0
        with:
          components: clippy

      - name: Run clippy
        uses: actions-rs-plus/clippy-check@v2.2.0
        with:
          args: --all-features
