From c56dfb8e0e0c562a8077c39c96e2aac0d12c7179 Mon Sep 17 00:00:00 2001 From: Martin Hanicinec Date: Thu, 13 Jan 2022 14:59:55 +0100 Subject: [PATCH 1/3] move pytest and tox config into pyproject.toml --- pyproject.toml | 27 ++++++++++++++++++++++++++- pytest.ini | 2 -- setup.py | 2 +- tox.ini | 13 ------------- 4 files changed, 27 insertions(+), 17 deletions(-) delete mode 100644 pytest.ini delete mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index 86909ae..fab629b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,28 @@ [build-system] requires = ["setuptools>=43", "wheel"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[tool.pytest.ini_options] +addopts = "--doctest-modules --doctest-glob='README.rst'" + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py3{10,9,8,7}-pp_{l,h}, py3{6}-pp_{l,h}-ir_{l,h} +skip_missing_interpreters = true + +[testenv] +deps = + pytest + pp_l: pyparsing==2.3.0 + pp_h: pyparsing + ir_l: importlib-resources==1.0 + ir_h: importlib-resources +commands = pytest +""" + +[tool.coverage.run] +omit = ["tests/*", "src/pyvalem/__init__.py"] + +[tool.coverage.html] +directory = "htmlcov" \ No newline at end of file diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 62e9d73..0000000 --- a/pytest.ini +++ /dev/null @@ -1,2 +0,0 @@ -[pytest] -addopts = --doctest-modules --doctest-glob="README.rst" diff --git a/setup.py b/setup.py index 83df974..b7834ee 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ "pyparsing>=2.3", 'importlib-resources>=1.0; python_version < "3.7.0"', ], - extras_require={"dev": ["black", "coverage", "pytest", "tox", "ipython"]}, + extras_require={"dev": ["black", "pytest-cov", "tox", "ipython"]}, # package_data will include all the resolved globs into both the wheel and sdist package_data={"pyvalem": ["*.txt"]}, # no need for MANIFEST.in, which should be reserved only for build-time files diff --git a/tox.ini b/tox.ini deleted file mode 100644 index cce5e18..0000000 --- a/tox.ini +++ /dev/null @@ -1,13 +0,0 @@ -[tox] -envlist = py3{10,9,8,7}-pp_{l,h}, py3{6}-pp_{l,h}-ir_{l,h} -skip_missing_interpreters = true - -[testenv] -deps = - pytest - pp_l: pyparsing==2.3.0 - pp_h: pyparsing==3.0.6 - ir_l: importlib-resources==1.0 - ir_h: importlib-resources==5.4.0 -commands = - pytest \ No newline at end of file From 6ab5adb4a3a3cd467792ea8df089bf83ceae1f8f Mon Sep 17 00:00:00 2001 From: Martin Hanicinec Date: Thu, 13 Jan 2022 15:09:35 +0100 Subject: [PATCH 2/3] add the github actions --- .github/workflows/python-pkg-cd.yml | 31 ++++++++++++++++++++++++++++ .github/workflows/python-pkg-ci.yml | 32 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/python-pkg-cd.yml create mode 100644 .github/workflows/python-pkg-ci.yml diff --git a/.github/workflows/python-pkg-cd.yml b/.github/workflows/python-pkg-cd.yml new file mode 100644 index 0000000..bf0f682 --- /dev/null +++ b/.github/workflows/python-pkg-cd.yml @@ -0,0 +1,31 @@ +name: Upload python package to PyPI + +on: + release: + types: [published] + +jobs: + deploy: + name: Build and deploy the package to TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: "3.9" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --upgrade build + pip install --upgrade twine + - name: Build package + run: | + python -m build --outdir dist/ + twine check dist/* + - name: Publish package + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + verbose: true diff --git a/.github/workflows/python-pkg-ci.yml b/.github/workflows/python-pkg-ci.yml new file mode 100644 index 0000000..7d07b21 --- /dev/null +++ b/.github/workflows/python-pkg-ci.yml @@ -0,0 +1,32 @@ +name: Install and test the package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-n-test: + name: Install and test the package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: "3.9" + - name: Install the package locally + run: | + python -m pip install --upgrade pip + pip install . + - name: Install dependencies for testing + run: | + pip install pytest-cov + pip install black + - name: Test with pytest + run: | + pytest --cov + - name: Check code format + run: | + black --check . From 62eeff9c84b8430a9ed0d69504ab9fde887fba67 Mon Sep 17 00:00:00 2001 From: Martin Hanicinec Date: Thu, 13 Jan 2022 15:13:48 +0100 Subject: [PATCH 3/3] remove doc from the coverage --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fab629b..e4e9fb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ commands = pytest """ [tool.coverage.run] -omit = ["tests/*", "src/pyvalem/__init__.py"] +omit = ["tests/*", "src/pyvalem/__init__.py", "doc/*"] [tool.coverage.html] directory = "htmlcov" \ No newline at end of file