From bbcf757264bbb15c28ca04d7bb2ea52f0b9eb746 Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Tue, 8 Jul 2025 23:39:08 +0000 Subject: [PATCH 01/11] add post-installation script --- .devcontainer/post-install.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 .devcontainer/post-install.sh diff --git a/.devcontainer/post-install.sh b/.devcontainer/post-install.sh new file mode 100755 index 000000000000..589ee361f5cb --- /dev/null +++ b/.devcontainer/post-install.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +echo "Begin post-installation steps..." + +set -e + +echo "Installing pre-commit hooks..." +pre-commit install + +echo "Installing Oh My Zsh plugins..." + +# Install zsh-autosuggestions if not present +if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then + echo "Cloning zsh-autosuggestions..." + git clone https://github.com/zsh-users/zsh-autosuggestions \ + "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" +fi + +# Install zsh-syntax-highlighting if not present +if [ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]; then + echo "Cloning zsh-syntax-highlighting..." + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git \ + "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" +fi + +echo "Configuring plugins in ~/.zshrc..." +sed -i '/^plugins=/c\plugins=(git zsh-autosuggestions zsh-syntax-highlighting)' ~/.zshrc + +echo "Post-installation steps completed successfully. Enjoy!" From 17f4017e8a0b914d70d08c35baf6dbd17c61de3d Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Tue, 8 Jul 2025 23:41:02 +0000 Subject: [PATCH 02/11] set zsh as default terminal and make post-install execution on postcreate --- .devcontainer/Dockerfile | 5 ++--- .devcontainer/devcontainer.json | 7 +++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a0bd05f47ec8..edee3bc4febb 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,6 +3,5 @@ ARG VARIANT=3.13-bookworm FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT} COPY requirements.txt /tmp/pip-tmp/ RUN python3 -m pip install --upgrade pip \ - && python3 -m pip install --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \ - && pipx install pre-commit ruff \ - && pre-commit install + && python3 -m pip install --no-cache-dir -r /tmp/pip-tmp/requirements.txt \ + && pipx install pre-commit ruff diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e23263f5b9de..4639d24f7814 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,10 +7,12 @@ // Update 'VARIANT' to pick a Python version: 3, 3.11, 3.10, 3.9, 3.8 // Append -bullseye or -buster to pin to an OS version. // Use -bullseye variants on local on arm64/Apple Silicon. - "VARIANT": "3.13-bookworm", + "VARIANT": "3.13-bookworm" } }, + "postCreateCommand": "zsh .devcontainer/post-install.sh", + // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. @@ -20,7 +22,8 @@ "python.defaultInterpreterPath": "/usr/local/bin/python", "python.linting.enabled": true, "python.formatting.blackPath": "/usr/local/py-utils/bin/black", - "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy" + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "terminal.integrated.defaultProfile.linux": "zsh" }, // Add the IDs of extensions you want installed when the container is created. From 68b7d6139a23aa30d68ea843f17b622926ddd2ce Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Tue, 8 Jul 2025 23:46:45 +0000 Subject: [PATCH 03/11] rename file --- .devcontainer/devcontainer.json | 2 +- .devcontainer/{post-install.sh => post_install.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .devcontainer/{post-install.sh => post_install.sh} (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4639d24f7814..6d925f24413e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,7 @@ } }, - "postCreateCommand": "zsh .devcontainer/post-install.sh", + "postCreateCommand": "zsh .devcontainer/post_install.sh", // Configure tool-specific properties. "customizations": { diff --git a/.devcontainer/post-install.sh b/.devcontainer/post_install.sh similarity index 100% rename from .devcontainer/post-install.sh rename to .devcontainer/post_install.sh From b316abd0301bab58f377623cbab8487baf704e9b Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Wed, 9 Jul 2025 00:39:56 +0000 Subject: [PATCH 04/11] rename script --- .devcontainer/{post_install.sh => post_install} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .devcontainer/{post_install.sh => post_install} (100%) diff --git a/.devcontainer/post_install.sh b/.devcontainer/post_install similarity index 100% rename from .devcontainer/post_install.sh rename to .devcontainer/post_install From ce69252de505b623a88ec26a9b222d7936f071ee Mon Sep 17 00:00:00 2001 From: Bertrand Awenze <156874668+bertrand-awz@users.noreply.github.com> Date: Wed, 9 Jul 2025 06:58:08 -0400 Subject: [PATCH 05/11] Create devcontainers_ci.yml --- .github/workflows/devcontainers_ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/devcontainers_ci.yml diff --git a/.github/workflows/devcontainers_ci.yml b/.github/workflows/devcontainers_ci.yml new file mode 100644 index 000000000000..0c66b7ab3d29 --- /dev/null +++ b/.github/workflows/devcontainers_ci.yml @@ -0,0 +1,16 @@ +name: Test DevContainer Build + +on: + push: + branches: [main, test-gh-action-for-devcontainer] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: devcontainers/ci@v0.3 + with: + runCmd: "true" From 1df076d0f0a42560b2b61e8edbf344c563101c79 Mon Sep 17 00:00:00 2001 From: Bertrand Awenze <156874668+bertrand-awz@users.noreply.github.com> Date: Wed, 9 Jul 2025 07:03:38 -0400 Subject: [PATCH 06/11] Update devcontainer.json --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6d925f24413e..4951d5eb268d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,7 @@ } }, - "postCreateCommand": "zsh .devcontainer/post_install.sh", + "postCreateCommand": "zsh .devcontainer/post_install", // Configure tool-specific properties. "customizations": { From 492a88d807072b6fe81f8942df59a5bcdd6995fb Mon Sep 17 00:00:00 2001 From: Bertrand Awenze <156874668+bertrand-awz@users.noreply.github.com> Date: Wed, 9 Jul 2025 07:09:11 -0400 Subject: [PATCH 07/11] Update devcontainers_ci.yml Never push image built here. It's for build testing purpose only. --- .github/workflows/devcontainers_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/devcontainers_ci.yml b/.github/workflows/devcontainers_ci.yml index 0c66b7ab3d29..e18e9b9b395e 100644 --- a/.github/workflows/devcontainers_ci.yml +++ b/.github/workflows/devcontainers_ci.yml @@ -13,4 +13,5 @@ jobs: - uses: actions/checkout@v4 - uses: devcontainers/ci@v0.3 with: + push: never runCmd: "true" From 9392da3337d751bcbaa444e753d7958b4cf23721 Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Wed, 9 Jul 2025 11:17:01 +0000 Subject: [PATCH 08/11] postCreateCommand update to reflect that the shell script has been renamed. --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6d925f24413e..4951d5eb268d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,7 @@ } }, - "postCreateCommand": "zsh .devcontainer/post_install.sh", + "postCreateCommand": "zsh .devcontainer/post_install", // Configure tool-specific properties. "customizations": { From 9b5021240014c587969e0b16ab5211616c2fe208 Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Wed, 9 Jul 2025 11:18:10 +0000 Subject: [PATCH 09/11] update devcontainer readme file --- .devcontainer/README.md | 43 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/.devcontainer/README.md b/.devcontainer/README.md index ec3cdb61de7a..8056578ad3a8 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -1 +1,42 @@ -https://code.visualstudio.com/docs/devcontainers/tutorial +# Development Container + +This is **Devcontainer** configuration to provide a consistent development environment for all contributors. + +## Features + +- [x] Pre-configured **Python environment** +- [x] Automatic installation of **pre-commit hooks** +- [x] **Ruff** linter ready to check your code +- [x] **Oh My Zsh** with plugins: +- `zsh-autosuggestions` +- `zsh-syntax-highlighting` + +## Usage + +1. Install [**Docker** ](https://www.docker.com/get-started/) and [**Visual Studio Code**](https://code.visualstudio.com/) +2. Install the **Remote - Containers** extension in VS Code + + - Do `CTRL+P`, paste this command and press `Enter` + + ```shell + ext install ms-vscode-remote.remote-containers + ``` +3. Open this repository in VS Code +4. When prompted, click **"Reopen in Container"** +5. Wait for the environment to build and initialize + +After setup: + +- `pre-commit` hooks are installed +- `ruff` and other tools are available +- The shell uses Zsh by default + +## Tips + +To manually run checks on all files: + +```bash +pre-commit run --all-files +``` + +> For further information here's [Microsoft tutorial about devcontainers.](https://code.visualstudio.com/docs/devcontainers/tutorial) From 0247279d55fffbfcffbda515a5f130270eea6881 Mon Sep 17 00:00:00 2001 From: Bertrand Awenze <156874668+bertrand-awz@users.noreply.github.com> Date: Wed, 9 Jul 2025 07:32:15 -0400 Subject: [PATCH 10/11] trigger workflow only on devcontainer/** changes --- .github/workflows/devcontainers_ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/devcontainers_ci.yml b/.github/workflows/devcontainers_ci.yml index e18e9b9b395e..84cc01aab036 100644 --- a/.github/workflows/devcontainers_ci.yml +++ b/.github/workflows/devcontainers_ci.yml @@ -2,9 +2,11 @@ name: Test DevContainer Build on: push: - branches: [main, test-gh-action-for-devcontainer] + paths: + - '.devcontainer/**' pull_request: - branches: [main] + paths: + - '.devcontainer/**' jobs: build: From df199b3383ce1a1f5453746f7f1d1b97a3c1182e Mon Sep 17 00:00:00 2001 From: Bertrand Awenze Date: Wed, 9 Jul 2025 11:39:23 +0000 Subject: [PATCH 11/11] prettier refactor --- .../workflows/{devcontainers_ci.yml => devcontainer_ci.yml} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{devcontainers_ci.yml => devcontainer_ci.yml} (83%) diff --git a/.github/workflows/devcontainers_ci.yml b/.github/workflows/devcontainer_ci.yml similarity index 83% rename from .github/workflows/devcontainers_ci.yml rename to .github/workflows/devcontainer_ci.yml index 84cc01aab036..c0b26bb77da6 100644 --- a/.github/workflows/devcontainers_ci.yml +++ b/.github/workflows/devcontainer_ci.yml @@ -3,10 +3,10 @@ name: Test DevContainer Build on: push: paths: - - '.devcontainer/**' + - ".devcontainer/**" pull_request: paths: - - '.devcontainer/**' + - ".devcontainer/**" jobs: build: