forked from wills106/homeassistant-solax-modbus
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (139 loc) · 4.22 KB
/
Copy pathci-cd.yml
File metadata and controls
163 lines (139 loc) · 4.22 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: CI/CD Integrated
on:
workflow_dispatch:
push:
branches:
- "**"
pull_request:
schedule:
- cron: "0 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install dependencies
run: uv sync --all-groups
- name: Run pre-commit checks
run: uv run pre-commit run --all-files --show-diff-on-failure
mypy:
name: Type Check (mypy)
needs: [quality]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: "3.12"
- name: Install dependencies
run: uv sync --all-groups
- name: Run mypy type checking
run: |
echo "Running mypy in strict mode..."
uv run mypy custom_components/solax_modbus tests --strict
hacs:
name: HACS Validation
needs: [quality]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: HACS Action
uses: hacs/action@main
with:
category: integration
hassfest:
name: Hassfest Validation
needs: [quality]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Hassfest Action
uses: home-assistant/actions/hassfest@master
test-quick:
name: Test Quick
needs: [mypy]
if: github.event_name == 'push' && github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-groups
- name: Run Quick Tests
run: uv run pytest -m "not slow"
test-comprehensive:
name: Test Comprehensive
needs: [mypy]
if: github.event_name == 'pull_request' || github.event_name == 'schedule' || (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12", "3.13"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-groups
- name: Run Full Tests
run: uv run pytest
all-checks-passed:
name: ✅ All Checks Passed
if: always()
needs: [hacs, hassfest, test-quick, test-comprehensive]
runs-on: ubuntu-latest
steps:
- name: Check all results
run: |
HACS="${{ needs.hacs.result }}"
HASSFEST="${{ needs.hassfest.result }}"
QUICK="${{ needs.test-quick.result }}"
COMPREHENSIVE="${{ needs.test-comprehensive.result }}"
echo "HACS: $HACS"
echo "Hassfest: $HASSFEST"
echo "Quick Tests: $QUICK"
echo "Comprehensive Tests: $COMPREHENSIVE"
# 1. Static Analysis must pass
if [[ "$HACS" != "success" ]]; then
echo "❌ HACS validation failed"
exit 1
fi
if [[ "$HASSFEST" != "success" ]]; then
echo "❌ Hassfest validation failed"
exit 1
fi
# 2. Tests: One path must succeed
if [[ "$COMPREHENSIVE" == "success" ]]; then
echo "✅ Comprehensive tests passed"
exit 0
elif [[ "$QUICK" == "success" && "$COMPREHENSIVE" == "skipped" ]]; then
echo "✅ Quick tests passed"
exit 0
elif [[ "$QUICK" == "skipped" && "$COMPREHENSIVE" == "skipped" ]]; then
echo "⚠️ No tests ran?"
exit 1
else
echo "❌ Tests failed or cancelled"
exit 1
fi