-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
79 lines (66 loc) · 2.11 KB
/
Makefile
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
# Variables
APP ?= # Specify the app (e.g., cookie-api, mock-gov-site, self-service)
DOCKER_TAG ?= latest
PYTHON_RUNNER ?= poetry
# Paths
ROOT_DIR := $(shell pwd)
APP_DIR := $(ROOT_DIR)/$(APP)
# Help message (default target)
.PHONY: help
help:
@echo "Available commands:"
@echo " make install Install Python dependencies using Poetry"
@echo " make lint Run pre-commit hooks"
@echo " make test Run tests with pytest"
@echo " make docker-build Build Docker image for specified app"
@echo " make docker-run Run the Docker container for specified app"
@echo " make clean Clean up Docker images and containers"
@echo " make code-quality Run Python and TypeScript checks and formatting"
@echo " make code-quality-fix Fix code quality issues"
@echo " make code-quality-check Check code quality issues"
# Global commands
.PHONY: install lint test code-quality code-quality-fix code-quality-check
install:
@echo "Installing dependencies..."
$(PYTHON_RUNNER) install
lint:
@echo "Running pre-commit hooks..."
pre-commit run --all-files
test:
@echo "Running tests..."
pytest
code-quality-fix:
# Python
poetry install --only ci
poetry run ruff --fix . || true
poetry run black . || true
# TypeScript
cd client && npm ci
cd client && npm run lint -- --fix || true
cd client && npm run format || true
code-quality-check:
# Python
poetry install --only ci
poetry run ruff .
poetry run black --check .
# TypeScript
cd client && npm ci
cd client && npm run lint
cd client && npm run format -- --check
code-quality:
@echo "Running code-quality-fix and code-quality-check..."
make code-quality-fix
make code-quality-check
# Docker commands
.PHONY: docker-build docker-run
docker-build:
@echo "Building Docker image for $(APP)..."
docker build --platform linux/arm64 -f $(APP_DIR)/Dockerfile -t $(APP):$(DOCKER_TAG) $(ROOT_DIR)
docker-run:
@echo "Running Docker container for $(APP)..."
docker run --rm -it -p 8000:8000 $(APP):$(DOCKER_TAG)
# Clean commands
.PHONY: clean
clean:
@echo "Cleaning up Docker images and containers..."
docker system prune -f