veils 0.1.2

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

on:
  push:
    branches: [ main ]
    paths:
      - "python/*.py"
      - "scripts/*.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

  python-rust-comparison:
    name: Python-Rust Compatibility Test
    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@v3

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

    - name: Build comparison container
      run: docker build -f docker/python_rust_comparison.Dockerfile -t veils-comparison .

    - name: Run Python-Rust comparison tests
      run: docker run --rm -v $(pwd):/workspace -w /workspace veils-comparison

    - name: Upload comparison results
      uses: actions/upload-artifact@v4
      if: always()
      with:
        name: python-rust-comparison-results
        path: final_comparison_results.json

  benchmark:
    name: Performance Benchmark
    runs-on: ubuntu-latest
    needs: python-rust-comparison
    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: python-rust-comparison
    container:
      image: rust:${{ vars.RUST_VERSION }}
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - 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: 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 }}