ibverbs-rs 0.4.1

Safe, ergonomic Rust bindings for the InfiniBand libibverbs API
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

permissions:
  contents: read
  packages: write

jobs:
  ci-build:
    runs-on: ubuntu-latest

    outputs:
      image_tag: ${{ steps.meta.outputs.version }}

    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v4

      - name: Log in to GHCR
        uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels)
        id: meta
        uses: docker/metadata-action@v6
        with:
          images: ghcr.io/tikitikitikidesuka/ibverbs-rs
          tags: |
            type=raw,value=dev
            type=sha

      - name: Build and push
        uses: docker/build-push-action@v7
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

  rust-check:
    name: Check, Clippy, Fmt
    runs-on: ubuntu-latest
    needs: ci-build

    container:
      image: ghcr.io/tikitikitikidesuka/ibverbs-rs:${{ needs.ci-build.outputs.image_tag }}
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v6
      - uses: actions/cache@v5
        id: cache
        with:
          path: .cargo-target-cache
          key: cargo-check-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: cargo-check-${{ runner.os }}-
      - name: Restore cargo cache
        run: |
          if [ -d .cargo-target-cache ]; then
            cp -r .cargo-target-cache/. /opt/cargo-target/
          fi
      - run: cargo fmt -- --check
      - run: cargo check --all-features
      - run: cargo clippy --all-features --no-deps
      - name: Update cargo cache
        if: steps.cache.outputs.cache-hit != 'true'
        run: |
          mkdir -p .cargo-target-cache/debug
          [ -d /opt/cargo-target/debug/.fingerprint ] && cp -r /opt/cargo-target/debug/.fingerprint .cargo-target-cache/debug/
          [ -d /opt/cargo-target/debug/incremental ] && cp -r /opt/cargo-target/debug/incremental .cargo-target-cache/debug/
          find /opt/cargo-target/debug -maxdepth 1 \( -name "ibverbs_rs*" -o -name "libibverbs_rs*" \) \
            | xargs -r cp -t .cargo-target-cache/debug/

  rust-test:
    name: Test
    runs-on: ubuntu-latest
    needs: [ci-build, rust-check]

    container:
      image: ghcr.io/tikitikitikidesuka/ibverbs-rs:${{ needs.ci-build.outputs.image_tag }}
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v6
      - uses: actions/cache@v5
        id: cache
        with:
          path: .cargo-target-cache
          key: cargo-test-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            cargo-test-${{ runner.os }}-
            cargo-check-${{ runner.os }}-
      - name: Restore cargo cache
        run: |
          if [ -d .cargo-target-cache ]; then
            cp -r .cargo-target-cache/. /opt/cargo-target/
          fi
      - run: cargo test --all-features
      - name: Update cargo cache
        if: steps.cache.outputs.cache-hit != 'true'
        run: |
          mkdir -p .cargo-target-cache/debug
          [ -d /opt/cargo-target/debug/.fingerprint ] && cp -r /opt/cargo-target/debug/.fingerprint .cargo-target-cache/debug/
          [ -d /opt/cargo-target/debug/incremental ] && cp -r /opt/cargo-target/debug/incremental .cargo-target-cache/debug/
          find /opt/cargo-target/debug -maxdepth 1 \( -name "ibverbs_rs*" -o -name "libibverbs_rs*" \) \
            | xargs -r cp -t .cargo-target-cache/debug/

  docs-build:
    name: Build docs
    runs-on: ubuntu-latest
    needs: ci-build

    container:
      image: ghcr.io/tikitikitikidesuka/ibverbs-rs:${{ needs.ci-build.outputs.image_tag }}
      credentials:
        username: ${{ github.actor }}
        password: ${{ secrets.GITHUB_TOKEN }}

    steps:
      - uses: actions/checkout@v6
      - uses: actions/cache@v5
        id: cache
        with:
          path: .cargo-target-cache
          key: cargo-doc-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
          restore-keys: |
            cargo-doc-${{ runner.os }}-
            cargo-test-${{ runner.os }}-
            cargo-check-${{ runner.os }}-
      - name: Restore cargo cache
        run: |
          if [ -d .cargo-target-cache ]; then
            cp -r .cargo-target-cache/. /opt/cargo-target/
          fi
      - run: cargo doc --no-deps --all-features
      - name: Update cargo cache
        if: steps.cache.outputs.cache-hit != 'true'
        run: |
          mkdir -p .cargo-target-cache/debug
          [ -d /opt/cargo-target/debug/.fingerprint ] && cp -r /opt/cargo-target/debug/.fingerprint .cargo-target-cache/debug/
          [ -d /opt/cargo-target/debug/incremental ] && cp -r /opt/cargo-target/debug/incremental .cargo-target-cache/debug/
          find /opt/cargo-target/debug -maxdepth 1 \( -name "ibverbs_rs*" -o -name "libibverbs_rs*" \) \
            | xargs -r cp -t .cargo-target-cache/debug/
      - run: echo '<meta http-equiv="refresh" content="0; url=ibverbs_rs/index.html">' > /opt/cargo-target/doc/index.html
      - uses: actions/upload-pages-artifact@v4
        with:
          path: /opt/cargo-target/doc

  docs-deploy:
    name: Deploy docs
    runs-on: ubuntu-latest
    needs: [docs-build, rust-test]
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deploy.outputs.page_url }}
    steps:
      - id: deploy
        uses: actions/deploy-pages@v4