ibapi 4.1.0

A Rust implementation of the Interactive Brokers TWS API, providing a reliable and user friendly interface for TWS and IB Gateway. Designed with a focus on simplicity and performance.
Documentation
name: CI

on:
  pull_request:
    branches:
      - main
      - v2-stable
  push:
    branches:
      - main
      - v2-stable

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1
  # Enable more efficient cargo builds
  CARGO_INCREMENTAL: 0
  CARGO_NET_RETRY: 10
  RUST_LOG: info

jobs:
  # Single job that runs all checks for each feature set
  ci:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        # One leg per genuinely distinct feature configuration. `default =
        # ["async"]` and cargo features are additive, so `--features sync` leaves
        # the async client enabled — it is NOT the sync-only build, which is why
        # the flags are spelled out per leg instead of interpolating a name.
        # See docs/rules/parity/feature-matrix.md.
        include:
          - name: async
            flags: ""
          - name: sync
            flags: "--no-default-features --features sync"
          - name: all-features
            flags: "--all-features"
    name: CI ${{ matrix.name }}

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

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.95.0
        with:
          components: rustfmt, clippy

      # Use Swatinem's Rust cache for better performance
      - name: Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.name }}
          cache-on-failure: true
          # Cache target directory for each feature set separately
          cache-targets: true
          # Clean cache if it gets too large
          cache-all-crates: true

      # Combine format check (run once per matrix to catch issues early)
      - name: Check formatting
        run: cargo fmt -- --check

      # Build with optimizations for faster subsequent steps
      - name: Build
        run: cargo build ${{ matrix.flags }}

      # Run clippy before tests to catch issues early
      - name: Run clippy
        run: cargo clippy --all-targets ${{ matrix.flags }} -- -D warnings

      # Run tests
      - name: Run tests
        run: cargo test ${{ matrix.flags }}

      # Build examples (only if previous steps pass)
      - name: Build examples
        run: cargo build --examples ${{ matrix.flags }}

      # Build documentation
      - name: Build documentation
        run: cargo doc --no-deps ${{ matrix.flags }}

      # Check that benches compile (if any exist)
      - name: Check benches compile
        run: cargo check --benches ${{ matrix.flags }} || true

  # Separate minimal job for basic checks that don't need feature matrix
  basic-checks:
    runs-on: ubuntu-latest
    name: Basic checks
    
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@1.95.0

      - name: Rust cache
        uses: Swatinem/rust-cache@v2
        with:
          key: basic-checks

      # Check that Cargo.toml is properly formatted and valid
      - name: Check Cargo.toml
        run: |
          cargo metadata --format-version 1 > /dev/null

      # Validate the docs/rules/ knowledge graph and its CLAUDE.md index
      - name: Check rules graph
        run: ./tools/check-rules-graph.sh
          
      # Audit dependencies for security vulnerabilities
      - name: Security audit
        run: |
          cargo install cargo-audit || true
          cargo audit || true