-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (87 loc) · 5.22 KB
/
Copy pathMakefile
File metadata and controls
101 lines (87 loc) · 5.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
# ────────────────────────────────────────────────────────────────────────────
# engineering-pulse — day-2 operations
# ────────────────────────────────────────────────────────────────────────────
INSTALL_DIR ?= $(HOME)/.engineering-pulse
BIN_DIR ?= $(HOME)/bin
RUNNER := $(BIN_DIR)/run-daily-dashboard.sh
PLIST_LABEL := com.$(shell whoami).daily-dashboard
PLIST_PATH := $(HOME)/Library/LaunchAgents/$(PLIST_LABEL).plist
LOG_FILE := /tmp/daily-dashboard.log
PYTHON := $(INSTALL_DIR)/.venv/bin/python3
.DEFAULT_GOAL := help
# ── Help ─────────────────────────────────────────────────────────────────────
.PHONY: help
help:
@echo ""
@echo " engineering-pulse — available targets"
@echo ""
@echo " make run Run now (foreground: stream logs to terminal + /tmp/log)"
@echo " make run-bg Run in background (log file only)"
@echo " make status Show LaunchAgent status"
@echo " make logs Tail the run log"
@echo " make logs-launchd Tail the launchd stdout/stderr"
@echo " make update Pull latest code + reinstall dependencies"
@echo " make test Run the test suite with coverage"
@echo " make schedule Reload the LaunchAgent (after plist changes)"
@echo " make unschedule Unload the LaunchAgent (pause the schedule)"
@echo " make uninstall Remove everything (LaunchAgent + files)"
@echo " make config Open .env in your default editor"
@echo ""
# ── Run ──────────────────────────────────────────────────────────────────────
.PHONY: run
run:
@echo "→ Running daily dashboard (foreground → terminal + append $(LOG_FILE))…"
@ENGINEERING_PULSE_RUN_FG=1 "$(RUNNER)"
.PHONY: run-bg
run-bg:
@echo "→ Running daily dashboard (background)…"
@"$(RUNNER)" &
@echo " Logs: tail -f $(LOG_FILE)"
# ── Logs ─────────────────────────────────────────────────────────────────────
.PHONY: logs
logs:
@tail -f $(LOG_FILE)
.PHONY: logs-launchd
logs-launchd:
@echo "─── stdout ───────────────────────────────────────"
@tail -40 /tmp/daily-dashboard-launchd.out 2>/dev/null || echo "(empty)"
@echo "─── stderr ───────────────────────────────────────"
@tail -40 /tmp/daily-dashboard-launchd.err 2>/dev/null || echo "(empty)"
# ── LaunchAgent ──────────────────────────────────────────────────────────────
.PHONY: status
status:
@echo "→ LaunchAgent status:"
@launchctl list | grep "$(PLIST_LABEL)" || echo " (not loaded)"
@echo ""
@echo "→ Plist: $(PLIST_PATH)"
@ls -la "$(PLIST_PATH)" 2>/dev/null || echo " (not found)"
.PHONY: schedule
schedule:
@launchctl unload "$(PLIST_PATH)" 2>/dev/null || true
@launchctl load "$(PLIST_PATH)"
@echo "✓ LaunchAgent reloaded: $(PLIST_LABEL)"
.PHONY: unschedule
unschedule:
@launchctl unload "$(PLIST_PATH)" 2>/dev/null && echo "✓ LaunchAgent unloaded" || echo " (was not loaded)"
# ── Update ───────────────────────────────────────────────────────────────────
.PHONY: update
update:
@echo "→ Pulling latest code…"
@git -C "$(INSTALL_DIR)" pull --ff-only
@echo "→ Updating dependencies…"
@$(INSTALL_DIR)/.venv/bin/pip install --quiet --upgrade pip
@$(INSTALL_DIR)/.venv/bin/pip install --quiet -r "$(INSTALL_DIR)/requirements.txt"
@echo "✓ Update complete"
# ── Test ─────────────────────────────────────────────────────────────────────
.PHONY: test
test:
@cd "$(INSTALL_DIR)" && \
.venv/bin/python -m pytest tests/ --cov=scripts --cov-report=term-missing -q
# ── Config ───────────────────────────────────────────────────────────────────
.PHONY: config
config:
@$${EDITOR:-nano} "$(INSTALL_DIR)/.env"
# ── Uninstall ────────────────────────────────────────────────────────────────
.PHONY: uninstall
uninstall:
@bash "$(INSTALL_DIR)/uninstall.sh"