From b1398189a0eb55cc2c008f931c17a9c44c766ab4 Mon Sep 17 00:00:00 2001 From: benoit Date: Tue, 12 Jul 2022 15:50:06 +0200 Subject: [PATCH 1/5] Release stuff --- MANIFEST.in | 13 +++++++++++++ pyproject.toml | 0 setup.py | 6 +++++- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 MANIFEST.in create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f4a6667 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,13 @@ +include *.md +include mypy.ini +include pytest.ini +include tox.ini +include .flake8 +include pyproject.toml +recursive-include docs *.sh +recursive-include tests *.json +recursive-include tests *.py + +prune vagrant +prune .github + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py index 7aaf56c..d631268 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,6 @@ setup( ], extras_require={ "dev": [ - "wheel", "black", "check-manifest", "flake8", @@ -55,6 +54,11 @@ setup( "pytest", "pytest-mock", ], + "release": [ + "wheel", + "setuptools", + "twine", + ], }, entry_points={ "console_scripts": [ From 04f7ea78d3c603cc72a32187d11f2083e33fd043 Mon Sep 17 00:00:00 2001 From: benoit Date: Tue, 12 Jul 2022 15:55:48 +0200 Subject: [PATCH 2/5] Add publish workflow --- .github/workflows/publish.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..16cd390 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,28 @@ +name: Publish + +on: + push: + tags: + - 'v*' + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Install + run: python -m pip install setuptools wheel twine + - name: Build + run: | + python setup.py check + python setup.py sdist bdist_wheel + python -m twine check dist/* + - name: Publish + run: python -m twine upload dist/* + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} From 12832945c3f6fa4da85396c4fcd699ac91b1793a Mon Sep 17 00:00:00 2001 From: benoit Date: Tue, 12 Jul 2022 16:07:57 +0200 Subject: [PATCH 3/5] pyproject.toml --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index e69de29..8fd8d67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" From 5198f38620596d5aba6296b315fed5d072e382fe Mon Sep 17 00:00:00 2001 From: benoit Date: Wed, 13 Jul 2022 09:03:23 +0200 Subject: [PATCH 4/5] Review fix --- MANIFEST.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index f4a6667..03ee4c6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,7 +7,3 @@ include pyproject.toml recursive-include docs *.sh recursive-include tests *.json recursive-include tests *.py - -prune vagrant -prune .github - From c18fa67a09d9fa1499bd3db11991b309fa856083 Mon Sep 17 00:00:00 2001 From: benoit Date: Wed, 13 Jul 2022 16:04:49 +0200 Subject: [PATCH 5/5] Tox updates, setup.py fixes and CONTRIBUTING.md --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++-- setup.py | 11 ----------- tox.ini | 25 ++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e7d95e5..a67ad5e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,8 @@ from the repo: ``` $ python3 -m venv .venv $ . .venv/bin/activate -(.venv) $ pip3 install .[dev,test] +(.venv) $ pip3 install .[test] +(.venv) $ pip3 install -r requirements-dev.txt (.venv) $ check_patroni ``` @@ -48,4 +49,26 @@ The `README.md` can be geneated with `./docs/make_readme.sh`. ## Executing Tests The pytests are in `./tests` and use a moker to provide a json response instead -of having to call the patroni API. +of having to call the patroni API. To manually run the tests use one of these +commands : + +``` +pytest ./tests # just the tests +tox # pytests for all supported version of python + mypy + flake8 +tox -e py # pytests + mypy + flake8 or the default version of python +``` + +The tests are executed automatically for each PR using the ci (see +`.github/workflow/lint.yml` and `.github/workflow/tests.yml`). + +## Release + +The package is generated and uploaded to pypi when a `v*` tag is created (see +`.github/workflow/publish.yml`). + +Alternatively, the release can be done manually with: + +``` +tox -e build +tox -e upload +``` diff --git a/setup.py b/setup.py index d631268..60ed932 100644 --- a/setup.py +++ b/setup.py @@ -44,21 +44,10 @@ setup( "click >= 8.0.1", ], extras_require={ - "dev": [ - "black", - "check-manifest", - "flake8", - "mypy == 0.961", - ], "test": [ "pytest", "pytest-mock", ], - "release": [ - "wheel", - "setuptools", - "twine", - ], }, entry_points={ "console_scripts": [ diff --git a/tox.ini b/tox.ini index 4fe7bee..573ca8b 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,9 @@ envlist = lint, mypy, py36, py37, py38, py39, py310 skip_missing_interpreters = True [testenv] -extras = test +deps = + pytest + pytest-mock commands = pytest {toxinidir}/check_patroni {toxinidir}/tests {posargs:-vv} @@ -21,3 +23,24 @@ deps = mypy == 0.961 commands = mypy {toxinidir}/check_patroni + +[testenv:build] +deps = + wheel + setuptools + twine +allowlist_externals = + rm +commands = + rm --verbose --recursive --force {toxinidir}/dist/ + python setup.py check + python setup.py sdist bdist_wheel + python -m twine check dist/* + +[testenv:upload] +# requires a check_patroni section in ~/.pypirc +skip_install = True +deps = + twine +commands = + python -m twine upload --repository check_patroni dist/*