From 8c7415a4b1e56288b718b227dd7c0db84561d86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Sat, 22 Apr 2023 13:40:21 +0200 Subject: [PATCH 1/8] Add initial devcontainer support --- .devcontainer/.dockerignore | 3 +++ .devcontainer/Dockerfile | 29 +++++++++++++++++++++++ .devcontainer/devcontainer.json | 41 +++++++++++++++++++++++++++++++++ scripts/post_create_command.sh | 7 ++++++ 4 files changed, 80 insertions(+) create mode 100644 .devcontainer/.dockerignore create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 scripts/post_create_command.sh diff --git a/.devcontainer/.dockerignore b/.devcontainer/.dockerignore new file mode 100644 index 000000000000..3040a317c0bf --- /dev/null +++ b/.devcontainer/.dockerignore @@ -0,0 +1,3 @@ +node_modules +.pytest_cache +ms-python-insiders.vsix \ No newline at end of file diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000000..c9088b76e3a8 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,29 @@ +FROM mcr.microsoft.com/devcontainers/python:3.7 + +ENV CI_PYTHON_PATH=python + +RUN python -m pip install --upgrade pip + +COPY build/test-requirements.txt ./ +RUN python -m pip install -r test-requirements.txt \ + && rm test-requirements.txt + +COPY build/smoke-test-requirements.txt ./ +RUN python -m pip install -r smoke-test-requirements.txt \ + && rm smoke-test-requirements.txt + +COPY build/functional-test-requirements.txt ./ +RUN python -m pip install -r functional-test-requirements.txt \ + && rm functional-test-requirements.txt + +COPY build/functional-test-requirements.txt ./ +RUN python -m pip install -r functional-test-requirements.txt \ + && rm functional-test-requirements.txt + +COPY build/debugger-install-requirements.txt ./ +RUN python -m pip install -r debugger-install-requirements.txt \ + && rm debugger-install-requirements.txt + + +RUN apt-get update +RUN apt-get install -y libatk1.0-0 libatk-bridge2.0-0 libdrm2 libgtk-3-0 libgbm-dev libasound2 \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000000..24ce34024a53 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,41 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/python +{ + "name": "Python 3", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "build": { + "dockerfile": "./Dockerfile", + "context": ".." + }, + "customizations": { + "vscode": { + "extensions": [ + "editorconfig.editorconfig", + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "ms-python.python", + "ms-python.black-formatter", + "ms-python.vscode-pylance" + ], + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python" + } + } + }, + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "bash scripts/post_create_command.sh", + "features": { + "ghcr.io/devcontainers/features/node:1": { + "nodeGypDependencies": true, + "version": "16" + } + }, + // Configure tool-specific properties. + // "customizations": {}, + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} \ No newline at end of file diff --git a/scripts/post_create_command.sh b/scripts/post_create_command.sh new file mode 100644 index 000000000000..c171ca326073 --- /dev/null +++ b/scripts/post_create_command.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +export PATH="./node_modules/.bin:$PATH" + +gulp installPythonLibs +npm install +npm run compile \ No newline at end of file From b3bdc3343907b652087ad733e9ec5d8b65328594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Sun, 7 May 2023 19:05:35 +0200 Subject: [PATCH 2/8] Add missing settings Added defaultFormatter for Python and tests location for Pytest. --- .vscode/settings.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 174a850c901e..f17b07795237 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,28 +26,43 @@ "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.organizeImports": true - } + }, + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnPaste": true }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, "editor.formatOnSave": true }, "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, "editor.formatOnSave": true }, "[JSON]": { "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, + "editor.formatOnSave": true + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, "editor.formatOnSave": true }, "[YAML]": { "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnPaste": true, "editor.formatOnSave": true }, + "files.autoSave": "onFocusChange", + "files.trimTrailingWhitespace": true, + "typescript.tsc.autoDetect": "off", "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version "python.linting.enabled": false, "python.formatting.provider": "black", "python.sortImports.args": ["--profile", "black"], + "python.testing.pytestArgs": ["src/test/pythonFiles"], "typescript.preferences.quoteStyle": "single", "javascript.preferences.quoteStyle": "single", "typescriptHero.imports.stringQuoteStyle": "'", From 9c7e083973e5314b7b9ab1cec09ca6abd90f4520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Sun, 7 May 2023 19:08:17 +0200 Subject: [PATCH 3/8] Sort settings.json alphabetically Used `richie5um2.vscode-sort-json` extension --- .vscode/settings.json | 98 +++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index f17b07795237..ebedb98122b9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,46 +1,16 @@ // Place your settings in this file to overwrite default and user settings. { - "files.exclude": { - "out": true, // set this to true to hide the "out" folder with the compiled JS files - "dist": true, - "**/*.pyc": true, - ".nyc_output": true, - "obj": true, - "bin": true, - "**/__pycache__": true, - "**/node_modules": true, - ".vscode-test": false, - ".vscode test": false, - "**/.mypy_cache/**": true - }, - "search.exclude": { - "out": true, // set this to false to include "out" folder in search results - "dist": true, - "**/node_modules": true, - "coverage": true, - "languageServer*/**": true, - ".vscode-test": true, - ".vscode test": true - }, - "[python]": { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true - }, - "editor.defaultFormatter": "ms-python.black-formatter", - "editor.formatOnPaste": true - }, - "[typescript]": { + "[JSON]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnPaste": true, "editor.formatOnSave": true }, - "[javascript]": { + "[YAML]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnPaste": true, "editor.formatOnSave": true }, - "[JSON]": { + "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnPaste": true, "editor.formatOnSave": true @@ -50,35 +20,65 @@ "editor.formatOnPaste": true, "editor.formatOnSave": true }, - "[YAML]": { + "[python]": { + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "editor.defaultFormatter": "ms-python.black-formatter", + "editor.formatOnPaste": true, + "editor.formatOnSave": true + }, + "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnPaste": true, "editor.formatOnSave": true }, + "cucumberautocomplete.skipDocStringsFormat": true, + "debug.javascript.usePreview": false, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, "files.autoSave": "onFocusChange", + "files.exclude": { + "**/*.pyc": true, + "**/.mypy_cache/**": true, + "**/__pycache__": true, + "**/node_modules": true, + ".nyc_output": true, + ".vscode test": false, + ".vscode-test": false, + "bin": true, + "dist": true, + "obj": true, + "out": true // set this to true to hide the "out" folder with the compiled JS files + }, "files.trimTrailingWhitespace": true, - "typescript.tsc.autoDetect": "off", - "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version - "python.linting.enabled": false, - "python.formatting.provider": "black", - "python.sortImports.args": ["--profile", "black"], - "python.testing.pytestArgs": ["src/test/pythonFiles"], - "typescript.preferences.quoteStyle": "single", "javascript.preferences.quoteStyle": "single", - "typescriptHero.imports.stringQuoteStyle": "'", "prettier.printWidth": 120, "prettier.singleQuote": true, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, + "python.formatting.provider": "black", "python.languageServer": "Default", - "python.linting.pylintEnabled": false, - "python.linting.flake8Enabled": true, - "cucumberautocomplete.skipDocStringsFormat": true, + "python.linting.enabled": false, "python.linting.flake8Args": [ // Match what black does. "--max-line-length=88" ], + "python.linting.flake8Enabled": true, + "python.linting.pylintEnabled": false, + "python.sortImports.args": ["--profile", "black"], + "python.testing.pytestArgs": ["src/test/pythonFiles"], + "search.exclude": { + "**/node_modules": true, + ".vscode test": true, + ".vscode-test": true, + "coverage": true, + "dist": true, + "languageServer*/**": true, + "out": true // set this to false to include "out" folder in search results + }, "typescript.preferences.importModuleSpecifier": "relative", - "debug.javascript.usePreview": false + "typescript.preferences.quoteStyle": "single", + "typescript.tsc.autoDetect": "off", + "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version + "typescriptHero.imports.stringQuoteStyle": "'" } From 2994977e7cb91aeada0339b43cfaa7c56cc87321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Tue, 2 May 2023 13:04:20 +0200 Subject: [PATCH 4/8] Remove unknown configuration settings --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index ebedb98122b9..daf813882b9b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -33,8 +33,6 @@ "editor.formatOnPaste": true, "editor.formatOnSave": true }, - "cucumberautocomplete.skipDocStringsFormat": true, - "debug.javascript.usePreview": false, "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, @@ -80,5 +78,4 @@ "typescript.preferences.quoteStyle": "single", "typescript.tsc.autoDetect": "off", "typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version - "typescriptHero.imports.stringQuoteStyle": "'" } From a95cacebc58091eb7ebd3ead091fa932a4f7c6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Tue, 2 May 2023 13:06:39 +0200 Subject: [PATCH 5/8] Replace Python sortImports settings property `python.sortImports.args` property will be removed soon --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index daf813882b9b..7a58cf0eee8f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -63,7 +63,7 @@ ], "python.linting.flake8Enabled": true, "python.linting.pylintEnabled": false, - "python.sortImports.args": ["--profile", "black"], + "isort.args": ["--profile", "black"], "python.testing.pytestArgs": ["src/test/pythonFiles"], "search.exclude": { "**/node_modules": true, From a2f99f6f18c030d9df612741f24b25c561cb6caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Tue, 2 May 2023 13:09:46 +0200 Subject: [PATCH 6/8] Use node.js v14 for DevContainer --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 24ce34024a53..9c800a5f1a00 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -31,7 +31,7 @@ "features": { "ghcr.io/devcontainers/features/node:1": { "nodeGypDependencies": true, - "version": "16" + "version": "14.18" } }, // Configure tool-specific properties. From 5d6fb2882da5d002898263692b3b7c7e47f7eeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Tue, 2 May 2023 11:41:46 +0000 Subject: [PATCH 7/8] Add wheel and pip upgrade as a new gulp task Set it as the 1st one to the existent `installPythonLibs` gulp task --- gulpfile.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index a344b165a6cc..37cb42a31b61 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -226,6 +226,23 @@ gulp.task('prePublishBundle', gulp.series('webpack', 'renameSourceMaps')); gulp.task('checkDependencies', gulp.series('checkNativeDependencies')); gulp.task('prePublishNonBundle', gulp.series('compile')); +gulp.task('preparePythonDeps', async () => { + let args = ['-m', 'pip', 'install', '-U', 'pip']; + await spawnAsync(process.env.CI_PYTHON_PATH || 'python', args, undefined, true) + .then(() => true) + .catch((ex) => { + console.error("Failed to upgrade pip using 'python'", ex); + return false; + }); + args = ['-m', 'pip', 'install', 'wheel']; + await spawnAsync(process.env.CI_PYTHON_PATH || 'python', args, undefined, true) + .then(() => true) + .catch((ex) => { + console.error("Failed to install wheel requirement using 'python'", ex); + return false; + }); +}); + gulp.task('installPythonRequirements', async () => { let args = [ '-m', @@ -308,7 +325,7 @@ gulp.task('installDebugpy', async () => { rmrf.sync('./pythonFiles/lib/temp'); }); -gulp.task('installPythonLibs', gulp.series('installPythonRequirements', 'installDebugpy')); +gulp.task('installPythonLibs', gulp.series('preparePythonDeps', 'installPythonRequirements', 'installDebugpy')); function spawnAsync(command, args, env, rejectOnStdErr = false) { env = env || {}; From 315681dd02f8aa84aa293c4dfa8903008c032d81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Pi=C3=B1a?= Date: Tue, 2 May 2023 11:43:01 +0000 Subject: [PATCH 8/8] Apply changes to post create command - Replace npm install by npm ci in devcontainer - Remove npm run compile --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 6 +++--- scripts/post_create_command.sh | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index c9088b76e3a8..eac80f12a620 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -26,4 +26,4 @@ RUN python -m pip install -r debugger-install-requirements.txt \ RUN apt-get update -RUN apt-get install -y libatk1.0-0 libatk-bridge2.0-0 libdrm2 libgtk-3-0 libgbm-dev libasound2 \ No newline at end of file +RUN apt-get install -y libatk1.0-0 libatk-bridge2.0-0 libdrm2 libgtk-3-0 libgbm-dev libasound2 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9c800a5f1a00..1f7a2262abdf 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/python { - "name": "Python 3", + "name": "VSCode Python Dev Container", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "build": { "dockerfile": "./Dockerfile", @@ -33,9 +33,9 @@ "nodeGypDependencies": true, "version": "14.18" } - }, + } // Configure tool-specific properties. // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" -} \ No newline at end of file +} diff --git a/scripts/post_create_command.sh b/scripts/post_create_command.sh index c171ca326073..8465fe89e365 100644 --- a/scripts/post_create_command.sh +++ b/scripts/post_create_command.sh @@ -3,5 +3,4 @@ export PATH="./node_modules/.bin:$PATH" gulp installPythonLibs -npm install -npm run compile \ No newline at end of file +npm ci