Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: drawable images + workflows #41

Merged
merged 3 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions .github/labels.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
- name: feat
description: A new feature
color: a2eeef
- name: fix
description: A bug correction
description: A bug fix
color: d3fc03
- name: enhancement
description: A new feature or request
color: a2eeef
- name: docs
description: Documentation only changes
color: D4C5F9
- name: documentation
description: This issue relates to writing documentation
color: D4C5F9
- name: doc
description: This issue relates to writing documentation
color: D4C5F9
- name: style
description: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
color: D4C5F9
- name: refactor
description: A code change that neither fixes a bug nor adds a feature
color: D4C5F9
- name: perf
description: A code change that improves performance
color: d3fc03
- name: test
description: Adding missing or correcting existing tests
color: d3fc03
- name: chore
description: Changes to the build process or auxiliary tools and libraries such as documentation generation
color: d3fc03
- name: major
description: A change requiring a major version bump
color: 6b230e
Expand All @@ -19,3 +40,6 @@
- name: breaking
description: A breaking change
color: d30000
- name: breaking change
description: A breaking change
color: d30000
34 changes: 34 additions & 0 deletions .github/scripts/get_new_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Script to calculate the next version."""
import subprocess

Check notice

Code scanning / Bandit

Consider possible security implications associated with the subprocess module.

Consider possible security implications associated with the subprocess module.
import sys

from git import Repo
from git_conventional_version.api import Api
import semantic_version
import semver


def get_last_beta_tag():
"""Get the last beta tag from GIT."""
command = ["git", "describe", "--tags", "--abbrev=0", "--match", "*beta*"]
output = subprocess.check_output(command).decode().strip()

Check notice

Code scanning / Bandit

subprocess call - check for execution of untrusted input.

subprocess call - check for execution of untrusted input.
return output


def get_version_without_prerelease(version):
"""Get SemVer version without prerelease suffix."""
semver = semantic_version.Version(version)
return str(semver.major) + "." + str(semver.minor) + "." + str(semver.patch)


api = Api(repo=Repo(search_parent_directories=True))
last_beta_tag = get_last_beta_tag()
new_tag = api.get_new_version(type="final")
last_beta_tag_without_prerelease = get_version_without_prerelease(last_beta_tag)
ver = semver.Version.parse(last_beta_tag)
if new_tag != last_beta_tag_without_prerelease:
new_version = f"{new_tag}-beta.1"
else:
new_version = ver.bump_prerelease()
print(new_version)
sys.exit(0)
43 changes: 43 additions & 0 deletions .github/scripts/pr_extract_labels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Script to extract the labels for a PR."""
import os
import re
import sys


def extract_semver_types(commit_messages):
"""Extract SemVer types."""
types = []
for message in commit_messages:
pattern = r"^(feat|fix|chore|docs|style|refactor|perf|test)(?:\(.+?\))?:\s(.+)$"
match = re.match(pattern, message)
if match and match.group(1) not in types:
types.append(match.group(1))
return types


def get_semver_level(commit_messages):
"""Extract SemVer level."""
major_keywords = ["breaking change", "major"]
minor_keywords = ["feat", "minor"]
for message in commit_messages:
if any(keyword in message for keyword in major_keywords):
return "major"
for message in commit_messages:
if any(keyword in message for keyword in minor_keywords):
return "minor"
return "patch"


file_path = "COMMIT_MESSAGES"
if os.path.exists(file_path):
with open(file_path) as file:
messages = []
for line in file:
messages.append(line.strip())
semver_level = get_semver_level(messages)
types = extract_semver_types(messages)
types.append(semver_level)
print(types)
sys.exit(0)
else:
sys.exit(f"ERROR: {file_path} does not exist")
50 changes: 47 additions & 3 deletions .github/workflows/pr-checker.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: PR Compliancy
name: PR Labels and Checks
on:
pull_request:
types:
Expand All @@ -12,12 +12,56 @@ concurrency:
cancel-in-progress: true

jobs:
assign_labels:
name: Assign SemVer labels
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: ⤵️ Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get commit messages
id: commit_messages
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
COMMIT_MESSAGES=$(curl -sSL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}/commits" | \
jq -r '.[].commit.message')
echo "$COMMIT_MESSAGES" > COMMIT_MESSAGES
echo "$COMMIT_MESSAGES"

- name: Determine SemVer level
id: semver_level
run: |
labels=$(python .github/scripts/pr_extract_labels.py)
echo Labels: $labels
echo "labels=$labels" >> "$GITHUB_OUTPUT"

- name: Delete commit messages file
run: |
rm COMMIT_MESSAGES

- name: Assign SemVer label
uses: actions/github-script@v6
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ${{ steps.semver_level.outputs.labels }}
});
check_semver_labels:
name: Check Semver labels
name: Check Semver labels in PR
needs: assign_labels
runs-on: "ubuntu-latest"
steps:
- name: Check for Semver labels
uses: danielchabr/pr-labels-checker@v3.2
uses: danielchabr/pr-labels-checker@v3.3
with:
hasSome: major,minor,patch
githubToken: ${{ secrets.GITHUB_TOKEN }}
55 changes: 30 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
exclude: CHANGELOG.md
minimum_pre_commit_version: 2.11.0
default_stages: [commit, push, manual]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: local
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
require_serial: true
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
name: flake8
entry: flake8
language: system
types: [python]
args: ["-j8", "--ignore=E501,W503"]
require_serial: true
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=custom_components]
args: [--max-line-length=88, "-j8", "--ignore=E501,W503"]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--filter-files]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: [--maxkb=800]
- id: debug-statements
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key
- id: end-of-file-fixer
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
4 changes: 1 addition & 3 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ ignore = [
"D407", # Section name underlining
"D411", # Missing blank line before section
"E501", # line too long
"T201", # 'print' found
"E731", # do not assign a lambda expression, use a def
]

[flake8-pytest-style]
fixture-parentheses = false

[pyupgrade]
keep-runtime-typing = true

[mccabe]
max-complexity = 40
Binary file added images/drawable/cable_cluster.webp
Binary file not shown.
Binary file added images/drawable/cable_home.webp
Binary file not shown.
Binary file added images/drawable/cable_mobile.webp
Binary file not shown.
Binary file added images/drawable/device_cluster_available.webp
Binary file not shown.
Binary file added images/drawable/device_cluster_charging.webp
Binary file not shown.
Binary file added images/drawable/device_cluster_offline.webp
Binary file not shown.
Binary file added images/drawable/device_cluster_plugged.webp
Binary file not shown.
Binary file added images/drawable/device_home_available.webp
Binary file not shown.
Binary file added images/drawable/device_home_charging.webp
Binary file not shown.
Binary file added images/drawable/device_home_offline.webp
Binary file not shown.
Binary file added images/drawable/device_home_plugged.webp
Binary file not shown.
Binary file added images/drawable/device_mobile_available.webp
Binary file not shown.
Binary file added images/drawable/device_mobile_charging.webp
Binary file not shown.
Binary file added images/drawable/device_mobile_offline.webp
Binary file not shown.
Binary file added images/drawable/device_mobile_plugged.webp
Binary file not shown.
Binary file added images/drawable/home_wifi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_chademo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_combo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_combo_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_schuko.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type1_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type2_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/drawable/ic_plug_type_type3_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.