bellperson 0.27.0

zk-SNARK library
Documentation
name: CI

on:
  pull_request:
  push:
    branches:
      - master

# Cancel a job if there's a new one on the same branch started.
# Based on https://stackoverflow.com/questions/58895283/stop-already-running-workflow-job-in-github-actions/67223051#67223051
concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_INCREMENTAL: 0
  RUST_BACKTRACE: 1
  RUST_LOG: debug

jobs:
  check_clippy:
    runs-on: ubuntu-24.04
    name: Clippy
    steps:
      - uses: actions/checkout@v6
      - name: Install required packages
        run: |
          sudo apt-get update
          sudo apt-get install --no-install-recommends --yes libhwloc-dev ocl-icd-opencl-dev
      - name: Install cargo clippy
        run: rustup component add clippy
      - name: Run cargo clippy
        run: cargo clippy --all-targets --workspace -- -D warnings

  check_fmt:
    runs-on: ubuntu-24.04
    name: Checking fmt
    steps:
      - uses: actions/checkout@v6
      - name: Install cargo fmt
        run: rustup component add rustfmt
      - name: Run cargo fmt
        run: cargo fmt --all -- --check

  test_cpu:
    runs-on: ['self-hosted', 'linux', 'x64', '4xlarge']
    name: Test with CPU
    strategy:
      fail-fast: false
      matrix:
        cargo-args: ['--workspace', '--workspace --no-default-features', '--release -- --ignored']
    steps:
      - uses: actions/checkout@v6
      - name: Install required packages
        run: |
          sudo apt-get update
          sudo apt-get install --no-install-recommends --yes libhwloc-dev ocl-icd-opencl-dev
      # TODO: Remove this and other rust installation directives from jobs running
      # on self-hosted runners once rust is available on these machines by default
      - uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: 1.93.1
      - name: Test
        run: cargo test ${{ matrix.cargo-args }}
      - name: Show results (only for ignored tests)
        run: test -f aggregation.csv && cat aggregation.csv || true

  test_gpu:
    runs-on: ['self-hosted', 'linux', 'x64', '2xlarge+gpu']
    name: Test
    env:
      # Build the kernel only for the single architecture that is used on CI.
      # This should reduce the overall compile-time significantly.
      BELLMAN_CUDA_NVCC_ARGS: --fatbin --gpu-architecture=sm_75 --generate-code=arch=compute_75,code=sm_75
      # These are needed for SupraSeal only, but it shouldn't do any harm for
      # the other cases.
      CC: gcc-12
      CXX: g++-12
      NVCC_PREPEND_FLAGS: "-ccbin /usr/bin/g++-12"
    strategy:
      fail-fast: false
      matrix:
        include:
          - name: "Test OpenCL only"
            cargo-args: "--workspace --release --features opencl"
            framework: ""
          - name: "Test CUDA only"
            cargo-args: "--release --features cuda"
            framework: ""
          - name: "Test CUDA/OpenCL (CUDA at run-time)"
            cargo-args: "--release --features cuda,opencl"
            framework: cuda
          - name: "Test CUDA/OpenCL (OpenCL at run-time)"
            cargo-args: "--release --features cuda,opencl"
            framework: cuda
          - name: "Test SupraSeal"
            cargo-args: "--release --features cuda-supraseal"
            framework: ""
    steps:
      - uses: actions/checkout@v6
      # TODO: Move the driver installation to the AMI.
      # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-nvidia-driver.html
      # https://www.nvidia.com/en-us/drivers/
      - name: Install CUDA drivers
        run: |
          curl -L -o nvidia-driver-local-repo-ubuntu2404-570.148.08_1.0-1_amd64.deb https://us.download.nvidia.com/tesla/570.148.08/nvidia-driver-local-repo-ubuntu2404-570.148.08_1.0-1_amd64.deb
          sudo dpkg -i nvidia-driver-local-repo-ubuntu2404-570.148.08_1.0-1_amd64.deb
          sudo cp /var/nvidia-driver-local-repo-ubuntu2404-570.148.08/nvidia-driver-local-*-keyring.gpg /usr/share/keyrings/
          sudo apt-get update
          sudo apt-get install --no-install-recommends --yes cuda-drivers
          rm nvidia-driver-local-repo-ubuntu2404-570.148.08_1.0-1_amd64.deb
      - name: Load NVIDIA kernel modules and verify GPU
        run: |
          sudo modprobe nvidia
          sudo modprobe nvidia-uvm
          nvidia-smi || echo "WARNING: nvidia-smi failed, GPU may not be available"
      - name: Install required packages
        run: |
          sudo apt-get update
          sudo apt-get install --no-install-recommends --yes libhwloc-dev nvidia-cuda-toolkit ocl-icd-opencl-dev
      - uses: dtolnay/rust-toolchain@efa25f7f19611383d5b0ccf2d1c8914531636bf9
        with:
          toolchain: 1.93.1
      - name: Test ${{ matrix.framework }} with ${{ matrix.cargo-args }}
        run: BELLMAN_GPU_FRAMEWORK=${{ matrix.framework }} cargo test ${{ matrix.cargo-args }}