Skip to content

Commit 2ab812e

Browse files
authored
Merge pull request #157 from myakove/move-to-uv
Use uv to manage the project
2 parents c2b6c2b + 9c862c8 commit 2ab812e

16 files changed

+1929
-1006
lines changed

.github/workflows/publish.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
1-
---
2-
name: PyPI Release
1+
name: "Publish"
32

43
on:
54
release:
6-
types:
7-
- created
5+
types: ["published"]
86

97
jobs:
10-
release:
8+
run:
9+
name: "Build and publish release"
1110
runs-on: ubuntu-latest
1211

13-
strategy:
14-
matrix:
15-
python-version: ["3.10"] # Use only one version for sdist
16-
1712
steps:
18-
- name: Set up Python
19-
uses: actions/setup-python@v2
13+
- uses: actions/checkout@v4
14+
15+
- name: Install uv
16+
uses: astral-sh/setup-uv@v6
2017
with:
21-
python-version: ${{ matrix.python-version }}
18+
enable-cache: true
19+
cache-dependency-glob: uv.lock
2220

23-
- name: Check out code
24-
uses: actions/checkout@v2
21+
- name: Set up Python
22+
run: uv python install 3.13
2523

26-
- name: Install dependencies
27-
run: pip install -r requirements.txt
24+
- name: Build
25+
run: uv build
2826

