name: Download PyTest cache

description: Downloads the pytest cache to S3

inputs:
  cache_dir:
    description: Path to the pytest cache directory, relative to $GITHUB_WORKSPACE. This is where the merged cache will be placed.
    required: true
  job_identifier:
    description: Text that uniquely identifies a given job type within a workflow. All shards of a job should share the same job identifier.
    required: true
  s3_bucket:
    description: S3 bucket to download PyTest cache
    required: false
    default: "gha-artifacts"

runs:
  using: composite
  steps:
    - uses: nick-fields/retry@v3.0.0
      name: Setup dependencies
      with:
        shell: bash
        timeout_minutes: 5
        max_attempts: 5
        retry_wait_seconds: 30
        command: |
          set -eu
          python3 -m pip install boto3==1.35.42

    - name: Download the cache
      shell: bash
      env:
        CACHE_DIR: ${{ inputs.cache_dir }}
        JOB_IDENTIFIER: ${{ inputs.job_identifier }}
        REPO: ${{ github.repository }}
        BUCKET: ${{ inputs.s3_bucket }}
      run: |
        python3 .github/scripts/pytest_cache.py \
          --download \
          --cache_dir $GITHUB_WORKSPACE/$CACHE_DIR \
          --pr_identifier $GITHUB_REF \
          --job_identifier $JOB_IDENTIFIER \
          --temp_dir $RUNNER_TEMP \
          --repo $REPO \
          --bucket $BUCKET \
