graph_d 1.3.2

A native graph database implementation in Rust with built-in JSON support and SQLite-like simplicity
Documentation
# ═══════════════════════════════════════════════════════════════════════════════
# CI/CD Pipeline for graph_d - Optimized for Speed
# ═══════════════════════════════════════════════════════════════════════════════
# Satisfies: RT-4 (Code quality MUST be continuously validated)
# Satisfies: RT-10 (CI validates all platforms and security)
# Satisfies: RT-3 (Conventional commit validation)
# Satisfies: O3 (CI/CD pipeline with automated testing)
# ═══════════════════════════════════════════════════════════════════════════════

name: CI

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  # Speed up cargo
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 10
  RUSTUP_MAX_RETRIES: 10

jobs:
  # ═══════════════════════════════════════════════════════════════════════════════
  # Fast Quality Gates - Run in parallel, no dependencies
  # ═══════════════════════════════════════════════════════════════════════════════

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
      - run: cargo clippy --all-targets --all-features -- -D warnings

  docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: -D warnings

  security:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      # Use cached binary install instead of cargo install
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-audit
      - run: cargo audit

  # ═══════════════════════════════════════════════════════════════════════════════
  # Cross-Platform Tests - Run in parallel
  # ═══════════════════════════════════════════════════════════════════════════════

  test:
    name: Test (${{ matrix.os }})
    strategy:
      fail-fast: false
      matrix:
        include:
          # Ubuntu - fastest, run full tests
          - os: ubuntu-latest
            run-doc-tests: true
          # macOS - medium speed
          - os: macos-latest
            run-doc-tests: false
          # Windows - slowest, skip doc tests to save time
          - os: windows-latest
            run-doc-tests: false
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
          # Separate cache per OS for better hit rate
          prefix-key: "v1-rust"

      - name: Run tests
        run: cargo test --all-features

      - name: Run doc tests
        if: matrix.run-doc-tests
        run: cargo test --doc

  # ═══════════════════════════════════════════════════════════════════════════════
  # MSRV - Check only, skip full tests for speed
  # ═══════════════════════════════════════════════════════════════════════════════

  msrv:
    name: MSRV (1.92)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@1.92.0
      - uses: Swatinem/rust-cache@v2
        with:
          prefix-key: "v1-msrv"
      # Just check compilation, skip tests for speed
      - run: cargo check --all-features

  # ═══════════════════════════════════════════════════════════════════════════════
  # Commit Lint - Only on PRs
  # ═══════════════════════════════════════════════════════════════════════════════

  commitlint:
    name: Commit Lint
    runs-on: ubuntu-latest
    if: github.event_name == 'pull_request'
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'
      - run: npm install -g @commitlint/cli @commitlint/config-conventional
      - run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

  # ═══════════════════════════════════════════════════════════════════════════════
  # Code Coverage - Only on Ubuntu, uses cached tool
  # ═══════════════════════════════════════════════════════════════════════════════

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    needs: [test]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: llvm-tools-preview
      - uses: Swatinem/rust-cache@v2
      # Use cached binary install
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-llvm-cov
      - run: cargo llvm-cov --all-features --lcov --output-path lcov.info
      - uses: codecov/codecov-action@v4
        with:
          files: lcov.info
          fail_ci_if_error: false

  # ═══════════════════════════════════════════════════════════════════════════════
  # Memory Limits Validation - GAP-6
  # Satisfies: B3 (≤1GB memory for 1M docs), RT-5 (Memory within bounds)
  # ═══════════════════════════════════════════════════════════════════════════════

  memory-check:
    name: Memory Limits
    runs-on: ubuntu-latest
    needs: [test]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Run memory limit tests
        # Satisfies: RT-5 (Memory usage MUST stay within bounds)
        run: |
          cargo test --release --test memory_limits -- --nocapture 2>&1 | tee memory_check.txt || true
          echo "Memory limit tests completed"

      - name: Check memory constraints
        run: |
          # Verify memory usage is within bounds
          if grep -q "MEMORY_LIMIT_EXCEEDED" memory_check.txt; then
            echo "❌ Memory limit exceeded!"
            exit 1
          fi
          echo "✅ Memory usage within bounds"

      - name: Upload memory report
        uses: actions/upload-artifact@v4
        with:
          name: memory-report
          path: memory_check.txt
          retention-days: 7

  # ═══════════════════════════════════════════════════════════════════════════════
  # CI Summary - Fast check that all required jobs passed
  # ═══════════════════════════════════════════════════════════════════════════════

  ci-success:
    name: CI Success
    needs: [fmt, clippy, test, msrv, docs, security]
    runs-on: ubuntu-latest
    if: always()
    steps:
      - name: Check all jobs
        run: |
          if [[ "${{ needs.fmt.result }}" != "success" ]] || \
             [[ "${{ needs.clippy.result }}" != "success" ]] || \
             [[ "${{ needs.test.result }}" != "success" ]] || \
             [[ "${{ needs.msrv.result }}" != "success" ]] || \
             [[ "${{ needs.docs.result }}" != "success" ]] || \
             [[ "${{ needs.security.result }}" != "success" ]]; then
            echo "One or more jobs failed"
            exit 1
          fi
          echo "✅ All CI checks passed!"