29-
- name: Build and publish
30-
env:
31-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
32-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
33-
run: |
34-
python setup.py sdist
35-
pip install twine
36-
twine upload dist/*
27+
- name: Publish
28+
run: uv publish -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }}

.github/workflows/test.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
name: rrmngmnt gatting
22
on:
3-
pull_request:
3+
pull_request:
44
jobs:
55
build:
66
name: Test
77
runs-on: ubuntu-latest
8-
strategy:
9-
matrix:
10-
python: ["3.8", "3.9", "3.10"]
8+
119
steps:
12-
- uses: actions/checkout@v2
13-
- uses: actions/setup-python@v2
14-
with:
15-
python-version: ${{ matrix.python }}
16-
- name: Install dependencies
17-
run: |
18-
pip install tox
19-
- name: Run linters
20-
run: tox -e pep8
21-
- name: Run unit tests
22-
run: tox -e py
10+
- uses: actions/checkout@v4
11+
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v6
14+
15+
- name: Install uv-tox
16+
run: uv tool install tox --with tox-uv
17+
- name: Run linters
18+
run: tox -e pep8
19+
- name: Run tests
20+
run: tox --skip-env=pep8

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Install
239239

240240
.. code:: sh
241241
242-
python setup.py devop
242+
pip install python-rrmngmnt
243243
244244
Test
245245
----

pyproject.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[build-system]
2+
requires = ["hatchling", "uv-dynamic-versioning"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "python-rrmngmnt"
7+
dynamic = ["version"]
8+
description = "Tool to manage remote systems and services"
9+
readme = "README.rst"
10+
license = { text = "GPL-2.0-only" }
11+
authors = [{ name = "Lukas Bednar", email = "[email protected]" }]
12+
keywords = ["remote", "resource", "service"]
13+
classifiers = [
14+
"Topic :: Utilities",
15+
"Intended Audience :: Developers",
16+
"Intended Audience :: Information Technology",
17+
"Operating System :: POSIX",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.9",
21+
"Programming Language :: Python :: 3.10",
22+
"Programming Language :: Python :: 3.11",
23+
"Programming Language :: Python :: 3.12",
24+
"Programming Language :: Python :: 3.13",
25+
]
26+
dependencies = ["paramiko", "netaddr", "six"]
27+
requires-python = ">=3.7"
28+
29+
[project.urls]
30+
Homepage = "https://github.com/rhevm-qe-automation/python-rrmngmnt"
31+
32+
33+
[tool.hatch.version]
34+
source = "uv-dynamic-versioning"
35+
36+
[tool.hatch.build.targets.wheel]
37+
packages = ["rrmngmnt"]
38+
39+
[dependency-groups]
40+
tests = [
41+
"attrs>=24.2.0",
42+
"pytest>=7.4.4",
43+
"pytest-cov>=4.1.0",
44+
"pytest-docker>=2.2.0",
45+
"pytest-xdist>=3.5.0",
46+
]

requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

test-requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/test_db.py

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
from rrmngmnt import Host, User
55
from rrmngmnt.db import Database
6-
from .common import FakeExecutorFactory
76

7+
from .common import FakeExecutorFactory
88

99
host_executor_factory = Host.executor_factory
1010

@@ -19,40 +19,38 @@ def fake_cmd_data(cmd_to_data, files=None):
1919

2020
class TestDb(object):
2121
data = {
22-
'which systemctl': (0, "", ""),
23-
'systemctl list-unit-files | grep -o ^[^.][^.]*.service | '
24-
'cut -d. -f1 | sort | uniq': (0, "postgresql\n", "",),
25-
'systemctl restart postgresql.service': (0, '', ''),
26-
'export PGPASSWORD=db_pass; psql -d db_name -U db_user '
27-
'-h localhost -R __RECORD_SEPARATOR__ -t -A -c '
22+
"which systemctl": (0, "", ""),
23+
"systemctl list-unit-files | grep -o ^[^.][^.]*.service | cut -d. -f1 | sort | uniq": (
24+
0,
25+
"postgresql\n",
26+
"",
27+
),
28+
"systemctl restart postgresql.service": (0, "", ""),
29+
"export PGPASSWORD=db_pass; psql -d db_name -U db_user "
30+
"-h localhost -R __RECORD_SEPARATOR__ -t -A -c "
2831
'"SELECT key, value FROM dist"': (
2932
0,
3033
"key1|value1__RECORD_SEPARATOR__key2|value2",
3134
"",
3235
),
33-
'export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost '
34-
'-R __RECORD_SEPARATOR__ -t -A -c "SELECT * FROM table ERROR"': (
35-
1, "", "Syntax Error"
36-
),
37-
'export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost '
38-
'-c \\\\dt': (
36+
"export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost "
37+
'-R __RECORD_SEPARATOR__ -t -A -c "SELECT * FROM table ERROR"': (1, "", "Syntax Error"),
38+
"export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost -c \\\\dt": (
3939
0,
4040
(
4141
"List of relations\n"
4242
" Schema | Name | Type | Owner\n"
4343
"--------+----------------------+-------+---------\n"
4444
" public | test_table | table | postgres\n"
4545
),
46-
""
47-
),
48-
'export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost '
49-
'-c \\\\dv': (
50-
0, "", "Did not find any relations."
46+
"",
5147
),
52-
'export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost '
53-
'-c \\\\gg': (
54-
1, "", "invalid command \\gg"
48+
"export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost -c \\\\dv": (
49+
0,
50+
"",
51+
"Did not find any relations.",
5552
),
53+
"export PGPASSWORD=db_pass; psql -d db_name -U db_user -h localhost -c \\\\gg": (1, "", "invalid command \\gg"),
5654
}
5755
files = {}
5856

@@ -64,37 +62,35 @@ class TestDb(object):
6462
def setup_class(cls):
6563
fake_cmd_data(cls.data, cls.files)
6664

67-
def get_db(self, ip='1.1.1.1'):
68-
h = Host(ip)
69-
h.add_user(User('root', '34546'))
65+
@pytest.fixture(scope="class")
66+
def db(self):
67+
h = Host("1.1.1.1")
68+
h.add_user(User("root", "34546"))
7069
return Database(
71-
h, self.db_name, User(self.db_user, self.db_pass),
70+
h,
71+
self.db_name,
72+
User(self.db_user, self.db_pass),
7273
)
7374

74-
def test_restart(self):
75-
db = self.get_db()
75+
def test_restart(self, db):
7676
db.restart()
7777

78-
def test_psql(self):
79-
db = self.get_db()
78+
def test_psql(self, db):
8079
res = db.psql("SELECT %s, %s FROM %s", "key", "value", "dist")
81-
assert res == [['key1', 'value1'], ['key2', 'value2']]
80+
assert res == [["key1", "value1"], ["key2", "value2"]]
8281

83-
def test_negative(self):
84-
db = self.get_db()
82+
def test_negative(self, db):
8583
with pytest.raises(Exception) as ex_info:
8684
db.psql("SELECT * FROM table ERROR")
8785
assert "Syntax Error" in str(ex_info.value)
8886

89-
def test_psql_cmd(self):
90-
db = self.get_db()
91-
res = db.psql_cmd('\\\\dt')
92-
assert 'List of relations' in res
93-
res = db.psql_cmd('\\\\dv')
94-
assert res == 'Did not find any relations.'
87+
def test_psql_cmd(self, db):
88+
res = db.psql_cmd("\\\\dt")
89+
assert "List of relations" in res
90+
res = db.psql_cmd("\\\\dv")
91+
assert res == "Did not find any relations."
9592

96-
def test_negative_cmd(self):
97-
db = self.get_db()
93+
def test_negative_cmd(self, db):
9894
with pytest.raises(Exception) as ex_info:
99-
db.psql_cmd('\\\\gg')
100-
assert 'invalid command' in str(ex_info.value)
95+
db.psql_cmd("\\\\gg")
96+
assert "invalid command" in str(ex_info.value)

0 commit comments

Comments
 (0)