Skip to content

Commit 5bc3ebe

Browse files
authored
Merge pull request #36 from harp-tech/gl-dev
Add CI pipeline and code coverage
2 parents 0bf15f9 + 849f30d commit 5bc3ebe

5 files changed

Lines changed: 60 additions & 22 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Builds the python environment; linter and formatting via ruff; type annotations via pyright;
2+
# tests via pytest; reports test coverage via pytest-cov.
3+
4+
name: build
5+
on:
6+
push:
7+
branches: ['*']
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
build_run_tests:
13+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
if: github.event.pull_request.draft == false
16+
strategy:
17+
matrix:
18+
os: [ubuntu-latest, windows-latest, macos-latest]
19+
python-version: [3.9, 3.11]
20+
fail-fast: false
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
- name: Setup Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
cache: 'pip'
29+
- name: Install dependencies
30+
run: pip install -e .[dev]
31+
32+
- name: ruff
33+
run: ruff check .
34+
- name: pyright
35+
run: pyright .
36+
- name: pytest
37+
run: pytest --cov harp

harp/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
from harp.io import REFERENCE_EPOCH, MessageType, read
22
from harp.reader import create_reader
33
from harp.schema import read_schema
4+
5+
__all__ = ["REFERENCE_EPOCH", "MessageType", "read", "create_reader", "read_schema"]

harp/reader.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def __init__(self, registers: Mapping[str, RegisterReader]) -> None:
5353
super().__init__(registers)
5454
self._address_map = {value.register.address: value for value in registers.values()}
5555

56-
def __getitem__(self, __key: Union[str, int]) -> RegisterReader:
57-
if isinstance(__key, int):
58-
return self._address_map[__key]
56+
def __getitem__(self, key: Union[str, int]) -> RegisterReader:
57+
if isinstance(key, int):
58+
return self._address_map[key]
5959
else:
60-
return super().__getitem__(__key)
60+
return super().__getitem__(key)
6161

6262

6363
class DeviceReader:

harp/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def read_schema(file: Union[str, PathLike, TextIO], include_common_registers: bo
3535
return read_schema(fileIO)
3636
else:
3737
schema = parse_yaml_raw_as(Model, file.read())
38-
if not "WhoAmI" in schema.registers and include_common_registers:
38+
if "WhoAmI" not in schema.registers and include_common_registers:
3939
common = _read_common_registers()
4040
schema.registers = dict(common.registers, **schema.registers)
4141
if common.bitMasks:

pyproject.toml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ classifiers = [
3131
[project.optional-dependencies]
3232
dev = [
3333
"datamodel-code-generator",
34+
"pandas-stubs",
3435
"pytest",
35-
"black",
36-
"isort",
36+
"pytest-cov",
37+
"pyright",
38+
"ruff",
3739
"codespell"
3840
]
3941

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

5961
[tool.setuptools_scm]
6062

61-
[tool.black]
63+
[tool.ruff]
6264
line-length = 108
63-
target-version = ['py39']
64-
include = '\.pyi?$'
65-
extend-exclude = '''
66-
# A regex preceded with ^/ will apply only to files and directories
67-
# in the root of the project.
68-
(
69-
^/LICENSE
70-
^/README.md
71-
| reflex-generator
72-
)
73-
'''
65+
target-version = "py39"
66+
exclude = [
67+
"reflex-generator"
68+
]
7469

75-
[tool.isort]
76-
profile = 'black'
77-
extend_skip = 'reflex-generator'
70+
[tool.pyright]
71+
venvPath = "."
72+
venv = ".venv"
73+
exclude = [
74+
".venv/*",
75+
"reflex-generator"
76+
]
7877

7978
[tool.codespell]
8079
skip = '.git,*.pdf,*.svg'

0 commit comments

Comments
 (0)