rasusa 4.1.0

Randomly subsample reads or alignments
# Based on https://github.com/actions-rs/meta/blob/master/recipes/msrv.md

on: 
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

name: Rust CI

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  # Disable incremental compilation for CI builds
  CARGO_INCREMENTAL: 0
  # Enable more verbose backtraces for easier debugging
  RUST_BACKTRACE: 1

jobs:
  cog_check_job:
    runs-on: ubuntu-latest
    name: check conventional commit compliance
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
          # pick the pr HEAD instead of the merge commit only if it's a PR, otherwise use the default
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

      - name: Conventional commit check
        uses: cocogitto/cocogitto-action@v4
        with:
          command: check
          args: --from-latest-tag

  check:
    name: Check Rust version ${{ matrix.rust }} on OS ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]
        rust:
          - stable
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}

      - uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Run cargo check
        run: cargo check

  test:
    name: Test Rust version ${{ matrix.rust }} on OS ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest, macos-latest ]
        rust:
          - stable
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}

      - uses: taiki-e/install-action@just

      - uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - name: Run cargo test
        run: just test

  fmt:
    name: Rustfmt
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}
          components: rustfmt

      - name: Run cargo fmt
        run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}
          components: clippy

      - uses: taiki-e/install-action@just

      - name: Run cargo clippy
        run: just lint

  shear:
    name: Check for unused dependencies
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ matrix.rust }}

      - name: Install cargo-binstall
        uses: cargo-bins/cargo-binstall@main

      - name: Install cargo-shear
        run: cargo binstall --no-confirm cargo-shear

      - name: Run cargo shear
        run: cargo shear

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Install toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy

      - uses: actions/cache@v5
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-

      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-tarpaulin,just

      - name: Run cargo-tarpaulin
        run: just coverage

      - name: Upload to codecov.io
        uses: codecov/codecov-action@v6
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          fail_ci_if_error: false
          verbose: true