Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ __pycache__
*.egg-info
*/dist/
*.org
*.1
*.1
78e43b91-b6a2-4e0a-99c2-3f6f74828063_ExportBlock-935e0d48-7286-4b74-aa60-ccd18217ac01
node_modules/
CLAUDE.md
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install commitlint --edit "$1"
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Husky hook file doesn’t include a shebang (e.g. #!/usr/bin/env sh). Depending on platform and how Git executes the hook, a missing shebang can cause the hook to fail to run. Add the standard Husky header (and any required initialization for your Husky major version) so the hook executes reliably.

Copilot uses AI. Check for mistakes.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx --no-install validate-branch-name && npx --no-install git-precommit-checks && npx --no-install lint-staged
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These Husky hook files don’t include a shebang (e.g. #!/usr/bin/env sh). Depending on platform and how Git executes the hook, a missing shebang can cause the hook to fail to run. Add the standard Husky header (and any required initialization for your Husky major version) so the hooks execute reliably.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Mark Husky hook scripts executable

These hook files were added with mode 100644, so Git ignores them instead of executing them (.husky/pre-commit/.husky/commit-msg are treated as non-executable). In a fresh clone this means the new commit-msg and pre-commit checks are silently bypassed, so invalid commit messages and unlinted staged Python changes can still be committed even after make setup.

Useful? React with 👍 / 👎.

64 changes: 64 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
.DEFAULT_GOAL := help

PORT ?= /dev/ttyACM0

# --- Development setup ---

.PHONY: install
install: ## Install dev tools and git hooks
pip install ruff pytest
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install installs ruff/pytest without the repo’s pinned dev requirements and misses dependencies that the repo actually uses (e.g. pyyaml for tests and mpremote for repl/mount and hardware test runner). Consider installing from .github/workflows/requirements.txt (keeps versions aligned with CI) and include mpremote, using python -m pip to respect the active venv.

Suggested change
pip install ruff pytest
python3 -m pip install -r .github/workflows/requirements.txt mpremote

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Install PyYAML in dev setup target

make install currently installs only ruff and pytest, but the test suite imports yaml (for example in tests/conftest.py and tests/test_scenarios.py). On a fresh environment, following this new workflow causes make test to fail with ModuleNotFoundError: No module named 'yaml', so the advertised setup target does not actually provision the dependencies needed for testing.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Install Python tools with the same interpreter used for tests

The Makefile installs dependencies with bare pip but runs tests with python3 -m pytest; on systems where pip targets a different interpreter (or is missing while only pip3 exists), make install succeeds/fails inconsistently and make test can still raise missing-module errors. Installing via python3 -m pip keeps the environment aligned with the test runner.

Useful? React with 👍 / 👎.

npm install

Comment on lines +21 to +24
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pip install -e ... can pick up the wrong Python environment (e.g., if pip points to a different interpreter than python3). Using python3 -m pip install -e ... (or $(PYTHON) -m pip with a configurable PYTHON var) makes the install target more reliable.

Copilot uses AI. Check for mistakes.
# --- Linting ---

.PHONY: lint
lint: ## Run ruff linter
ruff check

.PHONY: lint-fix
lint-fix: ## Auto-fix lint issues
ruff check --fix

# --- Testing ---

.PHONY: test
test: ## Run all mock tests (no hardware needed)
python3 -m pytest tests/ -v -k mock

.PHONY: test-hw
test-hw: ## Run hardware tests (needs board on PORT)
python3 -m pytest tests/ -v --port $(PORT) -s

.PHONY: test-all
test-all: ## Run all tests (mock + hardware)
python3 -m pytest tests/ -v --port $(PORT) -s

.PHONY: test-driver
test-driver: ## Run tests for one driver (usage: make test-driver DRIVER=hts221)
python3 -m pytest tests/ -v -k "$(DRIVER)" --port $(PORT) -s
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test-driver uses -k "$(DRIVER)", but this test suite already provides a dedicated --driver option in tests/conftest.py. Using -k will match substrings in nodeids and may select the wrong set of tests (or none). Switch this to --driver $(DRIVER) to match the documented/implemented driver filter.

Suggested change
python3 -m pytest tests/ -v -k "$(DRIVER)" --port $(PORT) -s
python3 -m pytest tests/ -v --driver $(DRIVER) --port $(PORT) -s

Copilot uses AI. Check for mistakes.

.PHONY: test-examples
test-examples: ## Validate all example files (syntax + imports)
python3 -m pytest tests/test_examples.py -v

# --- Hardware ---

.PHONY: repl
repl: ## Open MicroPython REPL on the board
mpremote connect $(PORT)

.PHONY: mount
mount: ## Mount lib/ on the board for live testing
mpremote connect $(PORT) mount lib/

# --- Utilities ---

.PHONY: clean
clean: ## Remove build artifacts and caches
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true
find . -type d -name .ruff_cache -exec rm -rf {} + 2>/dev/null || true

.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
53 changes: 53 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'subject-case': [0],
'subject-full-stop': [0],
'header-max-length': [2, 'always', 78],
'scope-enum': [
1,
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scope-enum is configured with severity 1 (warning), which means invalid scopes will typically not fail the commit-msg hook. If the intent is to enforce the allowed scopes (as described in the PR), set the rule severity to 2 so invalid scopes are rejected.

Suggested change
1,
2,

Copilot uses AI. Check for mistakes.
'always',
[
'apds9960',
'bme280',
'bq27441',
'daplink_flash',
'gc9a01',
'hts221',
'im34dt05',
'ism330dl',
'lis2mdl',
'mcp23009e',
'ssd1327',
'steami_config',
'vl53l1x',
'wsen-hids',
'wsen-pads',
'ci',
'docs',
'style',
'tests',
'tooling',
],
],
'type-enum': [
2,
'always',
[
'build',
Comment on lines +38 to +42
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Allow existing scope-only commit subjects

The new type-enum restricts the leading token to conventional types and excludes driver scopes (e.g. hts221, ism330dl), so commit messages in the repository’s established <scope>: <Description.> format are rejected by the new commit-msg hook. This blocks contributors using the documented/project-native format unless they switch to a different convention, which creates workflow breakage.

Useful? React with 👍 / 👎.

'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'tooling',
],
],
'body-max-line-length': [1, 'always', 100],
},
};
Loading
Loading