Skip to content

Commit

Permalink
Fixed and improved CI workflows (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
famura authored Nov 11, 2023
1 parent 14f5765 commit a37be6e
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 29 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/black.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -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"
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 10 additions & 6 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
pytest.xml

# Translations
*.mo
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
4 changes: 0 additions & 4 deletions tests/pytest.ini

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_blm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit a37be6e

Please sign in to comment.