From 644f55b4e520c3d0119ee16f42585ea1b1c693cc Mon Sep 17 00:00:00 2001 From: touriste Date: Mon, 1 May 2023 12:59:27 +0200 Subject: [PATCH] removed tox + remake GH workflows --- .github/workflows/release.yml | 36 +++++++++++++++ .../{python-app.yml => validation.yml} | 46 +++++-------------- requirements-dev.txt | 3 +- setup.py | 11 +++-- tasks.py | 31 ++----------- tox.ini | 16 ------- 6 files changed, 60 insertions(+), 83 deletions(-) create mode 100644 .github/workflows/release.yml rename .github/workflows/{python-app.yml => validation.yml} (62%) delete mode 100644 tox.ini diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..16fb24e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,36 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Validation + +on: + push: + branches: + - master + tags: + - v** + +permissions: + contents: read + +jobs: + release: + + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e . + python -m pip install -e .[dev] + + - name: publish + run: invoke publish_test diff --git a/.github/workflows/python-app.yml b/.github/workflows/validation.yml similarity index 62% rename from .github/workflows/python-app.yml rename to .github/workflows/validation.yml index 05a4425..7f8b45e 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/validation.yml @@ -1,7 +1,7 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application +name: Validation on: pull_request @@ -9,12 +9,18 @@ permissions: contents: read jobs: - validate_unix: - - runs-on: ubuntu-latest + validate: strategy: matrix: - python-version: ["3.8", "3.9"] + os: + - ubuntu-latest + - windows-latest + python-version: + - 3.8 + - 3.9 + - '3.10' + - '3.11' + runs-on: ${{ matrix.os }} steps: - name: checkout uses: actions/checkout@v3 @@ -28,7 +34,7 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -e . - python -m pip install -r requirements-dev.txt + python -m pip install -e .[dev] - name: check pylint run: pylint JSONLibrary --disable=R,C,W0703,W0212,W1203 @@ -52,31 +58,3 @@ jobs: coverage xml --rcfile tests/.coveragerc coverage html --rcfile tests/.coveragerc robot -d tests/__out__/robot acceptance/ - - validate_windows: - - runs-on: windows-latest - strategy: - matrix: - python-version: ["3.10", "3.11"] - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install -e . - python -m pip install -r requirements-dev.txt - - - name: validate - run: | - pytest --cov-config=tests/.coveragerc --cov --cov-report term tests/ - coverage xml --rcfile tests/.coveragerc - coverage html --rcfile tests/.coveragerc - robot -d tests/__out__/robot acceptance/ diff --git a/requirements-dev.txt b/requirements-dev.txt index 3788a53..818aba1 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,9 +1,8 @@ twine wheel pylint -invoke black -tox pytest pytest-cov +coverage flake8 diff --git a/setup.py b/setup.py index 241449c..a77db5b 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,11 @@ with open(os.path.join(HERE, "JSONLibrary", "__version__.py"), encoding="utf8") as f: exec(f.read(), version) -requirements = [ - i.strip() for i in open("requirements.txt", encoding="utf8").readlines() -] + +def readfile(_file): + with open(_file, encoding="utf8") as fh: + return [i.strip() for i in fh.readlines()] + setup( name="robotframework-jsonlibrary", @@ -21,7 +23,8 @@ url="https://github.com/nottyo/robotframework-jsonlibrary.git", packages=["JSONLibrary"], package_dir={"robotframework-jsonlibrary": "JSONLibrary"}, - install_requires=requirements, + install_requires=readfile("requirements.txt"), + extras_require={"dev": readfile("requirements-dev.txt")}, include_package_data=True, keywords="testing robotframework json jsonschema jsonpath", classifiers=[ diff --git a/tasks.py b/tasks.py index 1d9314e..80d045c 100644 --- a/tasks.py +++ b/tasks.py @@ -17,7 +17,6 @@ def clean(_): os.path.join("tests", "__out__"), ignore_errors=True, ) - shutil.rmtree(".tox", ignore_errors=True) shutil.rmtree(".pytest_cache", ignore_errors=True) shutil.rmtree("build", ignore_errors=True) shutil.rmtree("dist", ignore_errors=True) @@ -47,33 +46,11 @@ def install(ctx): ctx.run(f"{sys.executable} -m pip install {wheel_file}", hide="both") -@task(install) -def test(ctx): - ctx.run("tox") - - -@task -def style_check(ctx): - ctx.run("black . --check --diff") - - -@task -def reformat_code(ctx): - ctx.run("black .") - - -@task +@task(build) def publish(ctx): ctx.run(f"{sys.executable} -m twine upload dist/*") -@task -def docs(ctx): - ctx.run(f"{sys.executable} -m robot.libdoc JSONLibrary docs/JSONLibrary.html") - - -@task(install) -def lint(ctx): - ctx.run("pylint JSONLibrary --disable=R,C,W0703,W0212,W1203") - uninstall(ctx) - clean(ctx) +@task(build) +def publish_test(ctx): + ctx.run(f"{sys.executable} -m twine upload --repository testpypi dist/*") diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 4b0d347..0000000 --- a/tox.ini +++ /dev/null @@ -1,16 +0,0 @@ -[tox] -envlist = py38,py39 - -[testenv] -setenv = - COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}/tmp/coverage/.coverage} -deps = - pytest - pytest-cov - coverage - robotframework -commands = - pytest --cov-config=tests/.coveragerc --cov --cov-report term tests/ - coverage xml --rcfile tests/.coveragerc - coverage html --rcfile tests/.coveragerc - robot -d tests/__out__/robot acceptance/