From e20a814926e6fecc252688aaca6a83e8cd62d00c Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 8 Feb 2021 16:16:40 +0100 Subject: [PATCH] Call setup during devcontainer create (#46224) --- .devcontainer/devcontainer.json | 3 ++- script/bootstrap | 17 ----------------- script/setup | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 94d3c284f1a..efcc0380748 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,8 @@ "name": "Home Assistant Dev", "context": "..", "dockerFile": "../Dockerfile.dev", - "postCreateCommand": "script/bootstrap", + "postCreateCommand": "script/setup", + "postStartCommand": "script/bootstrap", "containerEnv": { "DEVCONTAINER": "1" }, "appPort": 8123, "runArgs": ["-e", "GIT_EDITOR=code --wait"], diff --git a/script/bootstrap b/script/bootstrap index 12a2e5da707..3ffac11852b 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -6,23 +6,6 @@ set -e cd "$(dirname "$0")/.." -# Add default vscode settings if not existing -SETTINGS_FILE=./.vscode/settings.json -SETTINGS_TEMPLATE_FILE=./.vscode/settings.default.json -if [ ! -f "$SETTINGS_FILE" ]; then - echo "Copy $SETTINGS_TEMPLATE_FILE to $SETTINGS_FILE." - cp "$SETTINGS_TEMPLATE_FILE" "$SETTINGS_FILE" -fi - echo "Installing development dependencies..." python3 -m pip install wheel --constraint homeassistant/package_constraints.txt python3 -m pip install tox colorlog pre-commit $(grep mypy requirements_test.txt) $(grep stdlib-list requirements_test.txt) $(grep tqdm requirements_test.txt) $(grep pipdeptree requirements_test.txt) $(grep awesomeversion requirements.txt) --constraint homeassistant/package_constraints.txt - -if [ -n "$DEVCONTAINER" ];then - pre-commit install - pre-commit install-hooks - python3 -m pip install -e . --constraint homeassistant/package_constraints.txt - - mkdir -p config - hass --script ensure_config -c config -fi \ No newline at end of file diff --git a/script/setup b/script/setup index 83c2d24f038..46865ecfcb6 100755 --- a/script/setup +++ b/script/setup @@ -6,10 +6,20 @@ set -e cd "$(dirname "$0")/.." +# Add default vscode settings if not existing +SETTINGS_FILE=./.vscode/settings.json +SETTINGS_TEMPLATE_FILE=./.vscode/settings.default.json +if [ ! -f "$SETTINGS_FILE" ]; then + echo "Copy $SETTINGS_TEMPLATE_FILE to $SETTINGS_FILE." + cp "$SETTINGS_TEMPLATE_FILE" "$SETTINGS_FILE" +fi + mkdir -p config -python3 -m venv venv -source venv/bin/activate +if [ ! -n "$DEVCONTAINER" ];then + python3 -m venv venv + source venv/bin/activate +fi script/bootstrap