Skip to content

Commit 52fa670

Browse files
authored
Merge pull request #56 from Snuffy2/Linting-Cleanup
Add linting and formatting
2 parents e6d37ce + 0a5df54 commit 52fa670

File tree

19 files changed

+1517
-574
lines changed

19 files changed

+1517
-574
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/linters.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Linters
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
workflow_dispatch:
10+
11+
jobs:
12+
linters:
13+
name: Run Linters
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v5
18+
19+
- name: Debug GitHub Variables
20+
run: |
21+
echo "github.event_name: ${{ github.event_name }}"
22+
echo "github.ref_name: ${{ github.ref_name }}"
23+
echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}"
24+
25+
- name: Setup Python 3 (with caching)
26+
uses: actions/setup-python@v6
27+
id: setup-python
28+
with:
29+
python-version: 3.x
30+
cache: 'pip'
31+
cache-dependency-path: |
32+
requirements-lint.txt
33+
pyproject.toml
34+
35+
- name: Install Linting Requirements
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install -r requirements-lint.txt
39+
40+
- name: Cache pre-commit and mypy
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
~/.cache/pre-commit
45+
.mypy_cache
46+
.ruff_cache
47+
key: ${{ runner.os }}-lint-py${{ steps.setup-python.outputs.python-version || '3.x' }}-${{ hashFiles('**/requirements-lint.txt', '**/.pre-commit-config.yaml', '**/pyproject.toml') }}
48+
restore-keys: |
49+
${{ runner.os }}-lint-
50+
51+
- name: Run pre-commit
52+
run: pre-commit run --all-files --show-diff-on-failure --color always
53+
54+
- uses: pre-commit-ci/lite-action@v1.1.0
55+
if: always()
Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,65 @@
1-
name: Create Zip on Release
1+
name: Update Version and Create Zip on Release
22
on:
33
workflow_dispatch:
44
release:
55
types: [published, edited]
6+
67
jobs:
7-
create_zip:
8+
update_version_and_create_zip:
89
runs-on: ubuntu-latest
910
steps:
10-
- name: Checkout
11-
uses: actions/checkout@v4.1.7
12-
- name: Debug Variables
11+
- name: Checkout Repository
12+
uses: actions/checkout@v5
13+
14+
- name: Debug GitHub Variables
1315
run: |
1416
echo "github.event_name: ${{ github.event_name }}"
1517
echo "github.ref_name: ${{ github.ref_name }}"
18+
echo "github.event.release.tag_name: ${{ github.event.release.tag_name }}"
1619
echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}"
1720
echo "github.event.release.target_commitish: ${{ github.event.release.target_commitish }}"
1821
echo "github.event.release.prerelease: ${{ github.event.release.prerelease }}"
19-
echo "github.event.release.draft: ${{ github.event.release.draft }}"
22+
echo "github.event.release.draft: ${{ github.event.release.draft }}"
23+
2024
- name: Update Version in Manifest
21-
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
25+
if: ${{ github.event_name == 'release' && github.event.release.draft == false }}
2226
run: |
23-
sed -i 's/\"version\"\s*\:\s*\".*\"/\"version\"\:\"${{ github.ref_name }}\"/g' ./custom_components/animated_scenes/manifest.json
27+
sed -i 's/\"version\"\s*\:\s*\".*\"/\"version\"\:\"${{ github.event.release.tag_name }}\"/g' ./custom_components/animated_scenes/manifest.json
28+
2429
- name: Update Version in const.py
25-
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
30+
if: ${{ github.event_name == 'release' && github.event.release.draft == false }}
2631
run: |
27-
sed -i 's/VERSION \= \".*\"/VERSION \= \"${{ github.ref_name }}\"/' ./custom_components/animated_scenes/const.py
32+
sed -i 's/^VERSION \= \".*\"/VERSION \= \"${{ github.event.release.tag_name }}\"/' ./custom_components/animated_scenes/const.py
33+
2834
- name: Commit & Push Version Changes
29-
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
35+
if: ${{ github.event_name == 'release' && github.event.release.draft == false && github.event.release.prerelease == false }}
3036
uses: actions-js/push@master
3137
with:
3238
github_token: ${{ secrets.GITHUB_TOKEN }}
3339
branch: ${{ github.event.release.target_commitish }}
34-
message: 'Updating to version ${{ github.ref_name }}'
40+
message: 'Updating to version ${{ github.event.release.tag_name }} [skip ci]'
41+
42+
- name: Update Release with Version Changes Commit
43+
if: ${{ github.event_name == 'release' && github.event.release.draft == false && github.event.release.prerelease == false }}
44+
run: |
45+
git tag -f ${{ github.event.release.tag_name }}
46+
git push -f origin ${{ github.event.release.tag_name }}
47+
3548
- name: Create Zip
36-
uses: thedoctor0/zip-release@0.7.6
37-
with:
38-
type: 'zip'
39-
filename: 'animated_scenes.zip'
40-
directory: ./custom_components/animated_scenes
49+
run: |
50+
cd ${{ github.workspace }}/custom_components/animated_scenes
51+
zip animated_scenes.zip -r ./
52+
4153
- name: Upload Zip to Release
42-
if: ${{ github.event_name == 'release' }}
43-
uses: Roang-zero1/github-upload-release-artifacts-action@v3.0.0
54+
if: ${{ github.event_name == 'release' && github.event.release.draft == false }}
55+
uses: softprops/action-gh-release@v2
4456
with:
45-
args: ./custom_components/animated_scenes/animated_scenes.zip
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
files: ./custom_components/animated_scenes/animated_scenes.zip
58+
tag_name: ${{ github.event.release.tag_name }}
59+
4860
- name: Add Zip to Action
4961
if: ${{ github.event_name == 'workflow_dispatch' }}
50-
uses: actions/upload-artifact@v4.3.4
62+
uses: actions/upload-artifact@v4
5163
with:
5264
name: animated_scenes
5365
path: ./custom_components/animated_scenes/animated_scenes.zip
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
name: HA and HACS Validate
22

