rslife 0.2.13

A comprehensive Rust library for actuarial mortality table calculations and life insurance mathematics
Documentation
name: Coverage

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

env:
  CARGO_TERM_COLOR: always

jobs:
  coverage:
    name: Generate test coverage
    runs-on: ubuntu-latest

    steps:
      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev pkg-config

      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust nightly with required components
        uses: dtolnay/rust-toolchain@nightly
        with:
          components: llvm-tools-preview

      - name: Cache cargo registry and target directory
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target
          key: ${{ runner.os }}-cargo-coverage-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-coverage-
            ${{ runner.os }}-cargo-

      - name: Install grcov
        uses: taiki-e/install-action@v2
        with:
          tool: grcov

      - name: Build
        run: cargo build --verbose
        env:
          RUSTFLAGS: '-Cinstrument-coverage'
          RUSTDOCFLAGS: '-Cinstrument-coverage'

      - name: Run tests
        run: cargo test --all-features --verbose
        env:
          CARGO_INCREMENTAL: '0'
          RUSTFLAGS: '-Cinstrument-coverage'
          RUSTDOCFLAGS: '-Cinstrument-coverage'
          LLVM_PROFILE_FILE: 'cargo-test-%p-%m.profraw'

      - name: Generate coverage report
        run: |
          grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" --ignore '*/tests/*' -o coverage.lcov

      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v4
        with:
          files: coverage.lcov
          fail_ci_if_error: true
          flags: unittests
          verbose: true