tegdb 0.4.0

The name TegridyDB (short for TegDB) is inspired by the Tegridy Farm in South Park and tries to correct some of the wrong database implementations, such as null support, implicit conversion support, etc.
Documentation
name: TegDB CI/CD Pipeline

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  schedule:
    - cron: '0 0 * * *'  # Run every day at midnight for nightly tests

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Code quality and formatting checks
  code-quality:
    name: Code Quality & Formatting
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: stable
        override: true
        components: rustfmt, clippy
        profile: minimal
    
    - name: Check formatting
      run: cargo fmt --all -- --check
    
    - name: Run clippy
      run: cargo clippy --all-targets --all-features -- -D warnings
    
    - name: Check documentation
      run: cargo doc --no-deps --document-private-items

  # Comprehensive test suite using the new test script
  test:
    name: Comprehensive Test Suite
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        rust: [stable]

    steps:
    - uses: actions/checkout@v4.1.1

    - name: Setup Rust ${{ matrix.rust }}
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: ${{ matrix.rust }}
        override: true
        profile: minimal

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

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

    - name: Build with all features
      run: cargo build --all-features --verbose

    - name: Run comprehensive test suite
      run: ./run_all_tests.sh --ci --verbose
      shell: bash
      env:
        CI_MODE: true
        VERBOSE: true

    - name: Run additional unit tests
      run: cargo test --lib --all-features --verbose

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

  # Examples and demos
  examples:
    name: Examples & Demos
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: stable
        override: true
        profile: minimal
    
    - name: Cache cargo
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ubuntu-stable-cargo-examples-${{ hashFiles('**/Cargo.lock') }}
    
    - name: Run basic usage example
      run: cargo run --example simple_usage
    
    - name: Run comprehensive database test
      run: cargo run --example comprehensive_database_test
    
    - name: Run streaming API demo
      run: cargo run --example streaming_api_demo
    
    - name: Run arithmetic expressions example
      run: cargo run --example arithmetic_expressions
    
    - name: Run SQLite-like usage example
      run: cargo run --example sqlite_like_usage
    
    - name: Run IoT optimization demo
      run: cargo run --example iot_optimization_demo
    
    - name: Run planner demo
      run: cargo run --example planner_demo

  # Security and dependency checks
  security:
    name: Security & Dependency Audit
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: stable
        override: true
        profile: minimal
    
    - name: Install cargo-audit
      run: cargo install cargo-audit
    
    - name: Run security audit
      run: cargo audit
    
    - name: Check for outdated dependencies
      run: |
        cargo install cargo-outdated
        cargo outdated --exit-code 1 || echo "Some dependencies are outdated, but build continues"

  # Release preparation (only on main branch)
  release-check:
    name: Release Readiness
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main' && github.event_name == 'push'
    
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: stable
        override: true
        profile: minimal
    
    - name: Check if ready for release
      run: |
        echo "Checking release readiness..."
        
        # Check if version has been updated
        VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
        echo "Current version: $VERSION"
        
        # Run comprehensive test suite
        ./run_all_tests.sh --ci --verbose
        
        # Check documentation builds
        cargo doc --no-deps
        
        echo "✅ Release readiness check completed successfully!"

  # Coverage reporting
  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust nightly
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: nightly
        override: true
        components: llvm-tools-preview
        profile: minimal
    
    - name: Install cargo-llvm-cov
      run: cargo install cargo-llvm-cov
    
    - name: Generate code coverage
      run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
    
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v4
      with:
        file: lcov.info
        fail_ci_if_error: false

  # Performance tests (manual trigger only)
  performance:
    name: Performance Tests & Benchmarks
    runs-on: ubuntu-latest
    if: github.event_name == 'schedule' || contains(github.event.head_commit.message, '[bench]') || github.event.inputs.run_performance == 'true'
    
    steps:
    - uses: actions/checkout@v4.1.1
    
    - name: Setup Rust nightly
      uses: actions-rs/toolchain@v1.0.6
      with:
        toolchain: nightly
        override: true
        profile: minimal
    
    - name: Cache cargo
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ubuntu-nightly-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
    
    - name: Run performance tests
      run: ./run_performance_tests.sh --ci
    
    - name: Run benchmarks
      run: |
        echo "# TegDB Performance Benchmarks" > benchmarks.md
        echo "Generated on: $(date)" >> benchmarks.md
        echo "" >> benchmarks.md
        echo "## Database vs SQLite Comparison" >> benchmarks.md
        echo '```' >> benchmarks.md
        cargo bench --bench database_vs_sqlite_benchmark --features="dev" | tee -a benchmarks.md
        echo '```' >> benchmarks.md
        echo "" >> benchmarks.md
        echo "## Engine Performance" >> benchmarks.md
        echo '```' >> benchmarks.md
        cargo bench --bench engine_basic_benchmark | tee -a benchmarks.md
        echo '```' >> benchmarks.md
        echo "" >> benchmarks.md
        echo "## Query Planner Performance" >> benchmarks.md
        echo '```' >> benchmarks.md
        cargo bench --bench planner_optimization_benchmark --features="dev" | tee -a benchmarks.md
        echo '```' >> benchmarks.md
    
    - name: Upload benchmark results
      uses: actions/upload-artifact@v4.3.1
      with:
        name: benchmark-results-${{ github.sha }}
        path: |
          benchmarks.md
          performance-results/
        retention-days: 30