33
on:
4-
push:
54
pull_request:
65
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
- master
710

811
jobs:
9-
ha_and_hacs_validation:
12+
ha_validation:
13+
name: Hassfest Validation
1014
runs-on: ubuntu-latest
1115
steps:
1216
- name: Checkout
13-
uses: actions/checkout@v4.1.7
17+
uses: actions/checkout@v5
1418
- name: Hassfest validation
1519
uses: home-assistant/actions/hassfest@master
20+
hacs_validation:
21+
name: HACS Validation
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v5
1626
- name: HACS validation
17-
uses: hacs/action@22.5.0
27+
uses: hacs/action@main
1828
with:
1929
category: integration

.pre-commit-config.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
exclude: '.*\.md$'
9+
- id: end-of-file-fixer
10+
exclude: '.*\.md$'
11+
- id: check-yaml
12+
- id: check-toml
13+
- id: check-added-large-files
14+
- repo: https://github.com/rvben/rumdl-pre-commit
15+
rev: v0.0.153
16+
hooks:
17+
- id: rumdl
18+
args: [--fix]
19+
- repo: https://github.com/rhysd/actionlint
20+
rev: v1.7.7
21+
hooks:
22+
- id: actionlint
23+
# Note: shellcheck cannot directly parse YAML; actionlint extracts workflow
24+
# shell blocks and calls shellcheck when available.
25+
- repo: https://github.com/shellcheck-py/shellcheck-py
26+
rev: v0.11.0.1
27+
hooks:
28+
- id: shellcheck
29+
# Match by detected shell file type (extensions or shebang)
30+
types: [shell]
31+
args: ['-x']
32+
- repo: https://github.com/codespell-project/codespell
33+
rev: v2.4.1
34+
hooks:
35+
- id: codespell
36+
additional_dependencies:
37+
- tomli
38+
- repo: https://github.com/pre-commit/mirrors-mypy
39+
rev: 'v1.18.2'
40+
hooks:
41+
- id: mypy
42+
additional_dependencies:
43+
- homeassistant-stubs
44+
- types-cffi
45+
- types-PyMySQL
46+
- types-pyRFC3339
47+
- types-python-dateutil
48+
- types-PyYAML
49+
- types-requests
50+
- types-setuptools
51+
- repo: https://github.com/astral-sh/ruff-pre-commit
52+
rev: v0.13.3
53+
hooks:
54+
# Run the linter.
55+
- id: ruff-check
56+
args: [--fix]
57+
# Run the formatter.
58+
- id: ruff-format
59+
60+
ci:
61+
autofix_commit_msg: |
62+
[pre-commit.ci] auto fixes from pre-commit hooks
63+
autofix_prs: true
64+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
65+
autoupdate_schedule: weekly
66+
skip: [mypy]
67+
submodules: false

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
## 2.0.1
@@ -71,4 +72,4 @@ All notable changes to this project will be documented in this file.
7172

7273
- Fixed issue where lights may get overloaded because integration forgot to wait for an update.
7374
- Fixed animation switches starting in an unknown state, they will now all start in 'off' state.
74-
- Changed main loop to look for task done to theoretically resolve an issue where an animation would go rogue and keep running when it shouldn't.
75+
- Changed main loop to look for task done to theoretically resolve an issue where an animation would go rogue and keep running when it shouldn't.

0 commit comments

Comments
 (0)