-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
207 lines (183 loc) · 7.78 KB
/
Copy pathMakefile
File metadata and controls
207 lines (183 loc) · 7.78 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
.PHONY: help mock-up mock-down mock-logs ha-up ha-down ha-logs ha-reload test test-api check-logs clean full-clean dev-up dev-down dev-logs lint status version release-dry-run release-notes release release-github
help:
@echo "╔════════════════════════════════════════════════════════════╗"
@echo "║ Emlog HA Integration - Entwicklungsumgebung ║"
@echo "╚════════════════════════════════════════════════════════════╝"
@echo ""
@echo "📚 REPOSITORY STRUKTUR:"
@echo " custom_components/emlog/ → HACS Integration"
@echo " docs/ → Dokumentation"
@echo " tools/ → Entwicklungswerkzeuge"
@echo " tests/ → Tests & Mock Server"
@echo ""
@echo "🚀 VERFÜGBARE BEFEHLE:"
@echo ""
@echo "Dev-Umgebung:"
@echo " make dev-up Starte komplette Dev-Umgebung"
@echo " make dev-down Stoppe Dev-Umgebung"
@echo " make dev-logs Zeige alle Logs"
@echo ""
@echo "Einzelne Services:"
@echo " make mock-up Starte Mock Server"
@echo " make mock-down Stoppe Mock Server"
@echo " make mock-logs Mock Server Logs"
@echo " make ha-up Starte Home Assistant"
@echo " make ha-down Stoppe Home Assistant"
@echo " make ha-logs Home Assistant Logs"
@echo " make ha-reload Kopiere Integration & starte HA neu"
@echo ""
@echo "Testing & Validierung:"
@echo " make test Führe Tests durch"
@echo " make test-api Teste Mock API"
@echo " make lint Code-Qualität prüfen"
@echo " make check-logs Prüfe HA Logs auf Fehler (vor Commit)"
@echo ""
@echo "Release Management:"
@echo " make release-dry-run Teste Release (ohne zu pushen)"
@echo " make release-notes Zeige generierte Release Notes"
@echo " make release Führe manuellen Release aus (lokal, mit Bestätigung)"
@echo " make release-github Triggere GitHub Actions Release (remote auf GitHub)"
@echo ""
@echo "Wartung:"
@echo " make status Service Status"
@echo " make clean Cleanup (down)"
@echo " make full-clean Vollständiges Cleanup"
@echo " make version Zeige Version"
mock-up:
@echo "🚀 Starte Mock Server..."
docker-compose -f tools/docker/compose.yml up -d emlog-mock
@sleep 2 && echo "✅ http://localhost:8080"
mock-down:
docker-compose -f tools/docker/compose.yml down emlog-mock
mock-logs:
docker-compose -f tools/docker/compose.yml logs -f emlog-mock
ha-up: update-ha-config
@echo "🏠 Home Assistant starten..."
docker-compose -f tools/docker/compose.yml up homeassistant
ha-down:
docker-compose -f tools/docker/compose.yml down homeassistant
ha-logs:
docker-compose -f tools/docker/compose.yml logs -f homeassistant
ha-reload:
@echo "🔄 Kopiere Integration ins Test-Verzeichnis..."
@mkdir -p tests/config/custom_components
@cp -r custom_components/emlog tests/config/custom_components/
@echo "✅ Integration kopiert"
@echo "🔄 Starte Home Assistant neu..."
@docker restart docker-homeassistant-1 || (echo "⚠️ Container-Name nicht gefunden, versuche mit compose..." && docker-compose -f tools/docker/compose.yml restart homeassistant)
@sleep 5
@echo "✅ Home Assistant neugestartet"
@echo "📊 Prüfe Integration..."
@docker logs docker-homeassistant-1 2>&1 | grep -i "emlog" | tail -5 || echo "⚠️ Keine Emlog-Logs gefunden"
update-ha-config:
@python3 tools/scripts/update_ha_config.py
dev-up: update-ha-config
@echo "🚀 Starte Dev-Umgebung..."
docker-compose -f tools/docker/compose.yml up -d
@sleep 3 && echo "✅ HA: http://localhost:8123"
dev-down:
docker-compose -f tools/docker/compose.yml down
dev-logs:
docker-compose -f tools/docker/compose.yml logs -f
test:
@bash tools/scripts/test.sh
test-api:
@echo "🔍 Teste Mock API..."
@curl -s "http://localhost:8080/pages/getinformation.php?export&meterindex=1" | python3 -m json.tool | head -15
lint:
@echo "🔍 Prüfe Code..."
@find custom_components -name "*.py" -exec python3 -m py_compile {} \; && echo "✅ Python OK"
check-logs:
@echo "🔍 Prüfe Home Assistant Logs auf Fehler..."
@if [ ! -f "tests/config/home-assistant.log.1" ]; then \
echo "⚠️ Keine HA Logs gefunden - Home Assistant läuft möglicherweise nicht"; \
exit 1; \
fi
@echo ""
@echo "Suche nach ImportError..."
@if tail -500 tests/config/home-assistant.log.1 | grep -i "ImportError\|cannot import"; then \
echo "❌ ImportError gefunden!"; \
echo ""; \
echo "Fehlerdetails:"; \
tail -500 tests/config/home-assistant.log.1 | grep -A 5 "ImportError\|cannot import" | head -30; \
exit 1; \
else \
echo "✅ Keine ImportError gefunden"; \
fi
@echo ""
@echo "Suche nach Setup-Fehlern..."
@if tail -500 tests/config/home-assistant.log.1 | grep -i "Setup failed for custom integration"; then \
echo "❌ Setup Fehler gefunden!"; \
echo ""; \
echo "Fehlerdetails:"; \
tail -500 tests/config/home-assistant.log.1 | grep -B 2 -A 5 "Setup failed for custom integration" | head -30; \
exit 1; \
else \
echo "✅ Kein Setup Fehler gefunden"; \
fi
@echo ""
@echo "Suche nach anderen Modulfehlern..."
@if tail -500 tests/config/home-assistant.log.1 | grep -E "ModuleNotFoundError|AttributeError.*module"; then \
echo "❌ Modulfehler gefunden!"; \
echo ""; \
echo "Fehlerdetails:"; \
tail -500 tests/config/home-assistant.log.1 | grep -B 2 -A 5 -E "ModuleNotFoundError|AttributeError.*module" | head -30; \
exit 1; \
else \
echo "✅ Keine anderen Modulfehler gefunden"; \
fi
@echo ""
@echo "✅ Alle Log-Checks bestanden!"
clean:
@echo "🧹 Cleanup..."
docker-compose -f tools/docker/compose.yml down
full-clean: clean
docker-compose -f tools/docker/compose.yml down -v --rmi local 2>/dev/null || true
rm -rf tests/config/.storage tests/config/*.db*
status:
docker-compose -f tools/docker/compose.yml ps
version:
@echo "Version: $$(git describe --tags --abbrev=0 2>/dev/null || echo 'unreleased')"
@git status --short | head -5
release-dry-run:
@echo "🚀 Teste Semantic Release (Dry-Run)..."
@echo ""
@semantic-release --dry-run 2>&1 | grep -E "✔|✘|The (next|release|Repository)" || true
release-notes:
@echo "📝 Generierte Release Notes:"
@echo ""
@semantic-release --dry-run 2>&1 | grep -A 50 "Release note for version" | head -60
release:
@echo "🚀 Führe Semantic Release aus..."
@echo ""
@echo "⚠️ Dies wird:"
@echo " • Git Tags synchronisieren"
@echo " • Commits analysieren"
@echo " • Version berechnen"
@echo " • CHANGELOG.md aktualisieren"
@echo " • Git Tag erstellen"
@echo " • GitHub Release veröffentlichen"
@echo " • Änderungen zu Git pushen"
@echo ""
@read -p "Fortfahren? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "📥 Synchronisiere Git Tags..."; \
git fetch --all --tags --force; \
echo "✅ Git Tags synchronisiert"; \
echo ""; \
CI=true npx semantic-release; \
else \
echo "Release abgebrochen."; \
fi
release-github:
@echo "🚀 Triggere GitHub Actions Release Workflow..."
@echo ""
@gh workflow run release.yml --repo strausmann/hacs_emlog && \
echo "✅ Workflow getriggert!" && \
echo "" && \
echo "📊 Workflow Status anzeigen:" && \
echo " make status: gh run list --workflow=release.yml --limit 3" && \
echo "" && \
echo "🌐 Im Browser öffnen:" && \
echo " https://github.com/strausmann/hacs_emlog/actions/workflows/release.yml" || \
echo "❌ Fehler beim Triggern. Siehe CONTRIBUTING.md für PAT Setup-Anleitung."