diff --git a/.github/workflows/install-and-test.yml b/.github/workflows/install-and-test.yml index 8e6be806..19a48de8 100644 --- a/.github/workflows/install-and-test.yml +++ b/.github/workflows/install-and-test.yml @@ -44,13 +44,29 @@ jobs: uses: actions/checkout@v4 - name: Set up Python 3.13 + id: setup-python uses: actions/setup-python@v6 with: python-version: 3.13 + cache: 'pip' - - name : Install uv (if applicable) + - name: Install uv (if applicable) if: matrix.package_manager == 'uv' uses: astral-sh/setup-uv@v7 + with: + enable-cache: true + + - name: Cache venv (uv only) + if: matrix.package_manager == 'uv' + id: cache-venv + uses: actions/cache@v4 + with: + path: .venv + key: venv-v1-${{ runner.os }}-${{ matrix.device }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('pyproject.toml') }} + restore-keys: | + venv-v1-${{ runner.os }}-${{ matrix.device }}-py${{ steps.setup-python.outputs.python-version }}- + + - name: Create virtual environment (pip GPU) if: matrix.package_manager == 'pip' && matrix.device == 'gpu' @@ -77,14 +93,19 @@ jobs: python -m pip install --group dev . - name: Setup environment with uv (if applicable) - if: matrix.package_manager == 'uv' + if: matrix.package_manager == 'uv' && steps.cache-venv.outputs.cache-hit != 'true' run: | uv venv --no-project - source .venv/bin/activate uv pip install torch --index-url ${{ matrix.torch_index }} uv pip install --group dev -e . - uv pip list - echo "$PWD/.venv/bin" >> $GITHUB_PATH + + - name: Add venv to PATH (uv) + if: matrix.package_manager == 'uv' + run: echo "$PWD/.venv/bin" >> $GITHUB_PATH + + - name: Debug installed packages + if: matrix.package_manager == 'uv' + run: uv pip list - name: Print torch version run: |