From b3954536d1891d1741bd1cf9366d9e6f359835ee Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 11 Apr 2024 12:35:56 +0200 Subject: [PATCH 1/2] :sparkles: Use uv for python package installation uv is much faster than pip by itself. TODO: cache (built) wheels. --- action.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 171fdc1..841b4c1 100644 --- a/action.yml +++ b/action.yml @@ -100,11 +100,16 @@ runs: cache: 'pip' cache-dependency-path: '${{ steps.requirements_path.outputs.requirements_dir_prefix }}requirements/*.txt' + - name: Install uv (pip alternative) + # Docs: https://github.com/astral-sh/uv?tab=readme-ov-file#getting-started + run: pip install uv + shell: bash + - name: Install backend dependencies run: | - pip install -r requirements/ci.txt \ - --use-pep517 \ - --use-feature=no-binary-enable-wheel-cache + uv pip install \ + --system \ + -r requirements/ci.txt shell: bash working-directory: ${{ inputs.working-directory }} From e67d665515cd8e3873683d2b742b0299445d6966 Mon Sep 17 00:00:00 2001 From: Sergei Maertens Date: Thu, 11 Apr 2024 18:17:51 +0200 Subject: [PATCH 2/2] :zap: Set up cache for uv UV has its own cache directory, where it stores built/downloaded wheels and other resolution information. --- action.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 841b4c1..e7a9fea 100644 --- a/action.yml +++ b/action.yml @@ -95,16 +95,36 @@ runs: shell: bash - uses: actions/setup-python@v5 + id: setup_python with: python-version: ${{ inputs.python-version }} - cache: 'pip' - cache-dependency-path: '${{ steps.requirements_path.outputs.requirements_dir_prefix }}requirements/*.txt' - name: Install uv (pip alternative) + id: setup_uv # Docs: https://github.com/astral-sh/uv?tab=readme-ov-file#getting-started - run: pip install uv + run: | + pip install uv + # calculate cache parameters + + cache_dependency_path="${{ steps.requirements_path.outputs.requirements_dir_prefix }}requirements/*.txt" + + ubuntu_version=$(lsb_release -rs) + restore_key="uv-${{ runner.os }}-Ubuntu-${ubuntu_version}-python-${{ steps.setup_python.outputs.python-version }}" + + echo "uv_cache_dir=$(uv cache dir)" >> "$GITHUB_OUTPUT" + echo "cache_dependency_path=${cache_dependency_path}" >> "$GITHUB_OUTPUT" + echo "cache_restore_key=${restore_key}" >> "$GITHUB_OUTPUT" shell: bash + - name: (Restore) uv cache + uses: actions/cache@v4 + with: + path: ${{ steps.setup_uv.outputs.uv_cache_dir }} + key: ${{ steps.setup_uv.outputs.cache_restore_key }}-${{ hashFiles(steps.setup_uv.outputs.cache_dependency_path) }} + restore-keys: | + ${{ steps.setup_uv.outputs.cache_restore_key }}- + save-always: 'true' + - name: Install backend dependencies run: | uv pip install \