Skip to content

Commit

Permalink
Merge pull request #36 from harp-tech/gl-dev
Browse files Browse the repository at this point in the history
Add CI pipeline and code coverage
  • Loading branch information
glopesdev authored Oct 30, 2024
2 parents 0bf15f9 + 849f30d commit 5bc3ebe
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 22 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Builds the python environment; linter and formatting via ruff; type annotations via pyright;
# tests via pytest; reports test coverage via pytest-cov.

name: build
on:
push:
branches: ['*']
pull_request:
workflow_dispatch:

jobs:
build_run_tests:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
if: github.event.pull_request.draft == false
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.9, 3.11]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: pip install -e .[dev]

- name: ruff
run: ruff check .
- name: pyright
run: pyright .
- name: pytest
run: pytest --cov harp
2 changes: 2 additions & 0 deletions harp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from harp.io import REFERENCE_EPOCH, MessageType, read
from harp.reader import create_reader
from harp.schema import read_schema

__all__ = ["REFERENCE_EPOCH", "MessageType", "read", "create_reader", "read_schema"]
8 changes: 4 additions & 4 deletions harp/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def __init__(self, registers: Mapping[str, RegisterReader]) -> None:
super().__init__(registers)
self._address_map = {value.register.address: value for value in registers.values()}

def __getitem__(self, __key: Union[str, int]) -> RegisterReader:
if isinstance(__key, int):
return self._address_map[__key]
def __getitem__(self, key: Union[str, int]) -> RegisterReader:
if isinstance(key, int):
return self._address_map[key]
else:
return super().__getitem__(__key)
return super().__getitem__(key)


class DeviceReader:
Expand Down
2 changes: 1 addition & 1 deletion harp/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def read_schema(file: Union[str, PathLike, TextIO], include_common_registers: bo
return read_schema(fileIO)
else:
schema = parse_yaml_raw_as(Model, file.read())
if not "WhoAmI" in schema.registers and include_common_registers:
if "WhoAmI" not in schema.registers and include_common_registers:
common = _read_common_registers()
schema.registers = dict(common.registers, **schema.registers)
if common.bitMasks:
Expand Down
33 changes: 16 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ classifiers = [
[project.optional-dependencies]
dev = [
"datamodel-code-generator",
"pandas-stubs",
"pytest",
"black",
"isort",
"pytest-cov",
"pyright",
"ruff",
"codespell"
]

Expand All @@ -58,23 +60,20 @@ include = ["harp*"]

[tool.setuptools_scm]

[tool.black]
[tool.ruff]
line-length = 108
target-version = ['py39']
include = '\.pyi?$'
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
(
^/LICENSE
^/README.md
| reflex-generator
)
'''
target-version = "py39"
exclude = [
"reflex-generator"
]

[tool.isort]
profile = 'black'
extend_skip = 'reflex-generator'
[tool.pyright]
venvPath = "."
venv = ".venv"
exclude = [
".venv/*",
"reflex-generator"
]

[tool.codespell]
skip = '.git,*.pdf,*.svg'
Expand Down

0 comments on commit 5bc3ebe

Please sign in to comment.