bitcoinkernel-covenants 0.0.23

Safe Rust bindings to libbitcoinkernel with added covenant op_codes
Documentation
name: Rust CI

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  msrv-check:
    name: Build with MSRV
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - name: Install Rust MSRV
      uses: dtolnay/rust-toolchain@master
      with:
        # Set this to your MSRV as specified in Cargo.toml
        toolchain: 1.71.0

    - name: Install Boost library
      run: |
        sudo apt-get update
        sudo apt-get install -y libboost-all-dev

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2

    - name: Build with MSRV
      run: |
        # Ensure we're using the right version
        rustc --version
        # Build the project
        cargo build --all-features
 
    - name: Run tests with MSRV
      run: cargo test --all-features

  build:
    name: Build and Test
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust toolchain
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: rustfmt

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2

    - name: Install Boost library
      run: |
        sudo apt-get update
        sudo apt-get install -y libboost-all-dev

    - name: Build
      run: cargo build -vv

    - name: Build example binary
      run: |
        cd examples
        cargo build --verbose

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

    - name: Run tests
      run: cargo test -vv

    - name: Install Valgrind
      run: |
        sudo apt-get update
        sudo apt-get install -y valgrind

    - name: Run tests with Valgrind
      run: |
        find target/debug/deps -type f -executable -name "test-*" -not -name "*.so" -not -name "*.d" | xargs -I {} valgrind --leak-check=full --show-leak-kinds=all  --errors-for-leak-kinds=definite --suppressions=valgrind.supp --error-exitcode=1 {}

  windows-build:
    name: Build and Test on Windows
    runs-on: windows-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust toolchain
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: rustfmt

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2

    - name: Install Boost library
      run: |
        git clone https://github.com/microsoft/vcpkg.git
        cd vcpkg
        .\bootstrap-vcpkg.bat
        .\vcpkg install boost-multi-index:x64-windows-static boost-headers:x64-windows-static
        echo "VCPKG_ROOT=$env:GITHUB_WORKSPACE\vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append
        echo "$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows-static\lib" | Out-File -FilePath $env:GITHUB_PATH -Append

    - name: Set environment variables for static linking
      run: |
        echo "BOOST_ROOT=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows-static" | Out-File -FilePath $env:GITHUB_ENV -Append
        echo "BOOST_INCLUDEDIR=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows-static\include" | Out-File -FilePath $env:GITHUB_ENV -Append
        echo "BOOST_LIBRARYDIR=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows-static\lib" | Out-File -FilePath $env:GITHUB_ENV -Append

    - name: Run tests
      run: cargo test -vv

  linux-aarch64:
    name: Build and Test on Linux ARM64
    runs-on: ubuntu-24.04-arm

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust toolchain
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: rustfmt

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2

    - name: Install Boost library
      run: |
        sudo apt-get update
        sudo apt-get install -y libboost-all-dev

    - name: Build and test
      run: cargo test -vv

  macos-build:
    name: Build and Test on macOS
    runs-on: macos-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust toolchain
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: stable
        override: true
        components: rustfmt

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2

    - name: Install Boost library
      run: |
        brew install boost

    - name: Build and test
      run: cargo test -vv

  fuzzing:
    name: Check Fuzzing Setup
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust toolchain
      uses: actions-rs/toolchain@v1
      with:
        profile: minimal
        toolchain: nightly
        override: true
        targets: x86_64-unknown-linux-gnu

    - name: Install LLVM tools for sanitizers
      run: |
        sudo apt-get update
        sudo apt-get install -y llvm

    - name: Cache dependencies
      uses: Swatinem/rust-cache@v2
 
    - name: Install Boost library
      run: |
        sudo apt-get update
        sudo apt-get install -y libboost-all-dev
 
    - name: Install cargo-fuzz
      run: cargo install cargo-fuzz

    - name: Set up fuzzing directories
      run: |
        mkdir -p /tmp/rust_kernel_fuzz
        sudo mount -t tmpfs none /tmp/rust_kernel_fuzz || true
 
    - name: Build and run fuzzing with Address Sanitizer
      env:
        RUSTFLAGS: "-Zsanitizer=address"
        ASAN_OPTIONS: "detect_leaks=1"
      run: |
        # First compile the main crate with sanitizer flags
        cargo build --verbose
        # Now build and run the fuzzing targets with the same sanitizer flags
        cargo fuzz build fuzz_target_block
        cargo fuzz build fuzz_target_chainman
        cargo fuzz build fuzz_target_verify
        cargo fuzz run fuzz_target_verify -- -max_total_time=20
        cargo fuzz run fuzz_target_chainman -- -max_total_time=20
        cargo fuzz run fuzz_target_block -- -max_total_time=20