Skip to content

Commit d54abf4

Browse files
committed
RHOAIENG-17006: chore(pyproject.toml): migrate test dependencies from poetry to uv
1 parent 8a472fd commit d54abf4

10 files changed

+1174
-2160
lines changed

.github/workflows/build-notebooks-TEMPLATE.yaml

+13-22
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ jobs:
3939
TRIVY_VULNDB: "/home/runner/.local/share/containers/trivy_db"
4040
# Targets (and their folder) that should be scanned using FS instead of IMAGE scan due to resource constraints
4141
TRIVY_SCAN_FS_JSON: '{}'
42-
# Poetry version for use in running tests
43-
POETRY_VERSION: '2.0.0'
4442

4543
steps:
4644

@@ -315,33 +313,26 @@ jobs:
315313

316314
# region Pytest image tests
317315

318-
- name: Install poetry
319-
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
320-
run: pipx install poetry==${{ env.POETRY_VERSION }}
321-
env:
322-
PIPX_HOME: /home/runner/.local/pipx
323-
PIPX_BIN_DIR: /home/runner/.local/bin
324-
325-
- name: Check poetry is installed correctly
326-
run: poetry env info
327-
328-
- name: Set up Python
329-
id: setup-python
330-
uses: actions/setup-python@v5
316+
# https://github.com/astral-sh/setup-uv
317+
- name: Install the latest version of uv
318+
uses: astral-sh/setup-uv@v5
331319
with:
332-
python-version: '3.12'
333-
cache: 'poetry'
320+
version: "latest"
321+
python-version: "3.12"
322+
enable-cache: true
323+
cache-dependency-glob: "uv.lock"
324+
pyproject-file: "pyproject.toml"
334325

335-
- name: Configure poetry
336-
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
326+
- name: Check uv is installed correctly
327+
run: uv version
337328

338329
- name: Install deps
339-
run: poetry install --sync
330+
run: uv sync --locked
340331

341332
- name: Run Testcontainers container tests (in PyTest)
342333
run: |
343334
set -Eeuxo pipefail
344-
poetry run pytest --capture=fd tests/containers -m 'not openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
335+
uv run pytest --capture=fd tests/containers -m 'not openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
345336
env:
346337
DOCKER_HOST: "unix:///var/run/podman/podman.sock"
347338
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: "/var/run/podman/podman.sock"
@@ -511,7 +502,7 @@ jobs:
511502
if: ${{ steps.have-tests.outputs.tests == 'true' }}
512503
run: |
513504
set -Eeuxo pipefail
514-
poetry run pytest --capture=fd tests/containers -m 'openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
505+
uv run pytest --capture=fd tests/containers -m 'openshift' --image="${{ steps.calculated_vars.outputs.OUTPUT_IMAGE }}"
515506
env:
516507
# TODO(jdanek): this Testcontainers stuff should not be necessary but currently it has to be there
517508
DOCKER_HOST: "unix:///var/run/podman/podman.sock"

.github/workflows/code-quality.yaml

+12-35
Original file line numberDiff line numberDiff line change
@@ -31,49 +31,26 @@ jobs:
3131
3232
pytest-tests:
3333
runs-on: ubuntu-latest
34-
env:
35-
poetry_version: '1.8.3'
3634
steps:
3735
- uses: actions/checkout@v4
3836

39-
- name: Cache poetry in ~/.local
40-
uses: actions/cache/restore@v4
41-
id: cache-poetry-restore
37+
# https://github.com/astral-sh/setup-uv
38+
- name: Install the latest version of uv
39+
uses: astral-sh/setup-uv@v5
4240
with:
43-
path: ~/.local
44-
key: "${{ runner.os }}-local-${{ env.poetry_version }}"
45-
46-
- name: Install poetry
47-
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
48-
run: pipx install poetry==${{ env.poetry_version }}
49-
env:
50-
PIPX_HOME: /home/runner/.local/pipx
51-
PIPX_BIN_DIR: /home/runner/.local/bin
52-
53-
- name: Check poetry is installed correctly
54-
run: poetry env info
55-
56-
- name: Save cache
57-
if: steps.cache-poetry-restore.outputs.cache-hit != 'true'
58-
uses: actions/cache/save@v4
59-
with:
60-
path: ~/.local
61-
key: ${{ steps.cache-poetry-restore.outputs.cache-primary-key }}
62-
63-
- name: Set up Python
64-
id: setup-python
65-
uses: actions/setup-python@v5
66-
with:
67-
python-version: '3.12'
68-
cache: 'poetry'
41+
version: "latest"
42+
python-version: "3.12"
43+
enable-cache: true
44+
cache-dependency-glob: "uv.lock"
45+
pyproject-file: "pyproject.toml"
6946

