-
Notifications
You must be signed in to change notification settings - Fork 1
tooling: Add devcontainer for Python/MicroPython development. #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
222b03b
aa25253
ee7d4f8
521fb26
d669ed9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| FROM mcr.microsoft.com/devcontainers/python:3.10 | ||
|
|
||
| # System packages for firmware build and board communication | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| gcc-arm-none-eabi \ | ||
| libnewlib-arm-none-eabi \ | ||
| openocd \ | ||
| udev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # udev rules for STeaMi board (DAPLink / STM32) | ||
| RUN mkdir -p /etc/udev/rules.d \ | ||
| && echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="0d28", MODE="0666"' \ | ||
| > /etc/udev/rules.d/99-steami.rules |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,92 @@ | ||||
| { | ||||
| "name": "STeaMi MicroPython Dev", | ||||
| "build": { | ||||
| "dockerfile": "Dockerfile" | ||||
| }, | ||||
|
|
||||
| // USB access for STeaMi board (DAPLink / mpremote / OpenOCD). | ||||
| // Privileged mode is required for firmware flashing and board communication. | ||||
| // This is incompatible with GitHub Codespaces but essential for local use. | ||||
| "privileged": true, | ||||
| "mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"], | ||||
| "runArgs": ["--device=/dev/bus/usb"], | ||||
|
||||
| "runArgs": ["--device=/dev/bus/usb"], |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ __pycache__ | |
| node_modules/ | ||
| CLAUDE.md | ||
| .build/ | ||
| .venv/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "recommendations": [ | ||
| "charliermarsh.ruff", | ||
| "ms-python.python", | ||
| "ms-python.vscode-pylance", | ||
| "ms-vscode.vscode-serial-monitor", | ||
| "esbenp.prettier-vscode", | ||
| "github.vscode-pull-request-github", | ||
| "vivaxy.vscode-conventional-commits" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "python.languageServer": "Pylance", | ||
| "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python", | ||
| "python.analysis.typeCheckingMode": "basic", | ||
| "python.analysis.extraPaths": [ | ||
| "lib/apds9960", | ||
| "lib/bme280", | ||
| "lib/bq27441", | ||
| "lib/daplink_flash", | ||
| "lib/gc9a01", | ||
| "lib/hts221", | ||
| "lib/im34dt05", | ||
| "lib/ism330dl", | ||
| "lib/lis2mdl", | ||
| "lib/mcp23009e", | ||
| "lib/ssd1327", | ||
| "lib/steami_config", | ||
| "lib/vl53l1x", | ||
| "lib/wsen-hids", | ||
| "lib/wsen-pads" | ||
| ], | ||
| "python.analysis.stubPath": "typings", | ||
| "python.analysis.diagnosticSeverityOverrides": { | ||
| "reportMissingModuleSource": "none", | ||
| "reportWildcardImportFromLibrary": "none", | ||
| "reportGeneralTypeIssues": "warning" | ||
| }, | ||
| "pylint.enabled": false, | ||
| "mypy-type-checker.enabled": false | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,9 +83,40 @@ docs: Update README driver table. | |
| test(mcp23009e): Add mock scenarios for mcp23009e driver. | ||
| ``` | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| For local development (without dev container): | ||
|
||
|
|
||
| * Python 3.10+ | ||
| * Node.js 22+ (for husky, commitlint, lint-staged, semantic-release) | ||
| * `arm-none-eabi-gcc` toolchain (for `make firmware`) | ||
| * OpenOCD (for `make deploy`) | ||
| * `mpremote` (installed via `pip install -e ".[test]"`) | ||
| * GitHub CLI (`gh`) | ||
|
|
||
| Then run `make setup` to install all dependencies and git hooks. This creates a `.venv` with ruff, pytest, mpremote, and MicroPython type stubs for Pylance. | ||
|
|
||
| ## Dev Container | ||
|
|
||
| A dev container is available for VS Code (local Docker only, not GitHub Codespaces). It includes all prerequisites out of the box: Python 3.10, Node.js 22, ruff, pytest, mpremote, arm-none-eabi-gcc, OpenOCD, and the GitHub CLI. | ||
|
|
||
| 1. Open the repository in VS Code | ||
| 2. When prompted, click **Reopen in Container** (or use the command palette: *Dev Containers: Reopen in Container*) | ||
| 3. The container runs `make setup` automatically on creation | ||
|
|
||
| The container also provides: | ||
|
|
||
| * **zsh + oh-my-zsh** as default shell with persistent shell history | ||
| * **Pylance** configured with MicroPython STM32 stubs (no false `import machine` errors) | ||
| * **Serial Monitor** extension for board communication | ||
| * **USB passthrough** for mpremote, OpenOCD, and firmware flashing (the container runs in privileged mode with `/dev/bus/usb` mounted) | ||
| * **udev rules** for the DAPLink interface (auto-started on container creation) | ||
|
|
||
| Note: GitHub Codespaces is not supported because the container requires privileged mode and USB device access for board communication. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Set up your environment: `make setup` | ||
| 1. Set up your environment: open in the dev container, or run `make setup` locally | ||
| 2. Create a branch from main (format: `feat/`, `fix/`, `docs/`, `tooling/`, `ci/`, `test/`, `style/`, `chore/`, `refactor/`) | ||
| 3. Write your code and add tests in `tests/scenarios/<driver>.yaml` | ||
| 4. Run `make ci` to verify everything passes (lint + tests + examples) | ||
|
|
@@ -142,7 +173,7 @@ The firmware source is cloned into `.build/micropython-steami/` (gitignored). A | |
|
|
||
| Use `make firmware` for normal rebuilds from the existing local clone. Use `make firmware-update` only when you want to refresh the `micropython-steami` checkout itself or resync the board-specific submodules before rebuilding. | ||
|
|
||
| **Requirements**: `arm-none-eabi-gcc` toolchain, OpenOCD for flashing, and `mpremote` for running scripts on the board. | ||
| All these tools are included in the dev container. For local development, see the [Prerequisites](#prerequisites) section. | ||
|
|
||
| ## Notes | ||
|
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |||||
| "private": true, | ||||||
| "description": "MicroPython driver library for the STeaMi board.", | ||||||
| "engines": { | ||||||
| "node": ">=20.17" | ||||||
| "node": ">=22" | ||||||
|
||||||
| "node": ">=22" | |
| "node": ">=20.17" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The devcontainer is advertised as working in GitHub Codespaces, but
privileged: trueplus USB device mounts (/dev/bus/usb) are generally unsupported there and can prevent the container from starting. Consider making USB passthrough optional (e.g., via a separate/local override devcontainer config) and keeping the default config Codespaces-compatible.