forked from jaredlockhart/penny
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (79 loc) · 3.51 KB
/
Makefile
File metadata and controls
97 lines (79 loc) · 3.51 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
# Check tool configuration (single source of truth for tool parameters)
RUFF_TARGETS = penny/
PYTEST_ARGS = penny/tests/ -v
TEAM_RUFF_TARGETS = penny_team/
TEAM_PYTEST_ARGS = tests/ -v
.PHONY: up prod kill build team-build browser-build fmt lint fix typecheck check pytest token migrate-test migrate-validate
# --- Docker Compose ---
up: browser-build
GIT_COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo unknown) \
GIT_COMMIT_MESSAGE=$$(git log -1 --pretty=%B 2>/dev/null | tr '\n' ' ' | sed 's/ *$$//' || echo unknown) \
SNAPSHOT=1 \
docker compose --profile team up --build
prod: browser-build
GIT_COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo unknown) \
GIT_COMMIT_MESSAGE=$$(git log -1 --pretty=%B 2>/dev/null | tr '\n' ' ' | sed 's/ *$$//' || echo unknown) \
SNAPSHOT=1 \
docker compose -f docker-compose.yml up --build penny signal-api
kill:
docker compose --profile team down --rmi local --remove-orphans
build:
GIT_COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo unknown) \
GIT_COMMIT_MESSAGE=$$(git log -1 --pretty=%B 2>/dev/null | tr '\n' ' ' | sed 's/ *$$//' || echo unknown) \
docker compose build penny
team-build:
docker compose build team
browser-build:
cd browser && npm install && npm run build
# Print a GitHub App installation token for use with gh CLI
# Usage: GH_TOKEN=$(make token) gh pr create ...
token:
@docker compose --profile team run --rm --no-deps --entrypoint "" pm uv run python /shared/github_api/auth.py 2>/dev/null
# --- Code quality (auto-detects host vs container via LOCAL env var) ---
ifdef LOCAL
# Inside a container — run tools directly
RUN = cd penny &&
TEAM_RUN = cd penny-team &&
else
# On host — run tools inside Docker containers
# --no-deps: dev tools don't need signal-api healthy (would block on first run)
RUN = docker compose run --rm --no-deps penny
TEAM_RUN = docker compose run --rm --no-deps team
endif
fix: $(if $(LOCAL),,build team-build)
$(RUN) ruff format $(RUFF_TARGETS)
$(RUN) ruff check --fix $(RUFF_TARGETS)
$(TEAM_RUN) ruff format $(TEAM_RUFF_TARGETS)
$(TEAM_RUN) ruff check --fix $(TEAM_RUFF_TARGETS)
typecheck: $(if $(LOCAL),,build team-build)
$(RUN) ty check $(RUFF_TARGETS)
$(TEAM_RUN) ty check $(TEAM_RUFF_TARGETS)
check: $(if $(LOCAL),,build team-build)
$(RUN) ruff format --check $(RUFF_TARGETS)
$(RUN) ruff check $(RUFF_TARGETS)
$(RUN) ty check $(RUFF_TARGETS)
$(RUN) python -m penny.database.migrate --validate
$(RUN) pytest $(PYTEST_ARGS)
$(TEAM_RUN) ruff format --check $(TEAM_RUFF_TARGETS)
$(TEAM_RUN) ruff check $(TEAM_RUFF_TARGETS)
$(TEAM_RUN) ty check $(TEAM_RUFF_TARGETS)
$(TEAM_RUN) pytest $(TEAM_PYTEST_ARGS)
cd browser && npm install --silent && npx tsc --noEmit
pytest: $(if $(LOCAL),,build team-build)
$(RUN) pytest $(PYTEST_ARGS)
$(TEAM_RUN) pytest $(TEAM_PYTEST_ARGS)
migrate-test: $(if $(LOCAL),,build)
$(RUN) python -m penny.database.migrate --test
migrate-validate: $(if $(LOCAL),,build)
$(RUN) python -m penny.database.migrate --validate
signal-avatar:
@python3 -c " \
import base64, json, os, urllib.request; \
number = os.environ.get('SIGNAL_NUMBER', ''); \
api = os.environ.get('SIGNAL_API_URL', 'http://localhost:8080'); \
f = open('penny.png', 'rb'); avatar = base64.b64encode(f.read()).decode(); f.close(); \
data = json.dumps({'name': 'Penny', 'avatar': avatar}).encode(); \
req = urllib.request.Request(api + '/v1/profiles/' + number, data=data, headers={'Content-Type': 'application/json'}, method='PUT'); \
urllib.request.urlopen(req, timeout=10); \
print('Signal avatar set for ' + number) \
"