name: Tests

on:
  push:

env:
  CARGO_TERM_COLOR: always

jobs:
  build_and_test:
    name: Tests and Coverage
    runs-on: ubuntu-latest
    container:
      image: xd009642/tarpaulin:develop-nightly
      options: --security-opt seccomp=unconfined
    steps:
      - uses: actions/checkout@v4
      - uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
      - name: Generate code coverage
        run: |
          cargo tarpaulin --engine llvm --out lcov
      - name: Coveralls GitHub Action
        uses: coverallsapp/github-action@v2
        with:
          github-token: ${{ github.token }}
      - name: Install cargo-crap
        run: |
          cargo binstall cargo-crap --no-confirm || cargo install cargo-crap
      - name: Run CRAP analysis
        run: |
          cargo crap --lcov lcov.info --format github
