Add devcontainer for easier external contribution (#18694)

* add devcontainer

* add readme
This commit is contained in:
Haifeng Jin 2023-10-28 07:39:24 -07:00 committed by GitHub
parent 7d5b12b189
commit bac3a2a377
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

26
.devcontainer/README.md Normal file
View File

@ -0,0 +1,26 @@
# Dev container configurations
This directory contains the configuration for dev containers, which is used to
initialize the development environment in **Codespaces**, **Visual Studio
Code**, and **JetBrains IDEs**. The environment is installed with all the
necessary dependencies for development and is ready for linting, formatting, and
running tests.
* **GitHub Codespaces**. Create a codespace for the repo by clicking
the "Code" button on the main page of the repo, selecting the "Codespaces"
tab, and clicking the "+". The configurations will automatically be used.
Follow
[this guide](https://docs.github.com/en/codespaces/developing-in-a-codespace/creating-a-codespace-for-a-repository)
for more details.
* **Visual Studio Code**. Open the root folder of the repo in VS Code. A
notification will pop up to open it in a dev container with the
configuration. Follow
[this guide](https://code.visualstudio.com/docs/devcontainers/tutorial)
for more details.
* **JetBrains IDEs**. Open the `.devcontainer/devcontainer.json` in your
JetBrains IDE. Click the docker icon to create a dev container.
Follow
[this guide](https://www.jetbrains.com/help/idea/connect-to-devcontainer.html)
for more details.

View File

@ -0,0 +1,30 @@
{
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.10",
"postCreateCommand": "sh ./.devcontainer/setup.sh",
"customizations": {
"vscode": {
"settings": {
"python.testing.pytestEnabled": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"editor.rulers": [
80
]
},
"extensions": [
"ms-python.python",
"ms-python.isort",
"ms-python.flake8",
"ms-python.black-formatter"
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
}
}

4
.devcontainer/setup.sh Normal file
View File

@ -0,0 +1,4 @@
sudo pip install --upgrade pip
sudo pip install -r requirements.txt
echo "bash shell/lint.sh" > .git/hooks/pre-commit
chmod a+x .git/hooks/pre-commit