tooling: Add devcontainer for Python/MicroPython development.#275
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a VS Code / GitHub Codespaces devcontainer to provide a consistent, tool-complete environment for developing and testing this MicroPython driver library, and documents how contributors should use it.
Changes:
- Add
.devcontainer/devcontainer.jsonto define the devcontainer build, VS Code settings, andpostCreateCommand. - Add
.devcontainer/Dockerfileto install firmware/tooling dependencies (ARM GCC toolchain, OpenOCD, Node.js 20, GitHub CLI). - Document devcontainer usage in
CONTRIBUTING.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CONTRIBUTING.md | Adds contributor documentation for using the devcontainer. |
| .devcontainer/devcontainer.json | Defines devcontainer build + post-create setup + VS Code customization. |
| .devcontainer/Dockerfile | Builds a Python 3.10-based container with required firmware/tooling packages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Node.js 20 (for husky, commitlint, lint-staged, semantic-release) | ||
| ARG NODE_VERSION=20 | ||
| RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \ | ||
| && apt-get install -y --no-install-recommends nodejs \ |
There was a problem hiding this comment.
The Dockerfile uses curl (for NodeSource and GitHub CLI setup), but it isn’t explicitly installed. To keep the devcontainer build self-contained and resilient to base-image changes, consider installing curl (and typically ca-certificates) via apt-get install before first use.
|
La remarque de Copilot sur le |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "description": "MicroPython driver library for the STeaMi board.", | ||
| "engines": { | ||
| "node": ">=20.17" | ||
| "node": ">=22" |
There was a problem hiding this comment.
Bumping the minimum supported Node version from >=20.17 to >=22 is a breaking change for contributors not using the dev container/CI. If there isn’t a specific dependency requiring Node 22, consider keeping the previous floor (or document the rationale clearly in CONTRIBUTING/README).
| "node": ">=22" | |
| "node": ">=20.17" |
| "privileged": true, | ||
| "mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"], | ||
| "runArgs": ["--device=/dev/bus/usb"], |
There was a problem hiding this comment.
The devcontainer is advertised as working in GitHub Codespaces, but privileged: true plus 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.
| "privileged": true, | |
| "mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"], | |
| "runArgs": ["--device=/dev/bus/usb"], | |
| // NOTE: GitHub Codespaces does not support privileged containers or direct USB device mounts. | |
| // To enable USB passthrough in a local Docker/devcontainer environment, create a | |
| // `.devcontainer/devcontainer.local.json` that extends this config and adds, for example: | |
| // "privileged": true, | |
| // "mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"], | |
| // "runArgs": ["--device=/dev/bus/usb"], |
| // USB access for STeaMi board (DAPLink / mpremote / OpenOCD) | ||
| "privileged": true, | ||
| "mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"], | ||
| "runArgs": ["--device=/dev/bus/usb"], |
There was a problem hiding this comment.
mounts binding /dev/bus/usb and runArgs with --device=/dev/bus/usb are overlapping ways to expose the same device path. Consider keeping just one to reduce redundancy and potential host-compatibility issues.
| "runArgs": ["--device=/dev/bus/usb"], |
|
|
||
| ## Prerequisites | ||
|
|
||
| For local development (without dev container): |
There was a problem hiding this comment.
CONTRIBUTING says the dev container includes Node.js 20, but the actual devcontainer feature and repo engines/CI have been updated to Node 22. Please update this section to match the effective Node version (or adjust the devcontainer/engines back to 20 if that’s the intent).
|
Commentaires Copilot traités dans 3260327 :
|
98f166f to
076ba07
Compare
076ba07 to
d669ed9
Compare
|
🎉 This PR is included in version 0.1.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
.devcontainer/Dockerfileanddevcontainer.jsonfor VS Code/dev/bus/usbbind mount) for mpremote, OpenOCD, and firmware flashing/home/vscode/.venv) to avoid conflicts with the local.venv.venv(gitignored) created bymake setuptypings/time.pyistub to override CPython typeshed for MicroPythonsleep_ms,ticks_ms, etc..vscode/settings.jsonwith Pylance config and per-driverextraPaths.vscode/extensions.jsonwith recommended extensionspyrightconfig.jsonat project root for consistent analysispackage.jsonVENV_DIR, auto-creates venv, all commands use venv Pythoncleanhandles egg-info,deepcleanhandles venvCloses #264
Test plan
make setupcreates venv and installs all dependenciesmake cipasses (lint + mock tests + example validation).venvand devcontainer venv don't conflictfrom time import sleep_mswithout errorsfrom apds9960 import ...) in examples