diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 01f8d5c..0000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Lint - -on: [push, pull_request] - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: psf/black@stable - with: - args: ". --check" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..40368d5 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: Lint + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + - uses: psf/black@stable + with: + args: ". --check" + - uses: isort/isort-action@v1 + with: + sort-paths: "./blm" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..c4fb00e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: Publish to PyPI.org + +on: + release: + types: [published] + +jobs: + + build: + name: Build distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # to also get the tags + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install pypa/build + run: python3 -m pip install build --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish Python distribution to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/blm + permissions: + id-token: write # mandatory for trusted publishing + steps: + - name: Download all distributions + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index bc006d2..d3867cc 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -2,22 +2,26 @@ name: Run Tests on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build-images: runs-on: ${{ matrix.os }} strategy: matrix: - #os: [ubuntu-latest] - os: [ubuntu-latest, macos-latest, windows-latest] - python-version: ["3.7", "3.8", "3.9"] + os: [ubuntu-latest] +# os: [ubuntu-latest, macos-latest, windows-latest] # macos and windows runners time out during tests + python-version: ["3.8", "3.10", "3.12"] env: os: ${{ matrix.os }} python: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install @@ -27,7 +31,7 @@ jobs: run: | pytest --cov=./ --cov-report=xml - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: ./coverage.xml flags: unittests diff --git a/.gitignore b/.gitignore index 1a70407..7925f34 100644 --- a/.gitignore +++ b/.gitignore @@ -50,6 +50,7 @@ coverage.xml *.py,cover .hypothesis/ .pytest_cache/ +pytest.xml # Translations *.mo diff --git a/README.md b/README.md index 9d6e28c..2ce93f7 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ A simple model to describe the backlash effect in physics simulations based on n The model implemented in this package was published as: J. Vörös, "Modeling and identification of systems with backlash", Automatica, 2008, [link to pdf](https://www.researchgate.net/profile/Jozef-Voeroes/publication/233692268_Identification_of_cascade_systems_with_backlash/links/56b3535f08ae3d06a266451d/Identification-of-cascade-systems-with-backlash.pdf) -## Citing +## Support -If you use code or ideas from this repository for your projects or research, please cite it. +If you use code or ideas from this repository for your projects or research, **please cite it**. ``` @misc{Muratore_blm, author = {Fabio Muratore}, diff --git a/pyproject.toml b/pyproject.toml index 8ff187b..92782f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,3 +23,18 @@ exclude = ''' | dist )/ ''' + +[tool.pytest.ini_options] +addopts = [ + "--capture=tee-sys", + "--full-trace", + "--junit-xml=pytest.xml", + "--showlocals", + "--strict-markers", + "-ra", +] +markers = [ + "visual: marks tests that produce plots or animations (deselect with '-m \"not visual\"')", +] +pythonpath = [".", "blm"] +testpaths = ["tests"] \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 28ecefd..377de1c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ try: from matplotlib import pyplot as plt - m_needs_pyplot = pytest.mark.skipif(False, reason="matplotlib.pyplot can be imported.") + needs_pyplot = pytest.mark.skipif(False, reason="matplotlib.pyplot can be imported.") except (ImportError, ModuleNotFoundError): - m_needs_pyplot = pytest.mark.skip(reason="matplotlib.pyplot is not supported in this setup.") + needs_pyplot = pytest.mark.skip(reason="matplotlib.pyplot is not supported in this setup.") diff --git a/tests/pytest.ini b/tests/pytest.ini deleted file mode 100644 index a758a9b..0000000 --- a/tests/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -addopts = --strict-markers -markers = - visual: marks tests that produce a visual output, e.g. plots or animations diff --git a/tests/test_blm.py b/tests/test_blm.py index 7e27562..5be453e 100644 --- a/tests/test_blm.py +++ b/tests/test_blm.py @@ -2,7 +2,7 @@ import pytest import blm -from tests.conftest import m_needs_pyplot +from tests.conftest import needs_pyplot @pytest.mark.parametrize("model_param", [dict(m_lo=1.1, m_up=0.9, c_lo=0.1, c_up=0.2)]) @@ -51,7 +51,7 @@ def test_invalid_ctor_params(ctor_param: dict): blm.BacklashModel(**ctor_param) -@pytest.mark.parametrize("plot", [pytest.param(True, marks=[m_needs_pyplot, pytest.mark.visual]), False]) +@pytest.mark.parametrize("plot", [pytest.param(True, marks=[needs_pyplot, pytest.mark.visual]), False]) @pytest.mark.parametrize("model_param", [dict(m_lo=2.0, m_up=1.9, c_lo=2.5, c_up=2.7)]) @pytest.mark.parametrize("apply_u_bl", [False]) def test_all(model_param: dict, apply_u_bl: bool, plot: bool):