From 274f099191f3059c1e8077f11113b52f69fb8dc1 Mon Sep 17 00:00:00 2001 From: Christian Nuss Date: Mon, 16 Dec 2024 07:09:51 -0500 Subject: [PATCH 1/4] Update devcontainer.json --- .devcontainer/devcontainer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index cd69f6351401..bc5625416a1c 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,6 @@ { "name": "moto", - "image": "mcr.microsoft.com/devcontainers/python:0-3.11", - "remoteUser": "root", + "image": "mcr.microsoft.com/devcontainers/python:3.11", "features": { "ghcr.io/devcontainers/features/docker-in-docker:2": {} }, From 2f90d1b2002b39b85e50f0dc89b3a0151b4657cd Mon Sep 17 00:00:00 2001 From: Christian Nuss Date: Mon, 16 Dec 2024 14:37:28 +0000 Subject: [PATCH 2/4] Support for Public URLs --- .devcontainer/devcontainer.json | 86 +++++++++++++++++++++++++++++++-- 1 file changed, 83 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bc5625416a1c..08308404b24e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,20 +2,100 @@ "name": "moto", "image": "mcr.microsoft.com/devcontainers/python:3.11", "features": { - "ghcr.io/devcontainers/features/docker-in-docker:2": {} + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "portsAttributes": { + "5000": { + "onAutoForward": "silent", + "elevateIfNeeded": true, + "protocol": "http", + "requireLocalPort": false + } }, "customizations": { "vscode": { - "extensions": ["ms-vscode.makefile-tools", "ms-python.python", "ms-python.black-formatter"], + "extensions": [ + "ms-vscode.makefile-tools", + "ms-python.python", + "ms-python.black-formatter" + ], "settings": { + "editor.formatOnSave": true, "python.defaultInterpreterPath": "${workspaceFolder}/.venv", "python.formatting.provider": "none", "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" + }, + "tasks": { + "version": "2.0.0", + "tasks": [ + { + "label": "Open Port 5000", + "type": "shell", + "command": "bash", + "args": [ + "-c", + "until gh codespace ports visibility 5000:public --codespace ${CODESPACE_NAME} 2>/dev/null; do sleep 1; done" + ] + } + ] + }, + "launch": { + "version": "0.2.0", + "configurations": [ + { + "name": "Debug Moto Server", + "type": "debugpy", + "request": "launch", + "program": "${workspaceFolder}/moto/server.py", + "args": [ + "--reload" + ], + "console": "integratedTerminal", + "presentation": { + "hidden": true + } + }, + { + "name": "Debug Moto Server Tests", + "type": "debugpy", + "request": "launch", + "module": "pytest", + "console": "integratedTerminal", + "preLaunchTask": "Open Port 5000", + "env": { + "TEST_SERVER_MODE": "true", + "TEST_SERVER_MODE_ENDPOINT": "https://${env:CODESPACE_NAME}-5000.${env:GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" + }, + "presentation": { + "hidden": true + }, + "args": [ + "-sv", + "--cov=moto", + "--cov-report=xml", + "${workspaceFolder}/tests/" + ] + }, + ], + "compounds": [ + { + "name": "Run Server Tests", + "configurations": [ + "Debug Moto Server", + "Debug Moto Server Tests" + ], + "presentation": { + "group": "Moto Server" + }, + "stopAll": true + } + ] } } } }, "postCreateCommand": "python -m venv .venv", "postStartCommand": ". .venv/bin/activate && make init" -} +} \ No newline at end of file From afaa2d43d926cdbe4945536fe94fb1077b832ae4 Mon Sep 17 00:00:00 2001 From: Christian Nuss Date: Mon, 16 Dec 2024 14:38:54 +0000 Subject: [PATCH 3/4] remove trailing comma --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 08308404b24e..32d3f9bba05a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -77,7 +77,7 @@ "--cov-report=xml", "${workspaceFolder}/tests/" ] - }, + } ], "compounds": [ { From 37d83a8bc4b9300db932f665fba35953f2b5b7dc Mon Sep 17 00:00:00 2001 From: Christian Nuss Date: Tue, 17 Dec 2024 12:27:22 +0000 Subject: [PATCH 4/4] fix UX --- .devcontainer/devcontainer.json | 53 ++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 32d3f9bba05a..8a77afccfe33 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,6 +13,8 @@ "requireLocalPort": false } }, + "postCreateCommand": "python -m venv .venv", + "postStartCommand": ". .venv/bin/activate && make init", "customizations": { "vscode": { "extensions": [ @@ -37,7 +39,21 @@ "args": [ "-c", "until gh codespace ports visibility 5000:public --codespace ${CODESPACE_NAME} 2>/dev/null; do sleep 1; done" - ] + ], + "presentation": { + "reveal": "silent", + "focus": false + } + }, + { + "label": "Kill MotoServer", + "type": "shell", + "command": "pkill -f '${workspaceFolder}/moto/server.py'", + "problemMatcher": [], + "presentation": { + "reveal": "silent", + "focus": false + } } ] }, @@ -45,49 +61,60 @@ "version": "0.2.0", "configurations": [ { - "name": "Debug Moto Server", + "name": "Run MotoServer", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/moto/server.py", "args": [ "--reload" ], - "console": "integratedTerminal", + "console": "internalConsole", "presentation": { - "hidden": true + "order": 11 } }, { - "name": "Debug Moto Server Tests", + "name": "Run MotoServer Tests", "type": "debugpy", "request": "launch", "module": "pytest", "console": "integratedTerminal", "preLaunchTask": "Open Port 5000", + "postDebugTask": "Kill MotoServer", "env": { "TEST_SERVER_MODE": "true", "TEST_SERVER_MODE_ENDPOINT": "https://${env:CODESPACE_NAME}-5000.${env:GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}" }, "presentation": { - "hidden": true + "order": 12 }, "args": [ "-sv", "--cov=moto", "--cov-report=xml", - "${workspaceFolder}/tests/" + "${workspaceFolder}/tests/", + "-k", + "${input:pytestFilter}" ] } ], + "inputs": [ + { + "id": "pytestFilter", + "type": "promptString", + "description": "pytest -k filter (leave empty to run all tests)", + "default": "" + } + ], "compounds": [ { - "name": "Run Server Tests", + "name": "MotoServer Tests", "configurations": [ - "Debug Moto Server", - "Debug Moto Server Tests" + "Run MotoServer Tests", + "Run MotoServer" ], "presentation": { - "group": "Moto Server" + "order": 1 }, "stopAll": true } @@ -95,7 +122,5 @@ } } } - }, - "postCreateCommand": "python -m venv .venv", - "postStartCommand": ". .venv/bin/activate && make init" + } } \ No newline at end of file