Skip to content

Commit 3761702

Browse files
committed
tooling: Add Makefile and npm hooks for dev workflow.
1 parent abcb813 commit 3761702

7 files changed

Lines changed: 2310 additions & 1 deletion

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ __pycache__
33
*.egg-info
44
*/dist/
55
*.org
6-
*.1
6+
*.1
7+
78e43b91-b6a2-4e0a-99c2-3f6f74828063_ExportBlock-935e0d48-7286-4b74-aa60-ccd18217ac01
8+
node_modules/
9+
CLAUDE.md

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no-install commitlint --edit "$1"

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no-install validate-branch-name && npx --no-install git-precommit-checks && npx --no-install lint-staged

Makefile

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
.DEFAULT_GOAL := help
2+
3+
PORT ?= /dev/ttyACM0
4+
5+
# --- Development setup ---
6+
7+
.PHONY: install
8+
install: ## Install dev tools and git hooks
9+
pip install ruff pytest
10+
npm install
11+
12+
# --- Linting ---
13+
14+
.PHONY: lint
15+
lint: ## Run ruff linter
16+
ruff check
17+
18+
.PHONY: lint-fix
19+
lint-fix: ## Auto-fix lint issues
20+
ruff check --fix
21+
22+
# --- Testing ---
23+
24+
.PHONY: test
25+
test: ## Run all mock tests (no hardware needed)
26+
python3 -m pytest tests/ -v -k mock
27+
28+
.PHONY: test-hw
29+
test-hw: ## Run hardware tests (needs board on PORT)
30+
python3 -m pytest tests/ -v --port $(PORT) -s
31+
32+
.PHONY: test-all
33+
test-all: ## Run all tests (mock + hardware)
34+
python3 -m pytest tests/ -v --port $(PORT) -s
35+
36+
.PHONY: test-driver
37+
test-driver: ## Run tests for one driver (usage: make test-driver DRIVER=hts221)
38+
python3 -m pytest tests/ -v -k "$(DRIVER)" --port $(PORT) -s
39+
40+
.PHONY: test-examples
41+
test-examples: ## Validate all example files (syntax + imports)
42+
python3 -m pytest tests/test_examples.py -v
43+
44+
# --- Hardware ---
45+
46+
.PHONY: repl
47+
repl: ## Open MicroPython REPL on the board
48+
mpremote connect $(PORT)
49+
50+
.PHONY: mount
51+
mount: ## Mount lib/ on the board for live testing
52+
mpremote connect $(PORT) mount lib/
53+
54+
# --- Utilities ---
55+
56+
.PHONY: clean
57+
clean: ## Remove build artifacts and caches
58+
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
59+
find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
60+
find . -type d -name .ruff_cache -exec rm -rf {} + 2>/dev/null || true
61+
62+
.PHONY: help
63+
help: ## Show this help
64+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'

commitlint.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'subject-case': [0],
5+
'subject-full-stop': [0],
6+
'header-max-length': [2, 'always', 78],
7+
'scope-enum': [
8+
1,
9+
'always',
10+
[
11+
'apds9960',
12+
'bme280',
13+
'bq27441',
14+
'daplink_flash',
15+
'gc9a01',
16+
'hts221',
17+
'im34dt05',
18+
'ism330dl',
19+
'lis2mdl',
20+
'mcp23009e',
21+
'ssd1327',
22+
'steami_config',
23+
'vl53l1x',
24+
'wsen-hids',
25+
'wsen-pads',
26+
'ci',
27+
'docs',
28+
'style',
29+
'tests',
30+
'tooling',
31+
],
32+
],
33+
'type-enum': [
34+
2,
35+
'always',
36+
[
37+
'build',
38+
'chore',
39+
'ci',
40+
'docs',
41+
'feat',
42+
'fix',
43+
'perf',
44+
'refactor',
45+
'revert',
46+
'style',
47+
'test',
48+
'tooling',
49+
],
50+
],
51+
'body-max-line-length': [1, 'always', 100],
52+
},
53+
};

0 commit comments

Comments
 (0)