name: e2e-cache freethread

on:
  pull_request:
    paths-ignore:
      - '**.md'
  push:
    branches:
      - main
      - releases/*
    paths-ignore:
      - '**.md'
  workflow_dispatch:

permissions:
  contents: read
jobs:
  python-pip-dependencies-caching:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
      - name: Install dependencies
        run: pip install numpy pandas requests

  python-pipenv-dependencies-caching:
    name: Test pipenv (Python ${{ matrix.python-version}}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-24.04-arm,
            ubuntu-22.04,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.1t, 3.13.2t, 3.13.5t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        id: cache-pipenv
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pipenv'
      - name: Install pipenv
        run: python -m pip install --upgrade pip pipenv
      - name: Install dependencies on Linux/macOS
        if: runner.os != 'Windows'
        run: |
          export PIPENV_PYTHON=$(which python)
          pipenv install requests
      - name: Install dependencies on Windows
        if: runner.os == 'Windows'
        run: |
          # Remove existing virtualenv if any
          python -m pipenv --rm || echo "No existing env"
          # Create fresh env using current Python
          python -m pipenv install --python $(python -c "import sys; print(sys.executable)") requests

  python-poetry-dependencies-caching:
    name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0, 3.13.1, 3.13.2]
    steps:
      - uses: actions/checkout@v6
      - name: Install poetry
        run: pipx install poetry
      - name: Init pyproject.toml
        run: mv ./__tests__/data/pyproject.toml .
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          freethreaded: true
          cache: 'poetry'
      - name: Install dependencies
        run: poetry install --no-root

  python-pip-dependencies-caching-path:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          cache-dependency-path: __tests__/data/requirements.txt
      - name: Install dependencies
        run: pip install numpy pandas requests

  python-pipenv-dependencies-caching-path:
    name: Test pipenv (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.1t, 3.13.2t, 3.13.5t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        id: cache-pipenv
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pipenv'
          cache-dependency-path: '**/pipenv-requirements.txt'
      - name: Install pipenv
        run: python -m pip install --upgrade pip pipenv
      - name: Install dependencies on Linux/macOS
        if: runner.os != 'Windows'
        run: |
          export PIPENV_PYTHON=$(which python)
          pipenv install requests
      - name: Install dependencies on Windows
        if: runner.os == 'Windows'
        run: |
          # Remove existing virtualenv if any
          python -m pipenv --rm || echo "No existing env"
          # Create fresh env using current Python
          python -m pipenv install --python $(python -c "import sys; print(sys.executable)") requests

  python-pip-dependencies-caching-with-pip-version:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          pip-version: '25.0.1'
      - name: Install dependencies
        run: pip install numpy pandas requests

  python-pip-dependencies-caching-path-with-pip-version:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          cache-dependency-path: __tests__/data/requirements.txt
          pip-version: '25.0.1'
      - name: Install dependencies
        run: pip install numpy pandas requests

  python-pip-dependencies-caching-with-pip-install:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          pip-install: numpy pandas requests

  python-pip-dependencies-caching-path-with-pip-install:
    name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }}, caching path)
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          [
            ubuntu-latest,
            ubuntu-22.04,
            ubuntu-24.04-arm,
            ubuntu-22.04-arm,
            windows-latest,
            macos-latest,
            macos-15-intel
          ]
        python-version: [3.13.0t, 3.13.1t, 3.13.2t]
    steps:
      - uses: actions/checkout@v6
      - name: Setup Python
        uses: ./
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          cache-dependency-path: __tests__/data/requirements.txt
          pip-install: numpy pandas requests
