fixed_analytics 2.0.1

Fixed-point mathematical functions. Accurate, deterministic, and panic free.
Documentation
name: CI

on:
  push:
    branches: [main, master]
  pull_request:
    branches: [main, master]
  schedule:
    - cron: '0 0 * * 0'

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: -Dwarnings

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        rust: [stable, beta]
        exclude:
          - os: windows-latest
            rust: beta
          - os: macos-latest
            rust: beta
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.rust }}
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --features std
      - run: cargo test --doc --features std

  no-std:
    name: no_std
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo check --no-default-features

  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all -- --check
      - run: cargo clippy --all-targets --features std -- -D warnings
      - run: cargo doc --no-deps --features std
        env:
          RUSTDOCFLAGS: -Dwarnings

  msrv:
    name: MSRV
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.88
      - uses: Swatinem/rust-cache@v2
      - run: cargo check --features std

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@cargo-tarpaulin
      - run: cargo tarpaulin --out xml --features std --exclude-files 'tools/*'
      - uses: codecov/codecov-action@v4
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: cobertura.xml
          fail_ci_if_error: false

  security:
    name: Security
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: rustsec/audit-check@v1.4.1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

  no-panic:
    name: Verify No Panics
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Check all pub fns are annotated
        run: |
          pub_fns=$(grep -r '^pub fn ' src/ops/*.rs | wc -l)
          annotations=$(grep -r 'no_panic::no_panic' src/ops/*.rs | wc -l)
          echo "pub fn count: $pub_fns"
          echo "no_panic annotations: $annotations"
          if [ "$pub_fns" -ne "$annotations" ]; then
            echo "::error::Not all public functions in src/ops/ have #[no_panic] annotation ($annotations/$pub_fns)"
            grep -n '^pub fn ' src/ops/*.rs
            exit 1
          fi

      - name: Build with no-panic verification
        run: cargo build --profile no-panic-check --features verify-no-panic --bin verify_no_panic

  bench-check:
    name: Benchmarks Compile
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo bench --no-run

  accuracy:
    name: Accuracy Gate
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install GMP and MPFR
        run: sudo apt-get update && sudo apt-get install -y libgmp-dev libmpfr-dev

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: tools/accuracy-bench

      - name: Fetch baseline from main
        run: |
          # For PRs: fetch baseline from the base branch (main)
          # For pushes to main: fetch baseline from the previous commit
          if [ "${{ github.event_name }}" = "pull_request" ]; then
            git fetch origin ${{ github.base_ref }}
            git show origin/${{ github.base_ref }}:tools/accuracy-bench/baseline.json > /tmp/baseline-from-main.json
          else
            git show HEAD~1:tools/accuracy-bench/baseline.json > /tmp/baseline-from-main.json || cp tools/accuracy-bench/baseline.json /tmp/baseline-from-main.json
          fi

      - name: Run accuracy benchmark
        working-directory: tools/accuracy-bench
        run: cargo run --release -- --baseline /tmp/baseline-from-main.json

      - name: Upload report
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: accuracy-report-${{ github.sha }}
          path: tools/accuracy-bench/reports/
          retention-days: 30