Skip to content

Commit

Permalink
Add devcontainer for easier external contribution (#18694)
Browse files Browse the repository at this point in the history
* add devcontainer

* add readme
  • Loading branch information
haifeng-jin authored Oct 28, 2023
1 parent 7d5b12b commit bac3a2a
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -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.
30 changes: 30 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit bac3a2a

Please sign in to comment.