Skip to content

Commit

Permalink
add CI workflows (#2)
Browse files Browse the repository at this point in the history
* python-publish.yml
* test.yml
* add dependabot config
* add sponsorship config
* add codecov badge to README
  • Loading branch information
2bndy5 authored Aug 4, 2024
1 parent a484bf2 commit fb2ea21
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: 2bndy5
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -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:
- "*"
41 changes: 41 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
=============
Expand All @@ -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.
1 change: 1 addition & 0 deletions circuitpython_mocks/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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] = (
Expand Down
2 changes: 2 additions & 0 deletions circuitpython_mocks/board.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""A module that hosts mock pins."""


class Pin:
"""A dummy type for GPIO pins."""

pass


Expand Down
1 change: 1 addition & 0 deletions circuitpython_mocks/digitalio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions circuitpython_mocks/digitalio/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<SetState value='{self.state}'>"


class GetState(_State):
"""A class to represent setting the state of a Digital output pin."""

def __repr__(self) -> str:
return f"<GetState value='{self.state}'>"
2 changes: 1 addition & 1 deletion docs/busio.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
--------------------

.. automodule:: circuitpython_mocks.busio.operations

I2C operations
**************

Expand Down
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
adafruit-circuitpython-busdevice
adafruit-circuitpython-busdevice

0 comments on commit fb2ea21

Please sign in to comment.