From 1848912a0de63382d02f59d3926dc1c2c161eef9 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 04:56:44 -0700 Subject: [PATCH 1/7] Create python-publish.yml --- .github/workflows/python-publish.yml | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/python-publish.yml 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 }} From 94d314ecb492830ac70ff938480252da1207926f Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:16:01 -0700 Subject: [PATCH 2/7] add test CI workflow --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..898124d --- /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@v4 + 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 }} From 12305651a73d04f58af323fe4e0f62281c7e5bd9 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:19:03 -0700 Subject: [PATCH 3/7] add dependabot config --- .github/dependabot.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/dependabot.yml 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: + - "*" From 2cf4b4d3602684fcf000c8b4479a8cddea941133 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:19:34 -0700 Subject: [PATCH 4/7] add sponsorship config --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml 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 From b6f75c426d75cf42a76f66072d35bee4501444ad Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:20:57 -0700 Subject: [PATCH 5/7] ran pre-commit hooks --- circuitpython_mocks/_mixins.py | 1 + circuitpython_mocks/board.py | 2 ++ circuitpython_mocks/digitalio/__init__.py | 1 + circuitpython_mocks/digitalio/operations.py | 2 ++ docs/busio.rst | 2 +- tests/requirements.txt | 2 +- 6 files changed, 8 insertions(+), 2 deletions(-) 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 From 519f303e0e6c15fde6cf57f8aff735a6575b7fd0 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:28:14 -0700 Subject: [PATCH 6/7] add codecov badge to README --- README.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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. From ab713d571b3da9e628ad40c4749d2a99bc2b1511 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Sun, 4 Aug 2024 05:28:54 -0700 Subject: [PATCH 7/7] bump actions/setup-python to v5 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 898124d..241da1a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 id: setup-python with: python-version: '3.x'