Skip to content

Commit

Permalink
Update devcontainer and build files
Browse files Browse the repository at this point in the history
  • Loading branch information
amosyuen committed Mar 3, 2024
1 parent d32c57c commit f5838bc
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 114 deletions.
53 changes: 24 additions & 29 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"image": "ghcr.io/ludeeus/devcontainer/integration:stable",
"name": "Eight Sleep Climate integration development",
"context": "..",
"appPort": ["9123:8123"],
"postCreateCommand": ".devcontainer/setup.sh",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/root/.gitconfig,type=bind,consistency=cached"
],
"extensions": [
"ms-python.python",
"github.vscode-pull-request-github",
"ryanluker.vscode-coverage-gutters",
"ms-python.vscode-pylance",
"esbenp.prettier-vscode"
],
"settings": {
"files.eol": "\n",
"editor.tabSize": 4,
"terminal.integrated.shell.linux": "/bin/bash",
"python.pythonPath": "/usr/bin/python3",
"python.analysis.autoSearchPaths": false,
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
"name": "Eight sleep climate integration development",
"image": "mcr.microsoft.com/devcontainers/python:3.11-bullseye",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"postAttachCommand": ".devcontainer/setup.sh",
"forwardPorts": [8123],
"portsAttributes": {
"8123": {
"label": "Home Assistant",
"onAutoForward": "notify"
}
},
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode",
"github.vscode-pull-request-github",
"ms-vscode-remote.remote-containers",
"ms-python.black-formatter",
"ms-python.vscode-pylance",
"ryanluker.vscode-coverage-gutters"
]
}
},
"remoteUser": "vscode"
}
20 changes: 20 additions & 0 deletions .devcontainer/develop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

# Create config dir if not present
if [[ ! -d "${PWD}/config" ]]; then
mkdir -p "${PWD}/config"
hass --config "${PWD}/config" --script ensure_config
fi

# Set the path to custom_components
## This let's us have the structure we want <root>/custom_components/integration_blueprint
## while at the same time have Home Assistant configuration inside <root>/config
## without resulting to symlinks.
export PYTHONPATH="${PYTHONPATH}:${PWD}/custom_components"

# Start Home Assistant
hass --config "${PWD}/config" --debug
4 changes: 1 addition & 3 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ set -e

cd "$(dirname "$0")/.."

pip3 install -r .github/workflows/constraints.txt
pip3 install --requirement requirements.txt
pre-commit install

container install
13 changes: 6 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
- package-ecosystem: pip
directory: "/.github/workflows"
schedule:
interval: daily
- package-ecosystem: pip
interval: weekly
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: daily
interval: weekly
ignore:
# Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json
- dependency-name: "homeassistant"
5 changes: 0 additions & 5 deletions .github/workflows/constraints.txt

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ jobs:
name: Pre-commit
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/setup-python@v4.8.0
uses: actions/setup-python@v4.7.1
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Upgrade pip
run: |
pip install --constraint=.github/workflows/constraints.txt pip
pip install --constraint=requirements.txt pip
pip --version
- name: Install Python modules
run: |
pip install --constraint=.github/workflows/constraints.txt pre-commit black flake8 reorder-python-imports
pip install --constraint=requirements.txt pre-commit black flake8 reorder-python-imports
- name: Run pre-commit on all files
run: |
Expand All @@ -44,7 +44,7 @@ jobs:
name: HACS
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: HACS validation
uses: hacs/action@main
Expand All @@ -57,7 +57,7 @@ jobs:
name: Hassfest
steps:
- name: Check out the repository
uses: "actions/checkout@v3"
uses: "actions/checkout@v4"

- name: Hassfest validation
uses: "home-assistant/actions/hassfest@master"
16 changes: 12 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# artifacts
__pycache__
pythonenv*
.python-version
.pytest*
*.egg-info
*/build/*
*/dist/*

# misc
.coverage
venv
.venv
coverage.xml

# Home Assistant configuration
config/*
!config/configuration.yaml
34 changes: 0 additions & 34 deletions .vscode/launch.json

This file was deleted.

20 changes: 14 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
"python.linting.pylintArgs": ["--rcfile=setup.cfg"],
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.pythonPath": "venv/bin/python",
"files.associations": {
"*.yaml": "home-assistant"
"analysis.autoSearchPaths": false,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
},
"editor.formatOnSave": true,
"editor.tabSize": 4,
"files.eol": "\n",
"files.trimTrailingWhitespace": true,
"terminal.integrated.shell.linux": "/bin/bash",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
"files.associations": {
"*.yaml": "home-assistant"
}
}
22 changes: 2 additions & 20 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,14 @@
"version": "2.0.0",
"tasks": [
{
"label": "Run Home Assistant on port 9123",
"label": "Run Home Assistant on port 8123",
"type": "shell",
"command": "container start",
"command": ".devcontainer/develop.sh",
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Run Home Assistant configuration against /config",
"type": "shell",
"command": "container check",
"problemMatcher": []
},
{
"label": "Upgrade Home Assistant to latest dev",
"type": "shell",
"command": "container install",
"problemMatcher": []
},
{
"label": "Install a specific version of Home Assistant",
"type": "shell",
"command": "container set-version",
"problemMatcher": []
}
]
}
File renamed without changes.
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
black==23.12.0
colorlog==6.8.0
flake8==6.1.0
homeassistant==2023.6.0
pip>=21.0,<23.2
pre-commit==3.6.0
reorder-python-imports==3.12.0
ruff==0.1.11

0 comments on commit f5838bc

Please sign in to comment.