Skip to content

Commit fb2ea21

Browse files
authored
add CI workflows (#2)
* python-publish.yml * test.yml * add dependabot config * add sponsorship config * add codecov badge to README
1 parent a484bf2 commit fb2ea21

File tree

11 files changed

+118
-4
lines changed

11 files changed

+118
-4
lines changed

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: 2bndy5

.github/dependabot.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: github-actions
9+
directory: /
10+
schedule:
11+
interval: "weekly"
12+
groups:
13+
actions:
14+
patterns:
15+
- "*"
16+
- package-ecosystem: pip
17+
directory: /
18+
schedule:
19+
interval: "weekly"
20+
groups:
21+
pip:
22+
patterns:
23+
- "*"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
permissions:
16+
contents: read
17+
18+
jobs:
19+
deploy:
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.x'
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install build
35+
- name: Build package
36+
run: python -m build
37+
- name: Publish package
38+
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0
39+
with:
40+
user: __token__
41+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: test/lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
run:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
id: setup-python
18+
with:
19+
python-version: '3.x'
20+
- name: Install dependencies
21+
run: pip install -r tests/requirements.txt -e . -r requirements-dev.txt
22+
- name: Cache pre-commit venv(s)
23+
uses: actions/cache@v4
24+
with:
25+
path: '~/.cache/pre-commit'
26+
key: pre-commit_${{ steps.setup-python.outputs.python-version }}_${{ hashfiles('.pre-commit-config.yaml') }}
27+
- name: Run pre-commit hooks
28+
run: pre-commit run --all-files
29+
- name: Run tests and collect coverage
30+
run: coverage run -m pytest
31+
- name: Create coverage report
32+
run: coverage xml
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v4
35+
with:
36+
verbose: true
37+
env:
38+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
.. |rtd-badge| image:: https://readthedocs.org/projects/circuitpython-mocks/badge/?version=latest
22
:target: https://circuitpython-mocks.readthedocs.io/en/latest/
33
:alt: Documentation Status
4+
.. |codecov-badge| image:: https://codecov.io/github/2bndy5/CircuitPython-mocks/graph/badge.svg?token=RSMPIF9995
5+
:target: https://codecov.io/github/2bndy5/CircuitPython-mocks
6+
:alt: Coverage Status
47

5-
|rtd-badge|
8+
|rtd-badge| |codecov-badge|
69

710
Read The Docs
811
=============
@@ -12,4 +15,4 @@ Documentation for this library is hosted at https://circuitpython-mocks.rtfd.io/
1215
About this Library
1316
==================
1417

15-
This is a library of mock data structures to be used in soft-testing Circuitpython code.
18+
This is a library of mock data structures to be used in soft-testing Circuitpython-based projects.

circuitpython_mocks/_mixins.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def unlock(self):
4141

4242
class Expecting:
4343
"""A base class for the mock classes used to assert expected behaviors."""
44+
4445
def __init__(self, **kwargs) -> None:
4546
#: A double ended queue used to assert expected behavior
4647
self.expectations: deque[Read | Write | Transfer | SetState | GetState] = (

circuitpython_mocks/board.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
"""A module that hosts mock pins."""
22

3+
34
class Pin:
45
"""A dummy type for GPIO pins."""
6+
57
pass
68

79

circuitpython_mocks/digitalio/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Pull(Enum):
2828

2929
class DigitalInOut(Expecting, ContextManaged):
3030
"""A class that mocks :external:py:class:digitalio.DigitalInOut`"""
31+
3132
def __init__(self, pin: Pin, **kwargs):
3233
super().__init__(**kwargs)
3334
self._pin = pin

circuitpython_mocks/digitalio/operations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ def assert_state(self, value: bool | int):
1010

1111
class SetState(_State):
1212
"""A class to represent setting the state of a Digital output pin."""
13+
1314
def __repr__(self) -> str:
1415
return f"<SetState value='{self.state}'>"
1516

1617

1718
class GetState(_State):
1819
"""A class to represent setting the state of a Digital output pin."""
20+
1921
def __repr__(self) -> str:
2022
return f"<GetState value='{self.state}'>"

docs/busio.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
--------------------
99

1010
.. automodule:: circuitpython_mocks.busio.operations
11-
11+
1212
I2C operations
1313
**************
1414

0 commit comments

Comments
 (0)