Skip to content
This repository was archived by the owner on Jul 28, 2024. It is now read-only.

Commit d9f1d96

Browse files
authored
Add tests from original PR, and restructure for pytest-homeassistant-custom-component (#2)
* Add tests from original PR, and restructure for pytest-homeassistant-custom-component * Update workflows * Satisfy ruff
1 parent e476a98 commit d9f1d96

16 files changed

+558
-56
lines changed

.github/dependabot.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
22
version: 2
33
updates:
4-
- package-ecosystem: "github-actions"
5-
directory: "/"
4+
- package-ecosystem: github-actions
5+
directory: /
66
schedule:
7-
interval: "weekly"
7+
interval: weekly
88

9-
- package-ecosystem: "pip"
10-
directory: "/"
9+
- package-ecosystem: pip
10+
directory: /
1111
schedule:
12-
interval: "weekly"
12+
interval: weekly
1313
ignore:
1414
# Dependabot should not update Home Assistant as that should match the homeassistant key in hacs.json
15-
- dependency-name: "homeassistant"
15+
- dependency-name: homeassistant

.github/workflows/lint.yml

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
name: "Lint"
1+
name: Lint
22

33
on:
44
push:
5-
branches:
6-
- "main"
5+
branches: [ main ]
76
pull_request:
8-
branches:
9-
- "main"
7+
branches: [ main ]
108

119
jobs:
1210
ruff:
13-
name: "Ruff"
14-
runs-on: "ubuntu-latest"
11+
name: Ruff
12+
runs-on: ubuntu-latest
1513
steps:
16-
- name: "Checkout the repository"
17-
uses: "actions/checkout@v3.5.2"
14+
- name: Checkout the repository
15+
uses: actions/checkout@v3
1816

19-
- name: "Set up Python"
20-
uses: actions/setup-python@v4.6.1
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
2119
with:
2220
python-version: "3.10"
23-
cache: "pip"
21+
cache: pip
2422

25-
- name: "Install requirements"
23+
- name: Install requirements
2624
run: python3 -m pip install -r requirements.txt
2725

28-
- name: "Run"
26+
- name: Run
2927
run: python3 -m ruff check .

.github/workflows/pytest.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Pytest
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
pytest:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11"]
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
cache: pip
23+
- name: Install requirements
24+
run: pip install -r requirements_test.txt
25+
- name: Test with pytest
26+
run: pytest

.github/workflows/release.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: "Release"
1+
name: Release
22

33
on:
44
release:
55
types:
6-
- "published"
6+
- published
77

88
permissions: {}
99

1010
jobs:
1111
release:
12-
name: "Release"
13-
runs-on: "ubuntu-latest"
12+
name: Release
13+
runs-on: ubuntu-latest
1414
permissions:
1515
contents: write
1616
steps:
17-
- name: "Checkout the repository"
18-
uses: "actions/checkout@v3.5.2"
17+
- name: Checkout the repository
18+
uses: actions/checkout@v3
1919

20-
- name: "Adjust version number"
21-
shell: "bash"
20+
- name: Adjust version number
21+
shell: bash
2222
run: |
2323
yq -i -o json '.version="${{ github.event.release.tag_name }}"' \
2424
"${{ github.workspace }}/custom_components/matrix/manifest.json"
2525
26-
- name: "ZIP the integration directory"
27-
shell: "bash"
26+
- name: ZIP the integration directory
27+
shell: bash
2828
run: |
2929
cd "${{ github.workspace }}/custom_components/matrix"
3030
zip matrix-nio-hacs.zip -r ./
3131
32-
- name: "Upload the ZIP file to the release"
32+
- name: Upload the ZIP file to the release
3333
uses: softprops/[email protected]
3434
with:
3535
files: ${{ github.workspace }}/custom_components/matrix/matrix-nio-hacs.zip

.github/workflows/validate.yml

+18-20
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
1-
name: "Validate"
1+
name: Validate
22

33
on:
44
workflow_dispatch:
55
schedule:
6-
- cron: "0 0 * * *"
6+
- cron: 0 0 * * *
77
push:
8-
branches:
9-
- "main"
8+
branches: [ main ]
109
pull_request:
11-
branches:
12-
- "main"
10+
branches: [ main ]
1311

1412
jobs:
1513
hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest
16-
name: "Hassfest Validation"
17-
runs-on: "ubuntu-latest"
14+
name: Hassfest Validation
15+
runs-on: ubuntu-latest
1816
steps:
19-
- name: "Checkout the repository"
20-
uses: "actions/checkout@v3.5.2"
17+
- name: Checkout the repository
18+
uses: actions/checkout@v3
2119

22-
- name: "Run hassfest validation"
23-
uses: "home-assistant/actions/hassfest@master"
20+
- name: Run hassfest validation
21+
uses: home-assistant/actions/hassfest@master
2422

2523
hacs: # https://github.com/hacs/action
26-
name: "HACS Validation"
27-
runs-on: "ubuntu-latest"
24+
name: HACS Validation
25+
runs-on: ubuntu-latest
2826
steps:
29-
- name: "Checkout the repository"
30-
uses: "actions/checkout@v3.5.2"
27+
- name: Checkout the repository
28+
uses: actions/checkout@v3
3129

32-
- name: "Run HACS validation"
33-
uses: "hacs/action@main"
30+
- name: Run HACS validation
31+
uses: hacs/action@main
3432
with:
35-
category: "integration"
33+
category: integration
3634
# Remove this 'ignore' key when you have added brand images for your integration to https://github.com/home-assistant/brands
37-
ignore: "brands"
35+
ignore: brands

custom_components/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Custom Components."""

hacs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Matrix Nio",
33
"filename": "matrix-nio-hacs.zip",
44
"hide_default_branch": true,
5-
"homeassistant": "2023.5.4",
5+
"homeassistant": "2023.6.0",
66
"render_readme": true,
77
"zip_release": true
88
}

pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.pytest.ini_options]
2+
testpaths = ["tests"]
3+
asyncio_mode = "auto"

requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
colorlog==6.7.0
2-
homeassistant==2023.5.4
2+
homeassistant>=2023.5.4
33
pip>=21.0,<23.2
4-
ruff==0.0.270
4+
ruff>=0.0.271
55
matrix-nio==0.20.2
6-
Pillow==9.5.0
6+
Pillow==9.5.0

requirements_test.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-r requirements.txt
2+
pytest>=7.3.1
3+
pytest-homeassistant-custom-component>=0.13.35

tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Tests for the Matrix component."""

0 commit comments

Comments
 (0)