-
Notifications
You must be signed in to change notification settings - Fork 1
112 lines (90 loc) · 3.01 KB
/
Copy pathtest.yml
File metadata and controls
112 lines (90 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Test and Coverage
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_test.txt
- name: Run tests with coverage
run: |
pytest --cov=custom_components.battery_energy_trading \
--cov-report=xml \
--cov-report=term \
--cov-report=html \
tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
- name: Upload coverage HTML artifact
uses: actions/upload-artifact@v4
if: matrix.python-version == '3.13'
with:
name: coverage-report
path: htmlcov/
- name: Check coverage threshold
run: |
coverage report --fail-under=85
- name: Generate coverage badge
if: matrix.python-version == '3.12' && github.event_name == 'push'
run: |
pip install genbadge[coverage]
genbadge coverage -i coverage.xml -o coverage-badge.svg
- name: Comment coverage on PR
if: matrix.python-version == '3.12' && github.event_name == 'pull_request'
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
MINIMUM_GREEN: 85
MINIMUM_ORANGE: 70
lint:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff mypy bandit[toml]
- name: Run ruff linter
run: ruff check custom_components/battery_energy_trading/
- name: Run ruff formatter check
run: ruff format --check custom_components/battery_energy_trading/
- name: Run mypy type checker
run: mypy custom_components/battery_energy_trading/ --ignore-missing-imports || true
- name: Run bandit security checker
run: bandit -r custom_components/battery_energy_trading/ -c pyproject.toml || true
hassfest:
name: Validate with hassfest
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master