Skip to content

tooling: Add devcontainer for Python/MicroPython development.#275

Merged
nedseb merged 5 commits into
mainfrom
tooling/add-devcontainer
Mar 28, 2026
Merged

tooling: Add devcontainer for Python/MicroPython development.#275
nedseb merged 5 commits into
mainfrom
tooling/add-devcontainer

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 28, 2026

Summary

  • Add .devcontainer/Dockerfile and devcontainer.json for VS Code
  • Container includes Python 3.10, Node.js 22, ruff, pytest, mpremote, arm-none-eabi-gcc, OpenOCD, udev, and gh CLI
  • zsh + oh-my-zsh as default shell with persistent shell history
  • USB passthrough (privileged mode + /dev/bus/usb bind mount) for mpremote, OpenOCD, and firmware flashing
  • udev rules and daemon for DAPLink interface hot-plug detection
  • Devcontainer uses a separate venv (/home/vscode/.venv) to avoid conflicts with the local .venv
  • Local development uses .venv (gitignored) created by make setup
  • MicroPython STM32 stubs installed in venv for Pylance type checking
  • Minimal typings/time.pyi stub to override CPython typeshed for MicroPython sleep_ms, ticks_ms, etc.
  • Pylint and Mypy disabled in workspace (project uses ruff + Pylance only)
  • .vscode/settings.json with Pylance config and per-driver extraPaths
  • .vscode/extensions.json with recommended extensions
  • pyrightconfig.json at project root for consistent analysis
  • Node.js version standardized to 22 across CI, devcontainer, and package.json
  • Makefile: configurable VENV_DIR, auto-creates venv, all commands use venv Python
  • clean handles egg-info, deepclean handles venv
  • CONTRIBUTING.md updated with Prerequisites, Dev Container docs, and venv workflow

Closes #264

Test plan

  • make setup creates venv and installs all dependencies
  • make ci passes (lint + mock tests + example validation)
  • Dev container builds and opens in VS Code
  • Local .venv and devcontainer venv don't conflict
  • Pylance resolves from time import sleep_ms without errors
  • Pylance resolves driver imports (from apds9960 import ...) in examples
  • No false positives from Pylint/Mypy (disabled)
  • zsh default shell with oh-my-zsh in container
  • Connect STeaMi board and verify USB passthrough

Copilot AI review requested due to automatic review settings March 28, 2026 06:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.json to define the devcontainer build, VS Code settings, and postCreateCommand.
  • Add .devcontainer/Dockerfile to 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.

Comment thread .devcontainer/Dockerfile Outdated
Comment on lines +10 to +13
# 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 \
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 28, 2026

La remarque de Copilot sur le curl dans le Dockerfile est déjà résolue : le deuxième commit (4b03ce1) a remplacé l'installation manuelle de Node.js et gh CLI par des devcontainer features. Le Dockerfile ne contient plus aucun curl.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread package.json
"description": "MicroPython driver library for the STeaMi board.",
"engines": {
"node": ">=20.17"
"node": ">=22"
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
"node": ">=22"
"node": ">=20.17"

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +10
"privileged": true,
"mounts": ["type=bind,source=/dev/bus/usb,target=/dev/bus/usb"],
"runArgs": ["--device=/dev/bus/usb"],
Copy link

Copilot AI Mar 28, 2026

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: 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.

Suggested change
"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"],

Copilot uses AI. Check for mistakes.
// 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"],
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
"runArgs": ["--device=/dev/bus/usb"],

Copilot uses AI. Check for mistakes.
Comment thread CONTRIBUTING.md

## Prerequisites

For local development (without dev container):
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

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).

Copilot uses AI. Check for mistakes.
@nedseb
Copy link
Copy Markdown
Contributor Author

nedseb commented Mar 28, 2026

Commentaires Copilot traités dans 3260327 :

  1. curl dans le Dockerfile — déjà résolu dans un commit précédent (Node.js et gh CLI installés via devcontainer features).
  2. Node >=22 breaking change — choix intentionnel pour uniformiser avec le CI (release.yml utilisait déjà Node 22). Documenté dans CONTRIBUTING.md (section Prerequisites).
  3. privileged + Codespacesprivileged: true est maintenu volontairement : l'upload sur la carte STeaMi (mpremote, OpenOCD) est prioritaire sur la compatibilité Codespaces. Commentaire ajouté dans le fichier pour expliquer ce choix.
  4. mounts + runArgs redondants — mount est là pour le montage à chaud de la carte donc il n'est pas redondant.
  5. Node.js 20 dans CONTRIBUTING — déjà corrigé dans un commit précédent (section Prerequisites dit Node.js 22+).

@nedseb nedseb force-pushed the tooling/add-devcontainer branch from 98f166f to 076ba07 Compare March 28, 2026 14:56
@nedseb nedseb force-pushed the tooling/add-devcontainer branch from 076ba07 to d669ed9 Compare March 28, 2026 15:05
@nedseb nedseb merged commit d3a7673 into main Mar 28, 2026
7 checks passed
@nedseb nedseb deleted the tooling/add-devcontainer branch March 28, 2026 15:07
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.1.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: Add devcontainer for Python/MicroPython development environment.

2 participants