Skip to content

Commit bda4756

Browse files
committed
chore: Migrate to uv; upgrade to Python >= 3.12
Use `pip lock -e .[dev]` to generate `pylock.toml` . We still need requirements.txt for dependabot features. Add Python dependency CI as uv would ignore dependency conflicts. Bug: #297 Change-Id: I11257ed10d04f2c1a58180ca039d019d4db82699
1 parent 539ef6a commit bda4756

File tree

10 files changed

+1409
-68
lines changed

10 files changed

+1409
-68
lines changed

.github/workflows/black.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11"]
14+
python-version: ["3.12"]
1515
steps:
1616
- if: github.event_name != 'pull_request'
1717
uses: actions/checkout@v6
@@ -23,15 +23,17 @@ jobs:
2323
uses: actions/setup-python@v6
2424
with:
2525
python-version: ${{ matrix.python-version }}
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
- name: Setup venv
29+
run: |
30+
uv venv
2631
- name: Install dependencies
2732
run: |
28-
python -m pip install --upgrade pip
29-
pip install -r requirements.txt
30-
pip install -r requirements_dev.txt
31-
pip install -e .[dev]
33+
uv sync --group dev --locked
3234
- name: Formatting the code with Black
3335
run: |
34-
black $(git ls-files '*.py')
36+
uv run black $(git ls-files '*.py')
3537
- name: Git config
3638
run: |
3739
git config --local user.name "github-actions[bot]"
@@ -41,7 +43,7 @@ jobs:
4143
git diff HEAD || true
4244
- name: Git add
4345
run: |
44-
git add *
46+
git add .
4547
- name: Git commit & push
4648
run: |
4749
git diff-index --quiet HEAD || ( git commit -m "Format \"$(git show -s --format=%s)\" using Black" && git push )

.github/workflows/pylint.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11", "3.12"]
14+
python-version: ["3.12"]
1515
steps:
1616
- uses: actions/checkout@v6
1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
2126
- name: Install dependencies
2227
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements_dev.txt
26-
pip install -e .[dev]
28+
uv sync --group dev --locked
2729
- name: Analysing the code with Pylint
2830
run: |
29-
pylint $(git ls-files '*.py')
31+
uv run pylint $(git ls-files '*.py')

.github/workflows/pytest.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11", "3.12"]
14+
python-version: ["3.12"]
1515
steps:
1616
- uses: actions/checkout@v6
1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
2126
- name: Install dependencies
2227
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements_dev.txt
26-
pip install -e .[dev]
28+
uv sync --group dev --locked
2729
- name: Analysing the code with Pytest
2830
run: |
29-
pytest tests/pytest/
31+
uv run pytest tests/pytest/
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Sync dependency lock files
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
python-version: ["3.12"]
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v6
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v6
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
26+
- name: Check uv.lock is in-sync with pyproject.toml
27+
run: |
28+
uv lock --locked
29+
- name: Sync dependencies
30+
run: |
31+
uv export -o pylock.toml
32+
uv export --no-dev -o requirements.txt
33+
uv export --only-dev -o requirements_dev.txt
34+
- name: Git config
35+
run: |
36+
git config --local user.name "github-actions[bot]"
37+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
38+
- name: Git diff
39+
run: |
40+
git diff HEAD || true
41+
- name: Git add
42+
run: |
43+
git add .
44+
- name: Git commit & push
45+
run: |
46+
git diff-index --quiet HEAD || ( git commit --amend --no-edit && git push --force-with-lease )

.github/workflows/unittest.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: ["3.11", "3.12"]
14+
python-version: ["3.12"]
1515
steps:
1616
- uses: actions/checkout@v6
1717
- name: Set up Python ${{ matrix.python-version }}
1818
uses: actions/setup-python@v6
1919
with:
2020
python-version: ${{ matrix.python-version }}
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
- name: Setup venv
24+
run: |
25+
uv venv
2126
- name: Install dependencies
2227
run: |
23-
python -m pip install --upgrade pip
24-
pip install -r requirements.txt
25-
pip install -r requirements_dev.txt
26-
pip install -e .[dev]
28+
uv sync --group dev --locked
2729
- name: Analysing the code with Python unittest
2830
run: |
29-
python -m unittest $(git ls-files 'cog/tests/*.py')
30-
python -m unittest $(git ls-files 'tests/unittest/*.py')
31+
uv run python -m unittest $(git ls-files 'cog/tests/*.py')
32+
uv run python -m unittest $(git ls-files 'tests/unittest/*.py')

0 commit comments

Comments
 (0)