closure-ffi 5.1.2

FFI utility for creating bare function pointers that invoke a closure
Documentation
name: Checks
on:
  push:
    branches: [dev]
  pull_request:
    branches-ignore: [master]

jobs:
  fmt:
    name: cargo fmt
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --check

  check:
    name: cargo clippy
    strategy:
      fail-fast: false
      matrix:
        features:
          - --no-default-features -F no_safe_jit
          - --no-default-features -F safe_jit,global_jit_alloc
          - --no-default-features -F std,safe_jit,global_jit_alloc
          - ""
          - -F proc_macros
          - -F tuple_trait,c_variadic,coverage
        include:
          - toolchain: stable
          - features: -F tuple_trait,c_variadic,coverage
            toolchain: nightly

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: RUSTFLAGS="-Dwarnings" cargo clippy --workspace --all-targets ${{ matrix.features }}

  doc:
    name: cargo doc
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@nightly
      - uses: Swatinem/rust-cache@v2
      - run: RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --no-deps -F proc_macros

  build-and-test-native:
    name: Build and test (native)
    strategy:
      fail-fast: false
      matrix:
        target:
          - target: x86_64-unknown-linux-gnu
            runner: ubuntu-latest
          - target: x86_64-pc-windows-msvc
            runner: windows-latest
          - target: x86_64-apple-darwin
            runner: macos-15-intel
          - target: i686-pc-windows-msvc
            runner: windows-latest
          - target: i686-unknown-linux-gnu
            runner: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            runner: ubuntu-24.04-arm
          - target: aarch64-apple-darwin
            runner: macos-latest
        features:
          - "-F proc_macros"
          - "-F tuple_trait,c_variadic,coverage"
          - "--no-default-features -F safe_jit,global_jit_alloc"
        include:
          - toolchain: stable
          # Enable nightly rust for the nightly feature
          - features: "-F tuple_trait,c_variadic,coverage"
            toolchain: nightly
    
    needs: [fmt, check] # don't bother running tests if cargo check/fmt doesn't pass
    runs-on: ${{ matrix.target.runner }}
    steps:
      - uses: actions/checkout@v4
      - name: Install gcc-multilib for i686 cross-compilation
        if: ${{ matrix.target.target == 'i686-unknown-linux-gnu' }}
        run: sudo apt-get update && sudo apt-get install -y gcc-multilib
      - name: Setup Rust
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}
          targets: ${{ matrix.target.target }}
      - uses: Swatinem/rust-cache@v2
      - name: Build and test (debug)
        id: test-debug
        run: cargo test --target ${{ matrix.target.target }} ${{ matrix.features }}
      - name: Build and test (release)
        if: ${{ success() || steps.test-debug.conclusion == 'failure' }}
        run: cargo test --target ${{ matrix.target.target }} --release ${{ matrix.features }}
  
  build-and-test-cross:
    name: Build and test (cross-rs)
    strategy:
      fail-fast: false
      matrix:
        target:
          - armv7-unknown-linux-gnueabi
          - armv7-unknown-linux-gnueabihf
          - thumbv7neon-unknown-linux-gnueabihf
        features:
          - "-F proc_macros"
          - "-F tuple_trait,c_variadic,coverage"
          - "--no-default-features -F safe_jit,global_jit_alloc"
        include:
          - nightly: ""
          # Enable nightly rust for the nightly feature
          - features: "-F tuple_trait,c_variadic,coverage"
            nightly: +nightly

    needs: [fmt, check]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup cargo binstall
        uses: cargo-bins/cargo-binstall@main
      - name: Install cargo cross 
        run: cargo binstall cross
      - name: Build and test (debug)
        id: test-debug
        run: cross ${{ matrix.nightly }} test --target ${{ matrix.target }} ${{ matrix.features }}
      - name: Build and test (release)
        if: ${{ success() || steps.test-debug.conclusion == 'failure' }}
        run: cross ${{ matrix.nightly }} test --target ${{ matrix.target }} ${{ matrix.features }}

  all_checks_pass:
    needs:
      - fmt
      - check
      - doc
      - build-and-test-native
      - build-and-test-cross
    runs-on: ubuntu-latest
    steps:
    - name: Decide whether the needed jobs succeeded or failed
      uses: re-actors/alls-green@release/v1
      with:
        jobs: ${{ toJSON(needs) }}