diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..4e65be6 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,35 @@ +name: Run Tests +on: + push: + pull_request: + +concurrency: + group: test-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + name: test with ${{ matrix.py }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + py: + - "3.12" + - "3.11" + - "3.10" + - "3.9" + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup python for test ${{ matrix.py }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.py }} + - name: Install tox + run: python -m pip install tox-gh>=1.2 + - name: Setup test suite + run: tox -vv --notest + - name: Run test suite + run: tox --skip-pkg-install diff --git a/README.md b/README.md index 0133d7b..4b0817c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +![Tests](https://github.com/djcopley/ShellOracle/actions/workflows/run-tests.yml/badge.svg?branch=main) [![PyPI version](https://badge.fury.io/py/shelloracle.svg)](https://badge.fury.io/py/shelloracle) [![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/shelloracle.svg)](https://pypi.python.org/pypi/shelloracle/) [![Downloads](https://static.pepy.tech/badge/shelloracle/month)](https://pepy.tech/project/shelloracle) diff --git a/pyproject.toml b/pyproject.toml index 8a502cc..5e35d66 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,12 @@ where = ["src"] [tool.setuptools_scm] +[tool.pytest.ini_options] +pythonpath = "src" +addopts = [ + "--import-mode=importlib", +] + [project.scripts] shor = "shelloracle.__main__:main" diff --git a/tests/providers/test_ollama.py b/tests/providers/test_ollama.py new file mode 100644 index 0000000..c573633 --- /dev/null +++ b/tests/providers/test_ollama.py @@ -0,0 +1,5 @@ +from shelloracle.providers.ollama import Ollama + + +def test_name(): + assert Ollama.name == "Ollama" diff --git a/tests/providers/test_openai.py b/tests/providers/test_openai.py new file mode 100644 index 0000000..277b032 --- /dev/null +++ b/tests/providers/test_openai.py @@ -0,0 +1,5 @@ +from shelloracle.providers.openai import OpenAI + + +def test_name(): + assert OpenAI.name == "OpenAI" diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..9c87a83 --- /dev/null +++ b/tox.ini @@ -0,0 +1,19 @@ +[tox] +requires = + tox>=4 +env_list = py{39,310,311,312} + +[testenv] +description = run unit tests with pytest +deps = + pytest>=7 + pytest-sugar +commands = + pytest {posargs:tests} + +[gh] +python = + 3.12 = py312 + 3.11 = py311 + 3.10 = py310 + 3.9 = py39