Skip to content

Commit 0c187b8

Browse files
authored
Migrate to uv (#468)
* migrate to uv switch from poetry to uv build tool
1 parent 9eb3c8e commit 0c187b8

File tree

14 files changed

+4802
-6450
lines changed

14 files changed

+4802
-6450
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ updates:
1818
workflows-dependencies:
1919
patterns:
2020
- "*"
21-
- package-ecosystem: "pip"
21+
- package-ecosystem: "uv"
2222
directory: "/"
2323
schedule:
2424
interval: "monthly"
25-
versioning-strategy: lockfile-only
26-
allow:
27-
- dependency-type: "all"
2825
open-pull-requests-limit: 99
2926
groups:
30-
poetry-dependencies:
27+
python-dependencies:
3128
patterns:
3229
- "*"

.github/workflows/constraints.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
pip==24.3
2-
nox==2024.10.9
3-
nox-poetry==1.0.3
4-
poetry==2.0.1
5-
virtualenv==20.28.1
1+
nox==2025.11.12
2+
uv==0.9.10

.github/workflows/docs.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,27 @@ jobs:
2828
- name: Check out the repository
2929
uses: actions/checkout@v4
3030

31-
- name: Install Poetry
31+
- name: Get uv version from constraints
32+
id: uv-version
33+
shell: pwsh
3234
run: |
33-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry
34-
pipx inject poetry poetry-plugin-export
35-
poetry --version
35+
$UV_VERSION = (Get-Content .github/workflows/constraints.txt | Where-Object { $_ -match '^uv==' } | ForEach-Object { ($_ -split '==')[1] })
36+
echo "version=$UV_VERSION" >> $env:GITHUB_OUTPUT
3637
37-
- name: Set up Python
38-
uses: actions/setup-python@v5.3.0
38+
- name: Install uv
39+
uses: astral-sh/setup-uv@v7
3940
with:
41+
enable-cache: true
42+
version: "${{ steps.uv-version.outputs.version }}"
4043
python-version: "3.12"
41-
cache: "poetry"
4244

4345
- name: Install dependencies
4446
run: |
45-
poetry install --no-root
47+
uv sync --locked --only-dev
4648
4749
- name: Build doc with Sphinx
4850
run: |
49-
poetry run sphinx-build docs docs/_build
51+
uv run sphinx-build docs docs/_build
5052
5153
- name: Upload artifact
5254
uses: actions/upload-pages-artifact@v3

.github/workflows/pseudo-service-integration-test.yaml

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,51 +21,55 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
include:
24-
- { python: "3.11"}
25-
- { python: "3.12"}
26-
- { python: "3.13"}
24+
- { python: "3.11" }
25+
- { python: "3.12" }
26+
- { python: "3.13" }
2727
steps:
28-
- name: Checkout Repository
29-
uses: actions/checkout@v4
30-
- id: "auth"
31-
name: "Authenticate to Google Cloud"
32-
uses: "google-github-actions/auth@v2.1.3"
33-
with:
34-
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
35-
service_account: ${{ secrets.INTEGRATION_TEST_SA_EMAIL }}
36-
token_format: "access_token"
37-
- name: 'Set up Cloud SDK'
38-
uses: 'google-github-actions/setup-gcloud@v2'
39-
with:
40-
version: '>= 363.0.0'
41-
- name: Generate, mask, and output Google ID token as a secret
42-
id: get-id-token
43-
env:
44-
PRIVILEGED_SERVICE_ACCOUNT: ${{ secrets.INTEGRATION_TEST_PRIV_SA_EMAIL }}
45-
run: |
46-
# REQUIRED TO KEEP GH ACTIONS FOR LOGGING THE ID TOKEN
47-
# SEE: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-masking-a-generated-output-within-a-single-job
48-
pseudo_service_auth_token="$(gcloud auth print-identity-token --impersonate-service-account=$PRIVILEGED_SERVICE_ACCOUNT --audiences=$PSEUDO_SERVICE_URL --include-email)"
49-
echo "::add-mask::$pseudo_service_auth_token"
50-
echo "PSEUDO_SERVICE_AUTH_TOKEN=$pseudo_service_auth_token" >> "$GITHUB_OUTPUT"
51-
- name: Setup python
52-
uses: actions/setup-python@v5
53-
with:
54-
python-version: ${{ matrix.python }}
28+
- name: Checkout Repository
29+
uses: actions/checkout@v4
30+
- id: "auth"
31+
name: "Authenticate to Google Cloud"
32+
uses: "google-github-actions/auth@v2.1.3"
33+
with:
34+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
35+
service_account: ${{ secrets.INTEGRATION_TEST_SA_EMAIL }}
36+
token_format: "access_token"
37+
- name: "Set up Cloud SDK"
38+
uses: "google-github-actions/setup-gcloud@v2"
39+
with:
40+
version: ">= 363.0.0"
41+
- name: Generate, mask, and output Google ID token as a secret
42+
id: get-id-token
43+
env:
44+
PRIVILEGED_SERVICE_ACCOUNT: ${{ secrets.INTEGRATION_TEST_PRIV_SA_EMAIL }}
45+
run: |
46+
# REQUIRED TO KEEP GH ACTIONS FOR LOGGING THE ID TOKEN
47+
# SEE: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-masking-a-generated-output-within-a-single-job
48+
pseudo_service_auth_token="$(gcloud auth print-identity-token --impersonate-service-account=$PRIVILEGED_SERVICE_ACCOUNT --audiences=$PSEUDO_SERVICE_URL --include-email)"
49+
echo "::add-mask::$pseudo_service_auth_token"
50+
echo "PSEUDO_SERVICE_AUTH_TOKEN=$pseudo_service_auth_token" >> "$GITHUB_OUTPUT"
51+
- name: Setup python
52+
uses: actions/setup-python@v5
53+
with:
54+
python-version: ${{ matrix.python }}
5555

56-
- name: Install Poetry
57-
run: |
58-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry
59-
pipx inject poetry poetry-plugin-export
60-
poetry --version
56+
- name: Get uv version from constraints
57+
id: uv-version
58+
shell: pwsh
59+
run: |
60+
$UV_VERSION = (Get-Content .github/workflows/constraints.txt | Where-Object { $_ -match '^uv==' } | ForEach-Object { ($_ -split '==')[1] })
61+
echo "version=$UV_VERSION" >> $env:GITHUB_OUTPUT
6162
62-
- name: Install Nox
63-
run: |
64-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox
65-
pipx inject --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry
66-
nox --version
63+
- name: Install uv
64+
uses: astral-sh/setup-uv@v7
65+
with:
66+
enable-cache: true
67+
version: "${{ steps.uv-version.outputs.version }}"
68+
python-version: "${{ matrix.python }}"
6769

68-
- name: Integration test
69-
env:
70-
PSEUDO_SERVICE_AUTH_TOKEN: ${{ steps.get-id-token.outputs.PSEUDO_SERVICE_AUTH_TOKEN }}
71-
run: nox --python=${{ matrix.python }} --session tests -- tests/v1/integration
70+
- name: Integration test
71+
env:
72+
PSEUDO_SERVICE_AUTH_TOKEN: ${{ steps.get-id-token.outputs.PSEUDO_SERVICE_AUTH_TOKEN }}
73+
run: |
74+
uvx --constraints "${{ github.workspace }}/.github/workflows/constraints.txt" \
75+
nox --python="${{ matrix.python }}" --session tests -- tests/v1/integration

.github/workflows/release.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,19 @@ jobs:
2020
with:
2121
fetch-depth: 2
2222

23-
- name: Set up Python
24-
uses: actions/setup-python@v5.3.0
25-
with:
26-
python-version: "3.12"
27-
28-
- name: Upgrade pip
23+
- name: Get uv version from constraints
24+
id: uv-version
25+
shell: pwsh
2926
run: |
30-
pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip
31-
pip --version
27+
$UV_VERSION = (Get-Content .github/workflows/constraints.txt | Where-Object { $_ -match '^uv==' } | ForEach-Object { ($_ -split '==')[1] })
28+
echo "version=$UV_VERSION" >> $env:GITHUB_OUTPUT
3229
33-
- name: Install Poetry
34-
run: |
35-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry
36-
pipx inject poetry poetry-plugin-export
37-
poetry --version
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v7
32+
with:
33+
enable-cache: true
34+
version: "${{ steps.uv-version.outputs.version }}"
35+
python-version: "3.12"
3836

3937
- name: Check if there is a parent commit
4038
id: check-parent-commit
@@ -47,18 +45,18 @@ jobs:
4745
uses: salsify/action-detect-and-tag-new-version@v2.0.3
4846
with:
4947
version-command: |
50-
bash -o pipefail -c "poetry version | cut -f 2 -d' '"
48+
uv version --short
5149
5250
- name: Bump version for developmental release
5351
if: (!steps.check-version.outputs.tag)
5452
run: |
55-
poetry version patch &&
56-
version=$(poetry version | awk '{ print $2 }') &&
57-
poetry version $version.dev.$(date +%s)
53+
uv version --bump patch --frozen &&
54+
version=$(uv version --short) &&
55+
uv version $version.dev.$(date +%s) --no-sync
5856
5957
- name: Build package
6058
run: |
61-
poetry build --ansi
59+
uv build
6260
6361
- name: Publish package on PyPI
6462
if: steps.check-version.outputs.tag

.github/workflows/tests.yml

Lines changed: 26 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,19 @@ jobs:
4040
- name: Check out the repository
4141
uses: actions/checkout@v4
4242

43-
- name: Set up Python ${{ matrix.python }}
44-
uses: actions/setup-python@v5.3.0
45-
with:
46-
python-version: ${{ matrix.python }}
47-
48-
- name: Upgrade pip
49-
run: |
50-
pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip
51-
pip --version
52-
53-
54-
- name: Upgrade pip in virtual environments
55-
shell: python
56-
run: |
57-
import os
58-
import pip
59-
60-
with open(os.environ["GITHUB_ENV"], mode="a") as io:
61-
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
62-
- name: Install Poetry
43+
- name: Get uv version from constraints
44+
id: uv-version
45+
shell: pwsh
6346
run: |
64-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry
65-
pipx inject poetry poetry-plugin-export
66-
poetry --version
47+
$UV_VERSION = (Get-Content .github/workflows/constraints.txt | Where-Object { $_ -match '^uv==' } | ForEach-Object { ($_ -split '==')[1] })
48+
echo "version=$UV_VERSION" >> $env:GITHUB_OUTPUT
6749
68-
- name: Install Nox
69-
run: |
70-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox
71-
pipx inject --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry
72-
nox --version
50+
- name: Install uv
51+
uses: astral-sh/setup-uv@v7
52+
with:
53+
enable-cache: true
54+
version: "${{ steps.uv-version.outputs.version }}"
55+
python-version: "${{ matrix.python }}"
7356

7457
- name: Compute pre-commit cache key
7558
if: matrix.session == 'pre-commit'
@@ -98,7 +81,7 @@ jobs:
9881
9982
- name: Run Nox
10083
run: |
101-
nox --python=${{ matrix.python }}
84+
uvx --constraints "${{ github.workspace }}/.github/workflows/constraints.txt" nox --python="${{ matrix.python }}"
10285
10386
- name: Upload coverage data
10487
if: always() && matrix.session == 'tests'
@@ -124,24 +107,19 @@ jobs:
124107
with:
125108
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
126109

127-
- name: Set up Python
128-
uses: actions/setup-python@v5.3.0
129-
with:
130-
python-version: "3.13"
131-
- name: Upgrade pip
132-
run: |
133-
pip install -c ${{ github.workspace }}/.github/workflows/constraints.txt pip
134-
pip --version
135-
- name: Install Poetry
110+
- name: Get uv version from constraints
111+
id: uv-version
112+
shell: pwsh
136113
run: |
137-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" poetry
138-
pipx inject poetry poetry-plugin-export
139-
poetry --version
140-
- name: Install Nox
141-
run: |
142-
pipx install --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox
143-
pipx inject --pip-args "-c ${{ github.workspace }}/.github/workflows/constraints.txt" nox nox-poetry
144-
nox --version
114+
$UV_VERSION = (Get-Content .github/workflows/constraints.txt | Where-Object { $_ -match '^uv==' } | ForEach-Object { ($_ -split '==')[1] })
115+
echo "version=$UV_VERSION" >> $env:GITHUB_OUTPUT
116+
117+
- name: Install uv
118+
uses: astral-sh/setup-uv@v7
119+
with:
120+
enable-cache: true
121+
version: "${{ steps.uv-version.outputs.version }}"
122+
python-version: "3.11"
145123

146124
- name: Download coverage data
147125
uses: actions/download-artifact@v4
@@ -151,11 +129,11 @@ jobs:
151129

152130
- name: Combine coverage data and display human readable report
153131
run: |
154-
nox --session=coverage
132+
uvx --constraints "${{ github.workspace }}/.github/workflows/constraints.txt" nox --session=coverage
155133
156134
- name: Create coverage report
157135
run: |
158-
nox --session=coverage -- xml --omit="tests/*"
136+
uvx --constraints "${{ github.workspace }}/.github/workflows/constraints.txt" nox --session=coverage -- xml
159137
160138
# Need to fix coverage source paths for SonarCloud scanning in GitHub actions.
161139
# Replace root path with /github/workspace (mounted in docker container).

0 commit comments

Comments
 (0)