Skip to content

Commit

Permalink
docs: drawable images + workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
geertmeersman committed Jun 5, 2023
1 parent 7354ff1 commit b23797e
Show file tree
Hide file tree
Showing 34 changed files with 154 additions and 20 deletions.
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
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()
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.1
uses: danielchabr/pr-labels-checker@v3.3
with:
hasSome: major,minor,patch
githubToken: ${{ secrets.GITHUB_TOKEN }}
11 changes: 1 addition & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ repos:
- id: isort
args: [--filter-files]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
rev: v1.3.0
hooks:
- id: mypy
language: system
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
Expand All @@ -38,11 +37,3 @@ repos:
- id: forbid-new-submodules
- id: mixed-line-ending
- id: trailing-whitespace
- repo: local
hooks:
- id: reorder-python-imports
name: Reorder python imports
entry: reorder-python-imports
language: system
types: [python]
args: [--application-directories=custom_components]
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.
Binary file added images/drawable/ic_plug_type_chademo_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_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.
Binary file added images/drawable/ic_plug_type_schuko_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_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.

0 comments on commit b23797e

Please sign in to comment.