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 Windows ${{ inputs.rust_toolchain }} ${{ inputs.rust_features }}

    runs-on: windows-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: |
          curl -OL "https://capnproto.org/capnproto-c++-win32-1.3.0.zip"
          unzip capnproto-c++-win32-1.3.0.zip capnproto-tools-win32-1.3.0/capnp.exe
          "$pwd\capnproto-tools-win32-1.3.0" >> $env:GITHUB_PATH

      - 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
          "Rustfmt OK" >> $env:GITHUB_STEP_SUMMARY

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

      - id: clippy
        name: Clippy
        if: ${{ inputs.with_clippy }}
        run: |
          cargo clippy --all ${{ inputs.rust_features }} --all-targets -- -D warnings
          "Clippy OK" >> $env: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.ps1