Skip to content

Add initial devcontainer support #20960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.pytest_cache
ms-python-insiders.vsix
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

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

Curious, where're these coming from?

41 changes: 41 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": "VSCode Python Dev Container",
// 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"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"charliermarsh.ruff"

],
"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": "14.18"

Choose a reason for hiding this comment

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

@karthiknadig Please advise the node version to use here.

Copy link
Member

Choose a reason for hiding this comment

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

16.17.1

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"version": "14.18"
"version": "16.17.1"

}
}
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
98 changes: 55 additions & 43 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,81 @@
// 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
}
"[JSON]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true
},
"[typescript]": {
"[YAML]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true
},
"[JSON]": {
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"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
},
"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"],
"typescript.preferences.quoteStyle": "single",
"javascript.preferences.quoteStyle": "single",
"typescriptHero.imports.stringQuoteStyle": "'",
"prettier.printWidth": 120,
"prettier.singleQuote": true,
"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,
"javascript.preferences.quoteStyle": "single",
"prettier.printWidth": 120,
"prettier.singleQuote": 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,
"isort.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
}
19 changes: 18 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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 || {};
Expand Down
6 changes: 6 additions & 0 deletions scripts/post_create_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

export PATH="./node_modules/.bin:$PATH"

gulp installPythonLibs
npm ci