-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (137 loc) · 5.6 KB
/
Makefile
File metadata and controls
158 lines (137 loc) · 5.6 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
# Directories
SCRIPTS_DIR := ./scripts
DOCKER_DIR := ./docker
FRONTEND_DIR := ./frontend/interactEM
OPERATORS_DIR := ./operators
ROOT_DIR := $(shell pwd)
# Makefile configuration
.PHONY: help setup setup-docker-registry services docker-up docker-down clean lint operators check-docker-permission integration-test
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c
.DEFAULT_GOAL := help
INTEGRATION_MARKER ?= integration
# Reusable function
define success
@echo "✓ $(1)"
endef
define section
@echo "\n$(1)"
endef
define check_not_root
@if [ "$$(id -u)" -eq 0 ]; then \
echo "Error: This command should not be run as root" >&2; \
echo "Please run 'make $(1)' without sudo" >&2; \
exit 1; \
fi
endef
define check_uv_installed
@if ! command -v uv &> /dev/null; then \
echo "Error: 'uv' is required to run 'make operators' but is not installed" >&2; \
exit 1; \
fi
endef
# Auto-generated help from target comments
help: ## Show this help message
@echo "Available targets:"
@grep -E "^[a-zA-Z_-]+:.*##" $(MAKEFILE_LIST) | \
sed -E 's/^([a-zA-Z_-]+):.*## */\1|/' | \
column -t -s '|' | sed 's/^/ /'
@echo ""
# Check if we can run docker commands
check-docker-permission:
$(SCRIPTS_DIR)/check-docker-permission.sh
$(call success,Docker permission check passed)
setup: ## Setup .env file with generated secure secrets
$(call check_not_root,setup)
$(call section,Setting up environment...)
@echo "Copying .env.example files to .env..."
$(SCRIPTS_DIR)/copy-dotenv.sh
$(SCRIPTS_DIR)/setup-podman-socket.sh
$(SCRIPTS_DIR)/setup-secrets.sh
$(call success,Environment setup complete! Next steps:)
@echo " 1. Edit .env to add GITHUB_USERNAME and GITHUB_TOKEN. Should be a classic token with read:packages scope."
@echo " 2. Run 'make docker-up' to build + start services."
services: check-docker-permission ## Build Docker images for all services
@echo "Building Docker images..."
$(DOCKER_DIR)/bake.sh
docker-up: ## Start all services with docker-compose
@USER_ID=$(shell id -u) GROUP_ID=$(shell id -g) docker compose up --force-recreate --remove-orphans --build -d
$(call success,Services started)
$(SCRIPTS_DIR)/setup-container-host.sh
$(call success,Container host setup complete)
@bash -c '\
if grep -qE "^GITHUB_USERNAME=$$|^GITHUB_TOKEN=$$" .env; then \
echo ""; \
echo "⚠️ WARNING: GitHub credentials not configured"; \
echo "GITHUB_USERNAME and/or GITHUB_TOKEN are empty in .env"; \
echo "Frontend will only display local operators and skip operators on the remote container registry."; \
echo ""; \
fi'
@echo " Visit http://localhost:5173 in your browser"
@echo ""
@echo "Login credentials:"
@grep "FIRST_SUPERUSER_USERNAME\|FIRST_SUPERUSER_PASSWORD" .env | sed 's/^/ /'
@echo ""
docker-down: ## Stop all services
@docker compose down
clean: ## Stop services and remove volumes (WARNING: will delete database data)
@docker compose down -v
$(call success,Services stopped and volumes removed)
gen: ## Generate client, models, and type definitions (gen-client + pydantic-to-ts + deduplicate-enums)
$(call section,Generating TypeScript client and models...)
$(SCRIPTS_DIR)/generate-client.sh
$(call section,Generating TypeScript models from Pydantic...)
uv run --project backend/core/ backend/core/scripts/pydantic_to_ts.py
$(call section,Deduplicating enums...)
cd $(FRONTEND_DIR) && npm run deduplicate-enums
$(call section,Running linters...)
$(MAKE) lint
$(call success,Code generation complete)
lint: ## Run backend (ruff) and frontend (biome) linters
@echo "Running ruff linter..."
@if command -v ruff >/dev/null 2>&1; then \
ruff check . --fix; \
else \
echo "Warning: 'ruff' not found in PATH; skipping backend lint." >&2; \
fi
@echo "Running biome linter..."
cd $(FRONTEND_DIR) && npm run lint
$(call success,Linting complete)
## Set up local Docker registry for operator builds
setup-docker-registry: check-docker-permission
$(call section,Setting up local Docker registry...)
$(SCRIPTS_DIR)/setup-docker-registry.sh
operator: setup-docker-registry ## Build a specific operator and push to local podman registry (use target=OPERATOR_NAME)
$(call check_uv_installed)
@if [ -z "$(target)" ]; then \
echo "Error: target variable not set. Usage: make operator target=OPERATOR_NAME" >&2; \
exit 1; \
fi
$(call section,Building operator $(target)...)
$(OPERATORS_DIR)/bake.sh --push-local --pull-local --build-base --target $(target)
$(call success,Operator $(target) built and pushed to local registry)
operators: setup-docker-registry ## Build all operators and push to local podman registry
$(call check_uv_installed)
$(call section,Building operators...)
$(OPERATORS_DIR)/bake.sh --push-local --pull-local --build-base
$(call success,Operators built and pushed to local registry)
push-operators: setup-docker-registry ## Build + push operators to remote registry
$(call section,Building + pushing to remote registry...)
$(OPERATORS_DIR)/bake.sh --push-remote --build-base
$(call success,Operators pushed to remote registry)
test: ## Run tests
uv run pytest backend/ --ignore=backend/launcher/ --ignore=backend/app/
$(call success,Tests complete)
integration-test: ## Run integration tests against the docker-compose stack using the configured marker
$(call section,Running integration tests...)
@status=0; \
set -a; if [ -f .env ]; then . ./.env; fi; set +a; \
uv run pytest tests -m "$(INTEGRATION_MARKER)" || status=$$?; \
if [ $$status -eq 5 ]; then \
echo "No tests collected for marker '$(INTEGRATION_MARKER)'; skipping."; \
status=0; \
fi; \
if [ $$status -eq 0 ]; then \
cd $(FRONTEND_DIR) && npm run test:e2e -- --fail-on-flaky-tests || status=$$?; \
fi; \
exit $$status