name: 'Setup Go'
description: 'Setup Go and Development tools for running tests'
inputs:
  go-version:
    required: true
    description: Go version to setup.
  tools-bin:
    required: true
    description: Directory to installs tools to.
  tools-dir:
    required: true
    description: Directory that has the tool definitions.
runs:
  using: "composite"
  steps:
    - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
      with:
        go-version: ${{ inputs.go-version }}
        cache: true
        check-latest: true

    - name: Cache tools
      id: cache-tools
      uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
      with:
        path: ${{ inputs.tools-bin }}
        key: ${{ runner.os }}-go-${{ inputs.go-version }}-tools-${{ inputs.tools-dir }}-${{ inputs.tools-bin}}-${{ hashFiles('**/go.mod', '**/go.sum') }}

    - name: Install development tools
      if: steps.cache-tools.outputs.cache-hit != 'true'
      shell: bash
      run: |-
        ./scripts/install_tools.sh --tools-dir ${{ inputs.tools-dir }} --bin-dir ${{ inputs.tools-bin }}
