Skip to content

Commit 7184bdf

Browse files
dbgen1nateinactiong-e-n
authored
testing and magic numbers! (#3)
* [FIX] set alarm bit to the correct register and check for errors * fix operator precedence * checking and clearing the alarm * [FIX] trickle charger registers should use EEROM backup * testing for driver functions * big list of registers * VERY BIG list of bit masks * transfer register usage to pull from registers.py * get rid of those pesky magic numbers once and for all * Add dev workflow and CI * Lint * more tests * docstrings * get alarm function * [FIX] get alarm function * fix get alarm function * appease the linter gods * small logic improvement * [FIX] get alarm function --------- Co-authored-by: Nate Gay <email@nategay.me> Co-authored-by: Davit Babayan <davitb2013@gmail.com>
1 parent ba9e3e2 commit 7184bdf

File tree

12 files changed

+1050
-93
lines changed

12 files changed

+1050
-93
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: ci
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Lint
15+
run: |
16+
make fmt
17+
test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
- name: Test
22+
run: |
23+
make test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__/
99
# Distribution / packaging
1010
.Python
1111
build/
12+
coverage-reports/
1213
develop-eggs/
1314
dist/
1415
downloads/
@@ -17,6 +18,7 @@ eggs/
1718
lib/
1819
lib64/
1920
parts/
21+
tools/
2022
sdist/
2123
var/
2224
wheels/

.pre-commit-config.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: mixed-line-ending
10+
args: [ --fix=lf ]
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.8.6
14+
hooks:
15+
- id: ruff
16+
args: [ --fix ]
17+
- id: ruff
18+
args: [ --fix, --select, I ] # import sorting
19+
- id: ruff-format

Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.PHONY: all
2+
all: venv pre-commit-install help
3+
4+
.PHONY: help
5+
help: ## Display this help.
6+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
7+
8+
##@ Development
9+
10+
.venv: ## Create a virtual environment
11+
@echo "Creating virtual environment..."
12+
@$(MAKE) uv
13+
@$(UV) venv
14+
@$(UV) pip install --requirement pyproject.toml
15+
16+
.PHONY: pre-commit-install
17+
pre-commit-install: uv
18+
@echo "Installing pre-commit hooks..."
19+
@$(UVX) pre-commit install > /dev/null
20+
21+
.PHONY: fmt
22+
fmt: pre-commit-install ## Lint and format files
23+
$(UVX) pre-commit run --all-files
24+
25+
.PHONY: test
26+
test: .venv ## Run tests
27+
$(UV) run coverage run --rcfile=pyproject.toml -m pytest tests/
28+
@$(UV) run coverage html --rcfile=pyproject.toml > /dev/null
29+
@$(UV) run coverage xml --rcfile=pyproject.toml > /dev/null
30+
31+
.PHONY: clean
32+
clean: ## Remove all gitignored files such as downloaded libraries and artifacts
33+
git clean -dfX
34+
35+
##@ Build Tools
36+
TOOLS_DIR ?= tools
37+
$(TOOLS_DIR):
38+
mkdir -p $(TOOLS_DIR)
39+
40+
### Tool Versions
41+
UV_VERSION ?= 0.5.24
42+
43+
UV_DIR ?= $(TOOLS_DIR)/uv-$(UV_VERSION)
44+
UV ?= $(UV_DIR)/uv
45+
UVX ?= $(UV_DIR)/uvx
46+
.PHONY: uv
47+
uv: $(UV) ## Download uv
48+
$(UV): $(TOOLS_DIR)
49+
@test -s $(UV) || { mkdir -p $(UV_DIR); curl -LsSf https://astral.sh/uv/$(UV_VERSION)/install.sh | UV_INSTALL_DIR=$(UV_DIR) sh > /dev/null; }

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PROVES CircuitPython RV3028
22
This is a driver for the RV3028 Real Time Clock originally developed for use on the PROVES Kit Flight Controller V4c.
33

4-
# Usage
5-
This driver needs to be added to the lib folder of the the PySquared board you are currently using. The `pysquared.py` from the current main branch of the `circuitpy_flight_software` should have the required calls to interface with this library.
4+
# Usage
5+
This driver needs to be added to the lib folder of the the PySquared board you are currently using. The `pysquared.py` from the current main branch of the `circuitpy_flight_software` should have the required calls to interface with this library.

pyproject.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[project]
2+
name = "circuitpy-flight-software"
3+
version = "2.0.0"
4+
description = "Flight Software for the PROVES Kit"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"coverage==7.6.10",
9+
"pre-commit==4.0.1",
10+
"pytest==8.3.2",
11+
]
12+
13+
[tool.ruff.format]
14+
# Use `\n` line endings for all files
15+
line-ending = "lf"
16+
17+
[tool.pytest.ini_options]
18+
pythonpath = "."
19+
20+
[tool.coverage.run]
21+
branch = true
22+
relative_files = true
23+
24+
[tool.coverage.report]
25+
show_missing = true
26+
skip_covered = false
27+
include = [
28+
"registers.py",
29+
"rv3028.py",
30+
]
31+
32+
[tool.coverage.html]
33+
directory = "coverage-reports/html"
34+
35+
[tool.coverage.xml]
36+
output = "coverage-reports/coverage.xml"

0 commit comments

Comments
 (0)