-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (129 loc) · 5.87 KB
/
Makefile
File metadata and controls
156 lines (129 loc) · 5.87 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
GITHUB_REPO := vicnasdev/drp
-include .env
export
.PHONY: help dev test migrate cleanup install \
ollama-build ollama-run ollama-stop \
issues issues-full issue close reopen issue-new
help: ## Show available commands
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-16s %s\n", $$1, $$2}'
# ── Server ────────────────────────────────────────────────────────────────────
dev: ## Start Django dev server
python manage.py runserver
test: ## Run all tests
pytest && python manage.py test core
migrate: ## Run migrations
python manage.py migrate
cleanup: ## Delete expired drops (DB + B2)
python manage.py cleanup
# ── CLI ───────────────────────────────────────────────────────────────────────
install: ## Install drp CLI locally (editable)
pip install -e .
# ── Ollama (local) ────────────────────────────────────────────────────────────
OLLAMA_MODEL ?= qwen2.5:1.5b
ollama-build: ## Build Ollama Docker image
docker build -t drp-ollama --build-arg OLLAMA_MODEL=$(OLLAMA_MODEL) ollama
ollama-run: ## Run Ollama locally on :11434
docker run --rm -d --name drp-ollama \
-p 11434:11434 \
-e OLLAMA_MODEL=$(OLLAMA_MODEL) \
drp-ollama
@echo " ✓ Ollama running on http://localhost:11434"
ollama-stop: ## Stop local Ollama container
docker stop drp-ollama 2>/dev/null || true
# ── GitHub Issues ─────────────────────────────────────────────────────────────
# Requires GITHUB_ISSUES_TOKEN in .env or environment.
# Usage:
# make issues
# make issues STATE=closed
# make issues-full
# make issue N=12
# make issue-new TITLE="bug: crash" BODY="steps..."
# make close N=12
# make reopen N=12
define ISSUES_PY
import sys, json
issues = json.load(sys.stdin)
if not issues:
print(" (none)")
else:
for i in issues:
labels = ", ".join(l["name"] for l in i.get("labels", []))
tag = f" [{labels}]" if labels else ""
print(f" #{i['number']:<5} {i['title']}{tag}")
endef
define ISSUES_FULL_PY
import sys, json
issues = json.load(sys.stdin)
if not issues:
print(" (none)")
for i in issues:
labels = ", ".join(l["name"] for l in i.get("labels", []))
print(f"#{i['number']} [{i['state'].upper()}] {i['title']}")
print(f" opened by @{i['user']['login']} | comments: {i['comments']}")
if labels: print(f" labels: {labels}")
print()
print(i.get("body") or "(no description)")
print()
print(f" {i['html_url']}")
print("-" * 60)
endef
define ISSUE_PY
import sys, json
i = json.load(sys.stdin)
labels = ", ".join(l["name"] for l in i.get("labels", []))
print(f"#{i['number']} [{i['state'].upper()}] {i['title']}")
print(f" opened by @{i['user']['login']} | comments: {i['comments']}")
if labels: print(f" labels: {labels}")
print()
print(i.get("body") or "(no description)")
print()
print(f" {i['html_url']}")
endef
export ISSUES_PY
export ISSUES_FULL_PY
export ISSUE_PY
_gh_check:
@test -n "$$GITHUB_ISSUES_TOKEN" || (echo " ✗ GITHUB_ISSUES_TOKEN not set" && exit 1)
issues: _gh_check ## List open issues (STATE=closed for closed)
@curl -sf \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues?state=$(or $(STATE),open)&per_page=50" \
| python3 -c "$$ISSUES_PY"
issues-full: _gh_check ## List open issues with full detail (STATE=closed for closed)
@curl -sf \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues?state=$(or $(STATE),open)&per_page=50" \
| python3 -c "$$ISSUES_FULL_PY"
issue: _gh_check ## Show a single issue: make issue N=12
@test -n "$(N)" || (echo " ✗ Usage: make issue N=<number>" && exit 1)
@curl -sf \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues/$(N)" \
| python3 -c "$$ISSUE_PY"
issue-new: _gh_check ## Create an issue: make issue-new TITLE="..." BODY="..."
@test -n "$(TITLE)" || (echo " ✗ Usage: make issue-new TITLE=\"...\" BODY=\"...\"" && exit 1)
@curl -sf -X POST \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues" \
-d "{\"title\": \"$(TITLE)\", \"body\": \"$(BODY)\"}" \
| python3 -c "import sys,json; i=json.load(sys.stdin); print(f\" ✓ Created #{i['number']}: {i['title']}\n {i['html_url']}\")"
close: _gh_check ## Close an issue: make close N=12
@test -n "$(N)" || (echo " ✗ Usage: make close N=<number>" && exit 1)
@curl -sf -X PATCH \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues/$(N)" \
-d '{"state": "closed"}' \
| python3 -c "import sys,json; i=json.load(sys.stdin); print(f\" ✓ Closed #{i['number']}: {i['title']}\")"
reopen: _gh_check ## Reopen an issue: make reopen N=12
@test -n "$(N)" || (echo " ✗ Usage: make reopen N=<number>" && exit 1)
@curl -sf -X PATCH \
-H "Authorization: token $$GITHUB_ISSUES_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$(GITHUB_REPO)/issues/$(N)" \
-d '{"state": "open"}' \
| python3 -c "import sys,json; i=json.load(sys.stdin); print(f\" ✓ Reopened #{i['number']}: {i['title']}\")"