Skip to content

Commit b3070e4

Browse files
committed
modularly install uv
1 parent 2397acd commit b3070e4

File tree

3 files changed

+56
-27
lines changed

3 files changed

+56
-27
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Cache UV Packages'
2+
description: 'Caches UV package cache directory for faster dependency installation'
3+
inputs:
4+
lockfile-path:
5+
description: 'Path to uv.lock file (relative to repository root)'
6+
required: false
7+
default: ''
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Cache UV packages
12+
if: inputs.lockfile-path != ''
13+
uses: actions/cache@v4
14+
id: uv-cache
15+
with:
16+
path: |
17+
~/.cache/uv
18+
key: ${{ runner.os }}-uv-${{ hashFiles(inputs.lockfile-path) }}
19+
restore-keys: |
20+
${{ runner.os }}-uv-
21+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: 'Install UV'
2+
description: 'Installs uv package manager manually to avoid setup-uv action post-job cleanup issues'
3+
inputs:
4+
version:
5+
description: 'UV version to install (default: latest)'
6+
required: false
7+
default: ''
8+
runs:
9+
using: 'composite'
10+
steps:
11+
- name: Install uv
12+
shell: bash
13+
run: |
14+
# Install uv manually to avoid setup-uv's post-job cleanup issues
15+
# This gives us full control and avoids the cache directory cleanup bug
16+
if [ -n "${{ inputs.version }}" ]; then
17+
curl -LsSf https://astral.sh/uv/install.sh | UV_VERSION="${{ inputs.version }}" sh
18+
else
19+
curl -LsSf https://astral.sh/uv/install.sh | sh
20+
fi
21+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
22+

.github/actions/python/setup/action.yaml

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
description: "What Python version to use to create the project's virtual environment"
99
required: false
1010
default: "false"
11+
install-system-deps:
12+
description: 'Whether to install system dependencies (libsystemd-dev on Linux)'
13+
required: false
14+
default: 'true'
1115
outputs:
1216
start-time:
1317
description: 'Start time of the setup process (Unix timestamp)'
@@ -22,6 +26,7 @@ runs:
2226
using: 'composite'
2327
steps:
2428
- shell: bash
29+
if: inputs.install-system-deps == 'true'
2530
run: |
2631
if [[ "${OSTYPE}" =~ "linux" ]]; then
2732
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved
@@ -31,35 +36,16 @@ runs:
3136
fi
3237
- shell: bash
3338
run: npm install --global [email protected]
34-
- shell: bash
35-
id: check-lockfile
36-
run: |
37-
if [ -f "${{ inputs.project }}/uv.lock" ]; then
38-
echo "lockfile-exists=true" >> $GITHUB_OUTPUT
39-
echo "cache-glob=${{ inputs.project }}/uv.lock" >> $GITHUB_OUTPUT
40-
else
41-
echo "lockfile-exists=false" >> $GITHUB_OUTPUT
42-
echo "cache-glob=" >> $GITHUB_OUTPUT
43-
fi
44-
- name: Cache UV packages
45-
if: steps.check-lockfile.outputs.lockfile-exists == 'true'
46-
uses: actions/cache@v4
47-
id: uv-cache
48-
with:
49-
path: |
50-
~/.cache/uv
51-
key: ${{ runner.os }}-uv-${{ hashFiles(format('{0}/uv.lock', inputs.project)) }}
52-
restore-keys: |
53-
${{ runner.os }}-uv-
54-
- uses: astral-sh/setup-uv@v7
55-
id: setup-uv
56-
continue-on-error: true
39+
- name: Install UV
40+
uses: ./.github/actions/python/install-uv
41+
- name: Setup Python
42+
uses: actions/setup-python@v5
5743
with:
5844
python-version: ${{ inputs.python-version != 'false' && inputs.python-version || '3.10' }}
59-
# Disable setup-uv's built-in caching - we use actions/cache instead
60-
# setup-uv's post-job cleanup fails when cache directory doesn't exist,
61-
# so we use continue-on-error to prevent job failure
62-
enable-cache: false
45+
- name: Cache UV packages
46+
uses: ./.github/actions/python/cache-uv
47+
with:
48+
lockfile-path: ${{ inputs.project }}/uv.lock
6349
- name: Setup Python Environment
6450
id: setup-env
6551
shell: bash

0 commit comments

Comments
 (0)