From 0b2db19370eec5ba60fbc2abb73427ed7826dea0 Mon Sep 17 00:00:00 2001 From: Ghost Ops <72981180+GhostOps77@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:45:28 +0530 Subject: [PATCH] Added gh-actions YAML file and config (#84) * added gh-actions yaml file: .github/workflows/tests.yml deleted: .travis.yml deleted: bin/testrepl.py modified for gh-actions: tox.ini * Added for pytest config: pyproject.toml * Added the removed testrepl test case: tests/test_repl.py removed mypy: tox.ini * Update tests/test_repl.py --------- Co-authored-by: Asif Saif Uddin --- .github/workflows/tests.yml | 27 +++++++++++++++++++++ .travis.yml | 15 ------------ bin/testrepl.py | 25 ------------------- pyproject.toml | 8 +++++++ tests/test_repl.py | 27 +++++++++++++++++++++ tox.ini | 48 ++++++++++++++++++++++++++----------- 6 files changed, 96 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml delete mode 100644 bin/testrepl.py create mode 100644 pyproject.toml create mode 100644 tests/test_repl.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f58749d --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + - push + - pull_request + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ['3.7', '3.8', '3.9', '3.10'] + click-version: ['7.1.2', '8.1.2'] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install tox tox-gh-actions click==${{ matrix.click-version }} + - name: Test with tox + run: tox diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6089e52..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: python -python: - - "pypy" - - "3.4" - - "3.5" - - "3.6" - - "3.7-dev" - -matrix: - include: - - python: "3.6" - script: tox -e linters - -install: pip install tox-travis -script: tox diff --git a/bin/testrepl.py b/bin/testrepl.py deleted file mode 100644 index 87eba81..0000000 --- a/bin/testrepl.py +++ /dev/null @@ -1,25 +0,0 @@ -import click -from click_repl import register_repl - - -@click.group() -def cli(): - pass - - -@cli.command() -@click.option("--baz", is_flag=True) -def foo(baz): - print("Foo!") - - -@cli.command() -@click.option("--foo", is_flag=True) -def bar(foo): - print("Bar!") - - -register_repl(cli) - -if __name__ == "__main__": - cli() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4ff3c14 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,8 @@ +[tool.pytest.ini_options] +addopts = [ + "--cov=click_repl" +] + +testpaths = [ + "tests", +] diff --git a/tests/test_repl.py b/tests/test_repl.py new file mode 100644 index 0000000..d7232b7 --- /dev/null +++ b/tests/test_repl.py @@ -0,0 +1,27 @@ +import click +from click_repl import register_repl +import pytest + + +def test_repl(): + @click.group() + def cli(): + pass + + + @cli.command() + @click.option("--baz", is_flag=True) + def foo(baz): + print("Foo!") + + + @cli.command() + @click.option("--foo", is_flag=True) + def bar(foo): + print("Bar!") + + + register_repl(cli) + + with pytest.raises(SystemExit): + cli() diff --git a/tox.ini b/tox.ini index 3d2a0e2..9232771 100644 --- a/tox.ini +++ b/tox.ini @@ -1,19 +1,39 @@ [tox] envlist = - py{py,34,35,36,37} - linters + py{py,37,38,39,310} + ; mypy + click7 + +minversion = 3.7.14 +isolated_build = true + +[gh-actions] +python = + 3.7: py37, mypy, click7 + 3.8: py38 + 3.9: py39 + 3.10: py310 [testenv] -deps= - style: flake8 - test: pytest -commands= - style: flake8 [] - style: black --check . - test: py.test [] +setenv = + PYTHONPATH = {toxinidir} +deps = + pytest + pytest-cov + mypy + tox +commands = + pytest --basetemp={envtmpdir} + +; [testenv:mypy] +; basepython = python3.7 +; deps = mypy +; commands = mypy src -[travis] -; This section is used by tox-travis -; https://pypi.python.org/pypi/tox-travis -python= - 3.6: py36,linters +[testenv:click7] +basepython = python3.10 +deps = + click==7.1.2 + pytest + pytest-cov +commands = pytest --basetemp={envtmpdir}