teleop 0.4.1

Teleoperate Rust Processes
Documentation
name: Build

on:
  workflow_call:
    inputs:
      rust_toolchain:
        required: true
        type: string
      rust_features:
        required: false
        type: string
        default: --all-features
      with_rustfmt:
        required: false
        type: boolean
        default: false
      with_audit:
        required: false
        type: boolean
        default: false
      with_clippy:
        required: false
        type: boolean
        default: false
      pre_build_script:
        required: false
        type: string

env:
  CARGO_TERM_COLOR: always

jobs:

  build:

    name: Rust MacOS ${{ inputs.rust_toolchain }} ${{ inputs.rust_features }}

    runs-on: macos-latest

    steps:

      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ inputs.rust_toolchain }}
          components: rustfmt, clippy

      - id: quickinstall
        name: Install cargo-quickinstall
        if: ${{ inputs.with_audit }}
        run: |
          cargo install cargo-quickinstall

      - id: install-capnproto
        name: Install capnproto
        run: brew install capnp

      - id: pre_build_script
        name: Pre build script
        if: ${{ inputs.pre_build_script }}
        run: ${{ inputs.pre_build_script }}

      - id: rustfmt
        name: Rust format
        if: ${{ inputs.with_rustfmt }}
        run: |
          cargo fmt --verbose --all -- --check
          echo "Rustfmt OK" >> "$GITHUB_STEP_SUMMARY"

      - id: audit
        name: Audit
        if: ${{ inputs.with_audit }}
        run: |
          cargo quickinstall cargo-audit
          cargo audit
          echo "Audit OK" >> "$GITHUB_STEP_SUMMARY"

      - id: clippy
        name: Clippy
        if: ${{ inputs.with_clippy }}
        run: |
          cargo clippy --all ${{ inputs.rust_features }} --all-targets -- -D warnings
          echo "Clippy OK" >> "$GITHUB_STEP_SUMMARY"

      - id: test
        name: Compile and run tests
        run: cargo test ${{ inputs.rust_features }} --verbose

      - id: examples
        name: Check examples
        run: |
          ./scripts/check_examples.sh