diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..6c53825 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,63 @@ +# ----------------------- +# +# Run a full build-and-test from the git repo +# using a combination of conda and pip to install +# all optional dependencies. +# +# This is the 'full' test suite. +# +# ----------------------- + +name: Build and test + +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +jobs: + build-and-test: + name: Python ${{ matrix.python-version }} + + strategy: + fail-fast: false + matrix: + python-version: + - 3.7 + - 3.8 + - 3.9 + runs-on: ubuntu-latest + + steps: + - name: Get source code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '${{ matrix.python-version }}' + + - name: Install the software + run: python -m pip install Code/ + + - name: Package list + run: python -m pip list installed + + - name: Run test suite + run: python -m pytest -ra --color yes --cov PyROQ --pyargs PyROQ --cov-report=xml --junitxml=pytest.xml + + - name: Coverage report + run: python -m coverage report --show-missing + + - name: Publish coverage to Codecov + uses: codecov/codecov-action@v1.2.1 + with: + files: coverage.xml + flags: ${{ runner.os }},python${{ matrix.python-version }} diff --git a/Code/PyROQ/tests/__init__.py b/Code/PyROQ/tests/__init__.py new file mode 100644 index 0000000..f8766eb --- /dev/null +++ b/Code/PyROQ/tests/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Cardiff University + +"""Test suite for PyROQ +""" + +__author__ = "Duncan Macleod " diff --git a/Code/PyROQ/tests/test_pyroq.py b/Code/PyROQ/tests/test_pyroq.py new file mode 100644 index 0000000..e35417b --- /dev/null +++ b/Code/PyROQ/tests/test_pyroq.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2021 Cardiff University + +"""Test suite for `PyROQ.pyroq` module +""" + +__author__ = "Duncan Macleod " + +import numpy +import numpy.testing + +import pytest + +from .. import pyroq + + +@pytest.mark.parametrize(("a", "b", "result"), ( + (numpy.array((1, 0, 0)), # a + numpy.array((0, 1, 0)), # b + numpy.array((0, 0, 0)), # result + ), + (numpy.array((1, 1, 0)), + numpy.array((0, 1, 0)), + numpy.array((0.5, 0.5, 0)), + ), +)) +def test_proj(a, b, result): + """Test `PyROQ.pyroq.proj` function over a few different cases + """ + numpy.testing.assert_array_equal( + pyroq.proj(a, b), + result, + )