From 6a5e73c85675b5fc8927e71d1587b36a7c5d1ec3 Mon Sep 17 00:00:00 2001 From: Igor Lins e Silva <4753812+igorls@users.noreply.github.com> Date: Tue, 14 Apr 2026 15:10:23 -0300 Subject: [PATCH] feat: add VSCode devcontainer matching CI environment Contributors now get a one-click dev environment that mirrors CI exactly: Python 3.11 (middle of the 3.9/3.11/3.13 matrix), ruff pinned to the same >=0.4.0,<0.5 range CI enforces, and pre-commit hooks auto-installed from the existing .pre-commit-config.yaml. Pinning ruff in post-create.sh is the load-bearing piece: pyproject only sets a floor, so without the pin the ruff extension would install 0.15.x and phantom-fail lint against CI's 0.4.x. --- .devcontainer/devcontainer.json | 25 +++++++++++++++++++++++++ .devcontainer/post-create.sh | 21 +++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100755 .devcontainer/post-create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..41a4f13 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "name": "MemPalace", + "image": "mcr.microsoft.com/devcontainers/python:3.11", + "features": { + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "postCreateCommand": "bash .devcontainer/post-create.sh", + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "ms-python.debugpy", + "charliermarsh.ruff" + ], + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": ["tests/", "-v", "--ignore=tests/benchmarks"], + "ruff.importStrategy": "fromEnvironment", + "editor.formatOnSave": true, + "editor.defaultFormatter": "charliermarsh.ruff" + } + } + } +} diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh new file mode 100755 index 0000000..c9a5c0e --- /dev/null +++ b/.devcontainer/post-create.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "=== MemPalace Dev Container Setup ===" + +pip install -e ".[dev]" + +# Match CI's ruff pin (pyproject only sets a floor; without this contributors +# get a newer ruff locally than CI runs, causing phantom lint failures). +pip install "ruff>=0.4.0,<0.5" + +pip install pre-commit +pre-commit install + +echo "" +echo "=== Verification ===" +echo "python: $(python --version)" +echo "pytest: $(python -m pytest --version 2>&1 | head -1)" +echo "ruff: $(python -m ruff --version 2>&1 | head -1)" +echo "" +echo "Ready. Run: pytest tests/ -v --ignore=tests/benchmarks"