name: "setup"

description: "setup environment for rustfs"

inputs:
  rust-version:
    required: true
    default: "stable"
  cache-shared-key:
    required: true
    default: ""
  cache-save-if:
    required: true
    default: true

runs:
  using: "composite"
  steps:
    - name: Install system dependencies
      shell: bash
      run: |
        sudo apt update
        sudo apt install -y musl-tools build-essential lld libdbus-1-dev libwayland-dev libwebkit2gtk-4.1-dev libxdo-dev

    - uses: arduino/setup-protoc@v3
      with:
        version: "30.2"

    - uses: Nugine/setup-flatc@v1
      with:
        version: "24.3.25"

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

    - uses: Swatinem/rust-cache@v2
      with:
        cache-on-failure: true
        cache-all-crates: true
        shared-key: ${{ inputs.cache-shared-key }}
        save-if: ${{ inputs.cache-save-if }}

    - uses: mlugg/setup-zig@v1
    - uses: taiki-e/install-action@cargo-zigbuild
