axin 0.1.0

A Rust procedural macro library for function instrumentation
Documentation
name: CI

on:
  push:
    branches: [ master, dev ]
  pull_request:
    branches: [ master ]

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
          - 1.70.0  # MSRV (Minimum Supported Rust Version)
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@v1
      with:
        toolchain: ${{ matrix.rust }}

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

    - name: Check formatting
      if: matrix.rust == 'stable'
      run: cargo fmt --all -- --check

    - name: Run clippy
      if: matrix.rust == 'stable'
      run: cargo clippy --all-targets --all-features -- -D warnings -A clippy::uninlined_format_args

    - name: Build
      run: cargo build --verbose

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

    - name: Build examples
      run: |
        cargo build --examples --verbose

    - name: Run examples
      run: |
        cargo run --example 01_basic_prologue
        cargo run --example 02_entry_exit
        cargo run --example 03_decorators
        cargo run --example 04_combined_features
        cargo run --example 05_real_world

    - name: Test documentation
      if: matrix.rust == 'stable'
      run: cargo doc --no-deps --document-private-items

  coverage:
    name: Code Coverage
    runs-on: ubuntu-latest
    needs: test
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@v1
      with:
        toolchain: stable
        components: llvm-tools-preview

    - name: Install cargo-llvm-cov
      uses: taiki-e/install-action@cargo-llvm-cov

    - 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@v5
      with:
        files: lcov.info
        fail_ci_if_error: true
        token: ${{ secrets.CODECOV_TOKEN }}

  security:
    name: Security Audit
    runs-on: ubuntu-latest
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@v1
      with:
        toolchain: stable

    - name: Install cargo-audit
      run: cargo install cargo-audit

    - name: Run security audit
      run: cargo audit

  publish-dry-run:
    name: Publish Dry Run
    runs-on: ubuntu-latest
    needs: [test, security]
    
    steps:
    - name: Checkout code
      uses: actions/checkout@v4

    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@v1
      with:
        toolchain: stable

    - name: Publish dry run
      run: cargo publish --dry-run