-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
113 lines (95 loc) · 2.73 KB
/
Makefile
File metadata and controls
113 lines (95 loc) · 2.73 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
## @build
DOCKER_BUILDX_CMD ?= docker buildx
IMAGE_BUILD_CMD ?= $(DOCKER_BUILDX_CMD) build
IMAGE_BUILD_EXTRA_OPTS ?=
IMAGE_REGISTRY ?= inftyai
IMAGE_NAME ?= alphatrion
IMAGE_REPO := $(IMAGE_REGISTRY)/$(IMAGE_NAME)
GIT_TAG ?= $(shell git describe --tags --dirty --always)
IMG ?= $(IMAGE_REPO):$(GIT_TAG)
PLATFORMS ?= linux/arm64,linux/amd64
POETRY := poetry
RUFF := .venv/bin/ruff
PYTEST := .venv/bin/pytest
ALEMBIC := .venv/bin/alembic
PYTHON := .venv/bin/python
.PHONY: build
build: lint build-dashboard
$(POETRY) build
.PHONY: publish
publish: build
$(POETRY) publish --username=__token__ --password=$(INFTYAI_PYPI_TOKEN)
.PHONY: up
up:
docker compose -f ./docker-compose.yaml up -d
.PHONY: migrate-clickhouse
migrate-clickhouse:
$(PYTHON) -m migrations.clickhouse.cli migrate
.PHONY: migrate
migrate:
@if [ ! -f $(ALEMBIC) ]; then \
echo "Alembic not found, installing..."; \
$(POETRY) install alembic; \
fi
$(ALEMBIC) upgrade head
.PHONY: migrate-all
migrate-all: migrate migrate-clickhouse
.PHONY: down
down:
docker compose -f ./docker-compose.yaml down
.PHONY: lint
lint:
$(RUFF) check .
.PHONY: format
format:
$(RUFF) format .
$(RUFF) check --fix .
.PHONY: test
test: lint
$(PYTEST) tests/unit --timeout=15
.PHONY: test-integration
test-integration: lint
@bash -c '\
set -e; \
docker-compose -f ./docker-compose.yaml up -d; \
trap "docker-compose -f ./docker-compose.yaml down" EXIT; \
echo "Waiting for PostgreSQL..."; \
until docker exec postgres pg_isready -U alphatr1on; do sleep 1; done; \
echo "Waiting for ClickHouse..."; \
until docker exec clickhouse clickhouse-client --query "SELECT 1"; do sleep 1; done; \
echo "Waiting for Ollama..."; \
until curl -sf http://localhost:11434/api/tags | grep "smollm:135m" > /dev/null; do sleep 1; done; \
echo "Running migrations..."; \
make migrate-all; \
echo "Running integration tests..."; \
$(PYTEST) tests/integration --timeout=30; \
'
.PHONY: test-all
test-all: test test-integration
.PHONY: seed
seed:
$(PYTHON) hack/seed.py seed
.PHONY: seed-cleanup
seed-cleanup:
$(PYTHON) hack/seed.py cleanup
.PHONY: build-dashboard
build-dashboard:
cd dashboard && npm install && npm run build
.PHONY: image-build
image-build:
$(IMAGE_BUILD_CMD) -t $(IMG) \
--platform=$(PLATFORMS) \
$(IMAGE_BUILD_EXTRA_OPTS) ./
image-load: IMAGE_BUILD_EXTRA_OPTS=--load
image-load: image-build
image-push: IMAGE_BUILD_EXTRA_OPTS=--push
image-push: image-build
.PHONY: image-build-dashboard
image-build-dashboard:
$(IMAGE_BUILD_CMD) -t $(IMG) \
--platform=$(PLATFORMS) \
$(IMAGE_BUILD_EXTRA_OPTS) ./dashboard
image-load-dashboard: IMAGE_BUILD_EXTRA_OPTS=--load
image-load-dashboard: image-build-dashboard
image-push-dashboard: IMAGE_BUILD_EXTRA_OPTS=--push
image-push-dashboard: image-build-dashboard