veils 0.1.0

A high-performance Short-Time Fourier Transform (STFT) library with scipy.signal.ShortTimeFFT compatibility
Documentation
name: CI

on:
  push:
    branches: [ main ]
    paths:
      - "*.py"
      - "*.sh"
      - "src/*"
      - "Cargo.toml"
      - "Cargo.lock"
      - "docker/*"
      - ".github/workflows/ci.yml"
  pull_request:
    branches: [ main ]
  release:
    types: [published]

env:
  CARGO_TERM_COLOR: always

jobs:
  code-quality:
    name: Code Quality Checks
    runs-on: ubuntu-latest
    container:
      image: rust:${{ vars.RUST_VERSION }}

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

    - name: Install components
      run: rustup component add rustfmt && rustup component add clippy

    - name: Cache cargo registry
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}

    - name: Check formatting
      run: cargo fmt --all -- --check

    - name: Run clippy
      run: cargo clippy --all-targets --all-features -- -D warnings

  comprehensive-test:
    name: Comprehensive Test Suite
    runs-on: ubuntu-latest
    needs: code-quality
    container:
      image: rust:${{ vars.RUST_VERSION }}

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

    - name: Install components
      run: rustup component add rustfmt && rustup component add clippy

    - name: Cache cargo registry
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-comprehensive-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}

    - name: Build library
      run: cargo build --verbose

    - name: Run tests
      run: cargo test --verbose

    - name: Run integration tests
      run: cargo test --test integration_tests --verbose

    - name: Test with all features
      run: cargo test --all-features --verbose

    - name: Build documentation
      run: cargo doc --no-deps --all-features

  sanity-check:
    name: Sanity Check - Deterministic Results
    runs-on: ubuntu-latest
    needs: comprehensive-test
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v2

    - name: Cache Docker layers
      uses: actions/cache@v3
      with:
        path: /tmp/.buildx-cache
        key: ${{ runner.os }}-docker-${{ github.sha }}
        restore-keys: |
          ${{ runner.os }}-docker-

    - name: Generate test data using Python container
      run: |
        echo "Building Python container for data generation..."
        docker build -f docker/py.Dockerfile -t veils-python .
        
        echo "Generating test data..."
        mkdir -p comparison_results
        docker run --rm -v ${{ github.workspace }}/comparison_results:/workspace/comparison_results veils-python python run_full_comparison_docker.py --generate-data

    - name: Build and run Rust sanity checks
      run: |
        echo "Building Rust container..."
        docker build -f docker/rust.Dockerfile -t veils-rust .
        
        echo "Running Rust sanity checks..."
        docker run --rm -v ${{ github.workspace }}/comparison_results:/workspace/comparison_results veils-rust

  benchmark:
    name: Performance Benchmark
    runs-on: ubuntu-latest
    needs: sanity-check
    container:
      image: rust:${{ vars.RUST_VERSION }}
    if: github.event_name == 'push' && github.ref == 'refs/heads/main'
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install components
      run: rustup component add rustfmt && rustup component add clippy

    - name: Cache cargo
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-bench-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}

    - name: Run benchmarks
      run: cargo test --release -- --bench

  publish-check:
    name: Publish Check
    runs-on: ubuntu-latest
    needs: sanity-check
    container:
      image: rust:${{ vars.RUST_VERSION }}
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install components
      run: rustup component add rustfmt && rustup component add clippy

    - name: Cache cargo
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-publish-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}

    - name: Check if crate can be published
      run: cargo publish --dry-run

    - name: Verify package contents
      run: |
        cargo package --list
        echo "Checking package size..."
        cargo package 2>&1 | grep "Packaged"

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: publish-check
    container:
      image: rust:${{ vars.RUST_VERSION }}
    if: github.event_name == 'release'
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install components
      run: rustup component add rustfmt && rustup component add clippy

    - name: Cache cargo
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-publish-${{ hashFiles('**/Cargo.toml') }}-${{ hashFiles('**/Cargo.lock') }}

    - name: Publish to crates.io
      run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}