diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..c6e682c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: 2bndy5 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..150c537 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,23 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: "weekly" + groups: + actions: + patterns: + - "*" + - package-ecosystem: pip + directory: / + schedule: + interval: "weekly" + groups: + pip: + patterns: + - "*" diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..7420021 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,41 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..241da1a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: test/lint + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + id: setup-python + with: + python-version: '3.x' + - name: Install dependencies + run: pip install -r tests/requirements.txt -e . -r requirements-dev.txt + - name: Cache pre-commit venv(s) + uses: actions/cache@v4 + with: + path: '~/.cache/pre-commit' + key: pre-commit_${{ steps.setup-python.outputs.python-version }}_${{ hashfiles('.pre-commit-config.yaml') }} + - name: Run pre-commit hooks + run: pre-commit run --all-files + - name: Run tests and collect coverage + run: coverage run -m pytest + - name: Create coverage report + run: coverage xml + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/README.rst b/README.rst index f4603a7..f43af86 100644 --- a/README.rst +++ b/README.rst @@ -1,8 +1,11 @@ .. |rtd-badge| image:: https://readthedocs.org/projects/circuitpython-mocks/badge/?version=latest :target: https://circuitpython-mocks.readthedocs.io/en/latest/ :alt: Documentation Status +.. |codecov-badge| image:: https://codecov.io/github/2bndy5/CircuitPython-mocks/graph/badge.svg?token=RSMPIF9995 + :target: https://codecov.io/github/2bndy5/CircuitPython-mocks + :alt: Coverage Status -|rtd-badge| +|rtd-badge| |codecov-badge| Read The Docs ============= @@ -12,4 +15,4 @@ Documentation for this library is hosted at https://circuitpython-mocks.rtfd.io/ About this Library ================== -This is a library of mock data structures to be used in soft-testing Circuitpython code. +This is a library of mock data structures to be used in soft-testing Circuitpython-based projects. diff --git a/circuitpython_mocks/_mixins.py b/circuitpython_mocks/_mixins.py index 1f77b84..9bf63b2 100644 --- a/circuitpython_mocks/_mixins.py +++ b/circuitpython_mocks/_mixins.py @@ -41,6 +41,7 @@ def unlock(self): class Expecting: """A base class for the mock classes used to assert expected behaviors.""" + def __init__(self, **kwargs) -> None: #: A double ended queue used to assert expected behavior self.expectations: deque[Read | Write | Transfer | SetState | GetState] = ( diff --git a/circuitpython_mocks/board.py b/circuitpython_mocks/board.py index d4505bb..61bc016 100644 --- a/circuitpython_mocks/board.py +++ b/circuitpython_mocks/board.py @@ -1,7 +1,9 @@ """A module that hosts mock pins.""" + class Pin: """A dummy type for GPIO pins.""" + pass diff --git a/circuitpython_mocks/digitalio/__init__.py b/circuitpython_mocks/digitalio/__init__.py index 2b656e0..487c72f 100644 --- a/circuitpython_mocks/digitalio/__init__.py +++ b/circuitpython_mocks/digitalio/__init__.py @@ -28,6 +28,7 @@ class Pull(Enum): class DigitalInOut(Expecting, ContextManaged): """A class that mocks :external:py:class:digitalio.DigitalInOut`""" + def __init__(self, pin: Pin, **kwargs): super().__init__(**kwargs) self._pin = pin diff --git a/circuitpython_mocks/digitalio/operations.py b/circuitpython_mocks/digitalio/operations.py index 97de1c6..5423b9c 100644 --- a/circuitpython_mocks/digitalio/operations.py +++ b/circuitpython_mocks/digitalio/operations.py @@ -10,11 +10,13 @@ def assert_state(self, value: bool | int): class SetState(_State): """A class to represent setting the state of a Digital output pin.""" + def __repr__(self) -> str: return f"" class GetState(_State): """A class to represent setting the state of a Digital output pin.""" + def __repr__(self) -> str: return f"" diff --git a/docs/busio.rst b/docs/busio.rst index 29f9d69..3665683 100644 --- a/docs/busio.rst +++ b/docs/busio.rst @@ -8,7 +8,7 @@ -------------------- .. automodule:: circuitpython_mocks.busio.operations - + I2C operations ************** diff --git a/tests/requirements.txt b/tests/requirements.txt index 675d26a..672ac6b 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1 +1 @@ -adafruit-circuitpython-busdevice \ No newline at end of file +adafruit-circuitpython-busdevice