polytune 0.1.0

Maliciously-Secure Multi-Party Computation (MPC) Engine using Authenticated Garbling
Documentation
name: Pull Request Checks

# By using the pull_request event, the workflow is run on
# the merge commit before it is added to main. This ensures
# that the pipeline won't break after the merge.
on:
  pull_request:
    branches:
      - "main"

env:
  CARGO_TERM_COLOR: always
  RUST_LOG: info

jobs:
  lint:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
      - run: cargo fmt --check
      - run: cargo clippy --all-targets -F __bench -- -Dwarnings
      - name: Install cargo-machete
        uses: taiki-e/install-action@f3a27926ea13d7be3ee2f4cbb925883cf9442b56
        with:
          tool: cargo-machete@0.8.0 # install-action checks sha for the binary
      - name: Check for unused dependencies 
        run: cargo machete

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
      - run: cargo doc --no-deps

  # This job checks that we can build polytune with the msrv specified in the
  # Cargo.toml and that we *can't build* with one previous version.
  check-msrv:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install taplo for extracting rust-version
        uses: taiki-e/install-action@f3a27926ea13d7be3ee2f4cbb925883cf9442b56
        with:
          tool: taplo@0.10.0
      - run: |
          rust_version=$(taplo get -f Cargo.toml 'package.rust-version')
          prev_rust_version=$(echo "$rust_version" | awk -F'.' -v OFS='.' '{ $2 = $2 - 1; print }')
          echo "rust-version=$rust_version" >> $GITHUB_OUTPUT
          echo "prev-rust-version=$prev_rust_version" >> $GITHUB_OUTPUT
        id: get-rust-version
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: ${{  steps.get-rust-version.outputs.rust-version }}
      - run: cargo build
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: ${{  steps.get-rust-version.outputs.prev-rust-version }}
      - run: sed --in-place '/^rust-version/d' Cargo.toml
      - run: cargo build
        id: build-prev-version
        continue-on-error: true
      - run: |
          if [[ "${{ steps.build-prev-version }}" == "success" ]]; then
            echo "::error::Build with previous of MSRV succeeded unexpectedly. Change rust-version in Cargo.toml"
            exit 1
          fi

  test-lib:
    strategy:
      matrix:
        runner:
          - ubuntu-latest
          - macos-latest
          - windows-latest
    runs-on: ${{ matrix.runner }}
    timeout-minutes: 15
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
      - run: cargo test --release

  test-examples:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    strategy:
      matrix:
        workspace-member:
          - http-multi-server-channels
          - http-single-server-channels
          - sql-integration
          - api-integration
    defaults:
      run:
        working-directory: examples/${{ matrix.workspace-member }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
      - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
        with:
          key: ${{ matrix.workspace-member }}
      - if: ${{ matrix.workspace-member == 'sql-integration' }}
        run: docker compose -f docker-compose.yml up -d
      - run: cargo test --release -- --nocapture

  test-wasm-example:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    defaults:
      run:
        working-directory: examples/wasm-http-channels
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b
        with:
          toolchain: stable
          targets: wasm32-unknown-unknown
      - uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0
      - name: Install wasm-pack
        uses: taiki-e/install-action@f3a27926ea13d7be3ee2f4cbb925883cf9442b56
        with:
          tool: wasm-pack@0.13.1 # install-action will download from github releases and verify the SHA of the binary
      - run: wasm-pack build --target web
        working-directory: ./examples/wasm-http-channels
        env:
          RUSTFLAGS: '--cfg getrandom_backend="wasm_js"'