From da92413c061e97b34de81aab1e91605238a08611 Mon Sep 17 00:00:00 2001 From: AtomHare <29772841+AtomHare@users.noreply.github.com> Date: Tue, 21 May 2024 12:41:35 +0200 Subject: [PATCH] Use uv instead of pip during tests While also using uv cache if the dependencies are the same in requirements and requirements-dev fix: Auto-detection of python version fix: Missed comment Fix suggestions --- .github/workflows/lintandformat.yml | 17 ++++++++++++----- .github/workflows/test.yml | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/lintandformat.yml b/.github/workflows/lintandformat.yml index de09171e68..dbd8b85edc 100644 --- a/.github/workflows/lintandformat.yml +++ b/.github/workflows/lintandformat.yml @@ -17,15 +17,22 @@ jobs: # Setup Python (faster than using Python container) - name: Setup Python uses: actions/setup-python@v5 + id: setup-python with: python-version: "3.11" - cache: "pip" + + - name: Cache uv folder + id: cache-uv + uses: actions/cache@v4 + with: + path: ~/.cache/uv + key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('requirements-common.txt', 'requirements-dev.txt') }} + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - pip install "fastapi[all]" + run: uv pip install --system -r requirements-dev.txt - name: Cache .ruff_cache folder id: ruff_cache diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81f612cfde..ed88a3d9c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,15 +38,22 @@ jobs: # Setup Python (faster than using Python container) - name: Setup Python uses: actions/setup-python@v5 + id: setup-python with: python-version: "3.11" - cache: "pip" + + - name: Cache uv folder + id: cache-uv + uses: actions/cache@v4 + with: + path: ~/.cache/uv + key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-uv-${{ hashFiles('requirements-common.txt', 'requirements-dev.txt') }} + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements-dev.txt - pip install "fastapi[all]" + run: uv pip install --system -r requirements-dev.txt - name: Cache .pytest_cache folder id: pytest_cache