Files
foxhunt/docs/testing/WAVE4_CICD_INTEGRATION.md
jgrusewski 7458f1be01 feat(wave12): E2E validation complete - 225-feature pipeline ready
 Validation Results:
- PPO training: 24.2s (1 epoch, 950 samples, dim=225)
- Feature extraction: 105μs/bar (9.5x faster than target)
- Model checkpoint: 293KB (147KB actor + 146KB critic)
- GPU memory: 145MB used (96.4% headroom)
- Zero dimension mismatches

📊 Success Criteria (5/5):
 Feature dimension = 225 (Wave C 201 + Wave D 24)
 Model state_dim = 225
 Training completed without errors
 Checkpoint saved successfully
 No dimension mismatch errors

📁 Training Data Ready:
- ES.FUT: 2.9MB, 180 days
- NQ.FUT: 4.4MB, 180 days
- 6E.FUT: 2.8MB, 180 days
- ZN.FUT: 65KB, 90 days (clean)

🚀 Next: Full production model retraining (4 models, ~10min GPU time)

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 22:48:04 +02:00

7.9 KiB

Wave 4 CI/CD Integration Guide

Version: 1.0 Date: 2025-10-22 Status: Production Ready Author: Agent W4-5 (Test Documentation Specialist)


Overview

This guide describes the CI/CD integration strategy for automated testing in the Foxhunt HFT Trading System.


1. GitHub Actions Workflow

Complete Workflow (.github/workflows/test.yml)

name: Test Suite

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

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  unit-tests:
    name: Unit Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo test --workspace --lib
      - run: cargo test --doc

  integration-tests:
    name: Integration Tests
    runs-on: ubuntu-latest
    services:
      postgres:
        image: timescaledb/timescaledb:latest-pg16
        env:
          POSTGRES_USER: foxhunt
          POSTGRES_PASSWORD: foxhunt_dev_password
          POSTGRES_DB: foxhunt
        ports:
          - 5432:5432
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

      redis:
        image: redis:7-alpine
        ports:
          - 6379:6379
        options: >-
          --health-cmd "redis-cli ping"
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Install SQLx CLI
        run: cargo install sqlx-cli --no-default-features --features postgres

      - name: Run migrations
        run: cargo sqlx migrate run
        env:
          DATABASE_URL: postgresql://foxhunt:foxhunt_dev_password@localhost:5432/foxhunt

      - name: Run integration tests
        run: cargo test --workspace --test "*"
        env:
          DATABASE_URL: postgresql://foxhunt:foxhunt_dev_password@localhost:5432/foxhunt
          REDIS_URL: redis://localhost:6379

  e2e-tests:
    name: E2E Tests
    runs-on: ubuntu-latest
    needs: [unit-tests, integration-tests]
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Start services
        run: docker-compose -f tests/docker/docker-compose.test.yml up -d

      - name: Wait for services
        run: |
          timeout 60 bash -c 'until docker-compose -f tests/docker/docker-compose.test.yml ps | grep healthy; do sleep 2; done'

      - name: Run E2E tests
        run: cargo test -p tli e2e:: -p foxhunt_e2e

      - name: Cleanup
        if: always()
        run: docker-compose -f tests/docker/docker-compose.test.yml down -v

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: taiki-e/install-action@cargo-llvm-cov

      - name: Generate coverage
        run: cargo llvm-cov --workspace --lcov --output-path lcov.info

      - name: Upload to Codecov
        uses: codecov/codecov-action@v4
        with:
          files: lcov.info
          fail_ci_if_error: false

  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
      - run: cargo clippy --workspace --all-targets -- -D warnings

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

2. Nightly Stress Tests (.github/workflows/nightly.yml)

name: Nightly Stress Tests

on:
  schedule:
    - cron: '0 2 * * *'  # 2 AM UTC daily
  workflow_dispatch:

jobs:
  stress-tests:
    name: Stress Tests
    runs-on: ubuntu-latest-8core
    timeout-minutes: 120
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Run stress tests
        run: cargo test --release --features stress-test
        env:
          RUST_LOG: info

  benchmarks:
    name: Performance Benchmarks
    runs-on: ubuntu-latest-8core
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2

      - name: Run benchmarks
        run: cargo bench --workspace

      - name: Upload benchmark results
        uses: actions/upload-artifact@v4
        with:
          name: benchmark-results
          path: target/criterion/

      - name: Compare with baseline
        run: |
          if [ -f baseline/bench_results.json ]; then
            cargo install criterion-compare
            criterion-compare baseline/bench_results.json target/criterion/
          fi

3. Pre-Commit Hooks (.git/hooks/pre-commit)

#!/bin/bash
set -e

echo "Running pre-commit checks..."

# Run fast unit tests
echo "Running unit tests..."
cargo test --lib --quiet

# Run clippy
echo "Running clippy..."
cargo clippy --workspace --all-targets --quiet -- -D warnings

# Run rustfmt
echo "Checking formatting..."
cargo fmt --all -- --check

echo "All pre-commit checks passed!"

Install with:

chmod +x .git/hooks/pre-commit

4. Pre-Push Hooks (.git/hooks/pre-push)

#!/bin/bash
set -e

echo "Running pre-push checks..."

# Run all tests
echo "Running all tests..."
cargo test --workspace

# Check documentation
echo "Checking documentation..."
cargo doc --no-deps --workspace

echo "All pre-push checks passed!"

5. Performance Regression Detection

Baseline Storage

# Store performance baseline
cargo bench --workspace -- --save-baseline main

# Compare against baseline
cargo bench --workspace -- --baseline main

# Fail if regression > 10%
cargo bench --workspace -- --baseline main --threshold 10

Automated Regression Alerts

# .github/workflows/performance.yml
- name: Check for regressions
  run: |
    cargo bench --workspace -- --baseline main > bench_output.txt
    if grep -q "regressed" bench_output.txt; then
      echo "::error::Performance regression detected!"
      exit 1
    fi

6. Coverage Reporting

Codecov Integration

# codecov.yml
coverage:
  status:
    project:
      default:
        target: 60%  # Wave 4 target
        threshold: 2%  # Allow 2% drop
    patch:
      default:
        target: 70%  # New code should be well-tested

ignore:
  - "tests/**"
  - "benches/**"
  - "**/tests/**"

7. Docker Compose for CI

# tests/docker/docker-compose.test.yml
version: '3.8'

services:
  postgres:
    image: timescaledb/timescaledb:latest-pg16
    environment:
      POSTGRES_USER: foxhunt
      POSTGRES_PASSWORD: foxhunt_test_password
      POSTGRES_DB: foxhunt_test
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U foxhunt"]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5

  vault:
    image: hashicorp/vault:latest
    environment:
      VAULT_DEV_ROOT_TOKEN_ID: foxhunt-test-root
      VAULT_DEV_LISTEN_ADDRESS: 0.0.0.0:8200
    ports:
      - "8200:8200"
    cap_add:
      - IPC_LOCK

8. Test Matrix Strategy

# .github/workflows/test-matrix.yml
strategy:
  matrix:
    os: [ubuntu-latest, macos-latest, windows-latest]
    rust: [stable, beta, nightly]
    exclude:
      - os: macos-latest
        rust: beta
      - os: windows-latest
        rust: nightly

runs-on: ${{ matrix.os }}

steps:
  - uses: dtolnay/rust-toolchain@${{ matrix.rust }}
  - run: cargo test --workspace

Last Updated: 2025-10-22