Skip to content

Commit 1017a9a

Browse files
committed
setup uv first
1 parent 5afec52 commit 1017a9a

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

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

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,35 @@ runs:
1919
sudo apt-get update
2020
sudo apt-get install -y --no-install-recommends libsystemd-dev
2121
fi
22-
- name: Set the OT_PYTHON env variable
23-
shell: bash
24-
run: echo "OT_PYTHON=$(which python)" >> $GITHUB_ENV
25-
- name: If provided set the OT_VIRTUALENV_VERSION env variable
26-
shell : bash
27-
if: ${{ inputs.python-version != 'false' }}
28-
run: echo "OT_VIRTUALENV_VERSION=${{ inputs.python-version }}" >> $GITHUB_ENV
2922
- shell: bash
3023
run: npm install --global [email protected]
31-
- shell: bash
32-
run: $OT_PYTHON -m pip install --upgrade pip
33-
- shell: bash
34-
run: $OT_PYTHON -m pip install --user pipenv==2023.12.1
35-
- shell: bash
36-
run: $OT_PYTHON -m pip install --user virtualenv==20.30.0
37-
- shell: bash
38-
run: 'make -C ${{ inputs.project }} setup || make -C ${{ inputs.project }} setup'
24+
- uses: astral-sh/setup-uv@v7
25+
with:
26+
python-version: ${{ inputs.python-version != 'false' && inputs.python-version || '3.10' }}
27+
enable-cache: true
28+
cache-dependency-glob: '${{ inputs.project }}/uv.lock'
29+
- name: Setup Python Environment
30+
shell: bash
31+
run: |
32+
echo "::notice::Using UV for dependency management"
33+
START_TIME=$(date +%s)
34+
# Add linux extra if on Linux and project has linux optional dependency (for systemd-python in performance-metrics)
35+
LINUX_EXTRA=""
36+
if [[ "${OSTYPE}" =~ "linux" ]] || [[ "$(uname -s)" == "Linux" ]]; then
37+
# Check if project has linux optional dependency defined
38+
if [ -f "${{ inputs.project }}/pyproject.toml" ] && grep -q '\[project.optional-dependencies\]' "${{ inputs.project }}/pyproject.toml" && grep -A 5 '\[project.optional-dependencies\]' "${{ inputs.project }}/pyproject.toml" | grep -q 'linux'; then
39+
LINUX_EXTRA="--extra linux"
40+
fi
41+
fi
42+
if [ -f "${{ inputs.project }}/uv.lock" ]; then
43+
cd ${{ inputs.project }} && uv sync --frozen --extra dev $LINUX_EXTRA
44+
elif [ -f "${{ inputs.project }}/pyproject.toml" ]; then
45+
cd ${{ inputs.project }} && uv sync --extra dev $LINUX_EXTRA
46+
# Verify dev dependencies are installed
47+
uv pip list | grep -E "(mypy|pytest|black)" || echo "Warning: Dev dependencies may not be installed"
48+
else
49+
make -C ${{ inputs.project }} setup
50+
fi
51+
END_TIME=$(date +%s)
52+
DURATION=$((END_TIME - START_TIME))
53+
echo "::notice::UV setup completed in ${DURATION} seconds"

.github/workflows/api-test-lint-deploy.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ jobs:
144144
- uses: 'actions/setup-python@v4'
145145
with:
146146
python-version: '3.10'
147+
- uses: astral-sh/setup-uv@v7
148+
with:
149+
python-version: '3.10'
150+
enable-cache: true
147151
- name: Set up package-testing
148152
id: setup
149153
if: ${{ matrix.os != 'windows-2022' }}

0 commit comments

Comments
 (0)