Skip to content

Commit

Permalink
Merge pull request #1 from Brunas/workflows_some_cleanup
Browse files Browse the repository at this point in the history
Code cleanup, workflows, docs
  • Loading branch information
Brunas authored Jul 25, 2024
2 parents b938772 + 391d4fc commit 9af14d4
Show file tree
Hide file tree
Showing 25 changed files with 1,034 additions and 690 deletions.
76 changes: 38 additions & 38 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# Use an official Python image as the base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libffi-dev \
libssl-dev \
libjpeg-dev \
zlib1g-dev \
gcc \
make \
&& rm -rf /var/lib/apt/lists/*

# Set the timezone to Europe/Vilnius
ENV TZ=Europe/Vilnius

# Set up the user for vscode
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

# Switch to the vscode user
USER $USERNAME

# Set the working directory
WORKDIR /home/vscode

# Expose the default Home Assistant port
EXPOSE 8123
# Use an official Python image as the base image
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libffi-dev \
libssl-dev \
libjpeg-dev \
zlib1g-dev \
gcc \
make \
&& rm -rf /var/lib/apt/lists/*

# Set the timezone to Europe/Vilnius
ENV TZ=Europe/Vilnius

# Set up the user for vscode
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME

# Switch to the vscode user
USER $USERNAME

# Set the working directory
WORKDIR /home/vscode

# Expose the default Home Assistant port
EXPOSE 8123
80 changes: 44 additions & 36 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
{
"name": "Home Assistant Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-python.black-formatter",
"ms-python.autopep8",
"ms-python.pylint",
"ms-vscode.remote-containers",
"charliermarsh.ruff"
]
}
},
"postCreateCommand": "pip install -r requirements.txt",
"remoteUser": "vscode",
"mounts": [
"source=${localWorkspaceFolder}/config,target=/config,type=bind",
"source=${localWorkspaceFolder}/custom_components,target=/config/custom_components,type=bind"
],
"forwardPorts": [
8123
],
"remoteEnv": {
"TZ": "Europe/Vilnius"
}
{
"name": "Home Assistant Dev Container",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.selectInterpreter": "/usr/local/bin/python",
"terminal.integrated.shell.linux": "/bin/bash"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
"ms-python.black-formatter",
"ms-python.autopep8",
"ms-python.pylint",
"ms-vscode.remote-containers",
"charliermarsh.ruff",
"yzhang.markdown-all-in-one",
"kevinrose.vsc-python-indent",
"keesschollaart.vscode-home-assistant",
"donjayamanne.githistory",
"mhutchie.git-graph",
"mikoz.black-py"
]
}
},
"postCreateCommand": "pip install -r requirements.txt",
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"remoteUser": "vscode",
"mounts": [
"source=${localWorkspaceFolder}/config,target=/config,type=bind",
"source=${localWorkspaceFolder}/custom_components,target=/config/custom_components,type=bind"
],
"forwardPorts": [
8123
],
"remoteEnv": {
"TZ": "Europe/Vilnius"
}
}
18 changes: 18 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"

# Maintain dependencies for pip
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Lint"

on:
push:
paths-ignore:
- "**/README.md"
- "**/CHANGELOG.md"
- "**/CONTRIBUTING.md"
- "**/requirements.txt"
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
ruff:
name: "Ruff"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected]"

- name: "Set up Python"
uses: actions/[email protected]
with:
python-version: "3.12"
cache: "pip"

- name: "Install requirements"
run: python3 -m pip install -r requirements.txt

- name: "Run"
run: python3 -m ruff check .
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "Release"

on:
release:
types:
- "published"

permissions: {}

jobs:
release:
name: "Release"
runs-on: "ubuntu-latest"
permissions:
contents: write
steps:
- name: "Checkout the repository"
uses: "actions/[email protected]"

- name: "Adjust version number"
shell: "bash"
run: |
yq -i -o json '.version="${{ github.event.release.tag_name }}"' \
"${{ github.workspace }}/custom_components/meteo_lt/manifest.json"
- name: "ZIP the integration directory"
shell: "bash"
run: |
cd "${{ github.workspace }}/custom_components/meteo_lt"
zip meteo_lt.zip -r ./
- name: "Upload the ZIP file to the release"
uses: softprops/[email protected]
with:
files: ${{ github.workspace }}/custom_components/meteo_lt/meteo_lt.zip
40 changes: 40 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: "Validate"

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
push:
paths-ignore:
- "**/README.md"
- "**/CHANGELOG.md"
- "**/CONTRIBUTING.md"
- "**/requirements.txt"
branches:
- "main"
pull_request:
branches:
- "main"

jobs:
hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest
name: "Hassfest Validation"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected]"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"

hacs: # https://github.com/hacs/action
name: "HACS Validation"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/[email protected]"

- name: "Run HACS validation"
uses: "hacs/action@main"
with:
category: "integration"
Loading

0 comments on commit 9af14d4

Please sign in to comment.