growthbook-rust 0.2.1

Official Growthbook Rust SDK
Documentation
name: Build, Format and Test

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

jobs:
  build_and_test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        toolchain: ["1.75.0", "stable"] # Test across specific Rust versions: MSRV, stable, and beta

    steps:
    - uses: actions/checkout@v4
    
    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@master
      with:
        toolchain: ${{ matrix.toolchain }}
        components: rustfmt, clippy
        
    - uses: swatinem/rust-cache@v2

    - name: Cargo Build
      # --locked validates Cargo.lock is in sync and, on the MSRV toolchain,
      # fails loudly if the lockfile is ever regenerated into a format 1.75
      # can't parse (e.g. lockfile v4) instead of silently drifting.
      run: cargo build --verbose --locked

    - name: Cargo Test
      run: cargo test --verbose --locked

    - name: Cargo fmt
      if: matrix.toolchain == 'stable' # Only run fmt on stable toolchain
      run: cargo fmt --all -- --check

    - name: Cargo Clippy
      if: matrix.toolchain == 'stable' # Only run clippy on stable toolchain
      run: cargo clippy -- -D warnings # Treat warnings as errors

  corpus_freshness:
    # Drift check between tests/all_cases.json and the JS SDK's cases.json.
    # Fails the build on any "missing" or body-"drift" case not listed in
    # tests/scripts/corpus_skiplist.json. Extras (Rust's local additions) are
    # reported but never fail.
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: "3.13"
    - name: Check corpus freshness vs JS SDK
      run: python3 tests/scripts/check_corpus_freshness.py