70-
- name: Configure poetry
71-
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
47+
- name: Check uv is installed correctly
48+
run: uv version
7249

7350
- name: Install deps
74-
run: poetry install --sync
51+
run: uv sync --locked
7552

76-
- run: poetry run pytest
53+
- run: uv run pytest
7754

7855
code-static-analysis:
7956
runs-on: ubuntu-latest

.github/workflows/docs.yaml

+9-12
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,17 @@ jobs:
4242
path: ~/.local
4343
key: ${{ steps.cache-poetry-restore.outputs.cache-primary-key }}
4444

45-
- name: Set up Python
46-
id: setup-python
47-
uses: actions/setup-python@v5
45+
# https://github.com/astral-sh/setup-uv
46+
- name: Install the latest version of uv
47+
uses: astral-sh/setup-uv@v5
4848
with:
49-
python-version: '3.12'
50-
cache: 'poetry'
51-
52-
- name: Configure poetry
53-
run: poetry env use "${{ steps.setup-python.outputs.python-path }}"
54-
55-
- name: Install deps
56-
run: poetry install --sync
49+
version: "latest"
50+
python-version: "3.12"
51+
enable-cache: true
52+
cache-dependency-glob: "uv.lock"
53+
pyproject-file: "pyproject.toml"
5754

5855
- name: Run the release notes script
5956
run: |
6057
set -Eeuxo pipefail
61-
poetry run ci/package_versions.py | tee ${GITHUB_STEP_SUMMARY}
58+
uv run ci/package_versions.py | tee ${GITHUB_STEP_SUMMARY}

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -59,26 +59,24 @@ Note: To ensure the GitHub Action runs successfully, users must add a `GH_ACCESS
5959

6060
### Deploy & Test
6161

62-
#### Prepare Python + poetry + pytest env
62+
#### Prepare Python + uv + pytest env
6363

6464
```shell
6565
# Linux
6666
sudo dnf install python3.12
67-
pip install --user poetry
67+
pip install --user uv
6868
# MacOS
69-
brew install [email protected] poetry
69+
brew install [email protected] uv
7070

71-
poetry env use $(which python3.12)
72-
poetry config virtualenvs.in-project true
73-
poetry env info
74-
poetry install --sync
71+
uv venv --python $(which python3.12)
72+
uv sync --locked
7573
```
7674

7775
#### Running Python selftests in Pytest
7876
By completing configuration in previous section, you are able to run any tests that don't need to start a container using following command:
7977

8078
```
81-
poetry run pytest
79+
uv run pytest
8280
```
8381

8482
##### Container selftests
@@ -105,15 +103,15 @@ sudo dnf install podman
105103
systemctl --user start podman.service
106104
systemctl --user status podman.service
107105
systemctl --user status podman.socket
108-
DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock poetry run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
106+
DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock uv run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
109107
110108
# Mac OS
111109
brew install podman
112110
podman machine init
113111
podman machine set --rootful=false
114112
sudo podman-mac-helper install
115113
podman machine start
116-
poetry run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
114+
uv run pytest tests/containers -m 'not openshift' --image quay.io/opendatahub/workbench-images@sha256:e98d19df346e7abb1fa3053f6d41f0d1fa9bab39e49b4cb90b510ca33452c2e4
117115
```
118116

119117
When using lima on macOS, it might be useful to give yourself access to rootful podman socket

ci/cached-builds/konflux_generate_component_build_pipelines.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2424
Usage:
2525
26-
$ PYTHONPATH=. poetry run ci/cached-builds/konflux_generate_component_build_pipelines.py
26+
$ PYTHONPATH=. uv run ci/cached-builds/konflux_generate_component_build_pipelines.py
2727
"""
2828

2929

ci/cached-builds/konflux_generate_component_definitions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
This script is used to configure a Konflux Application with component definitions.
1111
We have very many components, and clicking them one by one in the UI is too inefficient.
1212
13-
$ poetry run ci/cached-builds/konflux_generate_component_definitions.py > konflux_components.yaml
13+
$ uv run ci/cached-builds/konflux_generate_component_definitions.py > konflux_components.yaml
1414
$ oc apply -f konflux_components.yaml
1515
1616
Open https://console.redhat.com/application-pipeline/workspaces/rhoai-ide-konflux/applications

0 commit comments

Comments
 (0)