cascade-cli 0.1.152

Stacked diffs CLI for Bitbucket Server
Documentation
name: CI

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

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test Suite
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        rust: [stable, beta]
        exclude:
          # Only test beta on Ubuntu to reduce CI time
          - os: macos-latest
            rust: beta
          - os: windows-latest
            rust: beta

    steps:
    - uses: actions/checkout@v4

    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
      with:
        toolchain: ${{ matrix.rust }}
        components: rustfmt, clippy

    - name: Configure Git (Windows)
      if: matrix.os == 'windows-latest'
      run: |
        git config --global user.name "GitHub Actions"
        git config --global user.email "actions@github.com"
        git config --global init.defaultBranch main

    - name: Configure Git (Unix)
      if: matrix.os != 'windows-latest'
      run: |
        git config --global user.name "GitHub Actions"
        git config --global user.email "actions@github.com"
        git config --global init.defaultBranch main

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

    - name: Check formatting
      run: cargo fmt --all -- --check

    - name: Run clippy
      run: cargo clippy --all-targets --all-features -- -D warnings

    - name: Build
      run: cargo build --verbose

    - name: Run unit tests
      run: cargo test --lib --verbose

    - name: Build release binary for integration tests
      run: cargo build --release

    - name: Run integration tests
      run: cargo test --test '*' --verbose -- --test-threads=1

    - name: Test CLI basic functionality
      run: ./target/release/ca --help

    - name: Test force push functionality (Linux/macOS only)
      if: matrix.os != 'windows-latest'
      run: cargo test test_force_push --verbose

  security-audit:
    name: Security Audit
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
    - name: Install cargo-audit
      run: cargo install cargo-audit@0.22.1 --locked
    - name: Run security audit
      run: cargo audit

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable
      with:
        components: llvm-tools-preview

    - name: Install cargo-llvm-cov
      run: cargo install cargo-llvm-cov

    - name: Configure Git
      run: |
        git config --global user.name "GitHub Actions"
        git config --global user.email "actions@github.com"
        git config --global init.defaultBranch main

    - name: Build binary for coverage
      run: cargo build --release

    - 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@v3
      with:
        files: lcov.info
        fail_ci_if_error: false

  check-docs:
    name: Documentation
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@stable

    - name: Check documentation
      run: cargo doc --no-deps --document-private-items

    - name: Test documentation examples
      run: cargo test --doc

  minimum-supported-rust-version:
    name: MSRV
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: dtolnay/rust-toolchain@1.82.0  # Set your MSRV here

    - name: Configure Git
      run: |
        git config --global user.name "GitHub Actions"
        git config --global user.email "actions@github.com"
        git config --global init.defaultBranch main

    - name: Check MSRV
      run: cargo check

  build-status:
    name: Build Status
    runs-on: ubuntu-latest
    needs: [test, security-audit, coverage, check-docs]
    if: always()
    steps:
    - name: Successful build
      if: ${{ !(contains(needs.*.result, 'failure')) }}
      run: exit 0
    - name: Failing build
      if: ${{ contains(needs.*.result, 'failure') }}
      run: exit 1