-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
174 lines (142 loc) Β· 4.37 KB
/
Copy pathMakefile
File metadata and controls
174 lines (142 loc) Β· 4.37 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Makefile for cronjob-scheduler - Development and build tasks
# Prerequisites:
# - uv: for Python dependency management
# - Docker: for container builds and testing
.PHONY: help
# π Show available commands
help:
@printf "\nCronjob Scheduler Development Commands:\n\n"
@awk '/^#/{c=substr($$0,3);next}c&&/^[[:alpha:]][[:alnum:]_-]+:/{printf " \033[36m%-20s\033[0m %s\n", substr($$1,1,index($$1,":")-1),c}1{c=0}' $(MAKEFILE_LIST)
@printf "\nRun 'make install' to get started!\n\n"
###############
# Setup Tasks #
###############
.PHONY: install
# π Install all dependencies (including dev dependencies)
install:
@command -v uv >/dev/null 2>&1 || { echo "uv is required. See https://docs.astral.sh/uv/getting-started/installation/"; exit 1; }
uv sync --all-extras
.PHONY: install-hooks
# πͺ Install pre-commit hooks for automated checks
install-hooks:
@command -v uvx >/dev/null 2>&1 || { echo "uv is required. See https://docs.astral.sh/uv/getting-started/installation/"; exit 1; }
uvx pre-commit install
@echo "β
Pre-commit hooks installed! They'll run automatically on git commit."
@echo " Run 'uvx pre-commit run --all-files' to test them now."
######################
# Development Tasks #
######################
.PHONY: dev
# π§ Start development environment with docker-compose
dev:
docker compose up --build
.PHONY: dev-bg
# π§ Start development environment in background
dev-bg:
docker compose up --build -d
.PHONY: logs
# π Show logs from running containers
logs:
docker compose logs -f
.PHONY: down
# π Stop and remove development containers
down:
docker compose down -v
#############
# Testing #
#############
.PHONY: test
# π§ͺ Run all tests with coverage
test:
uv run pytest --cov=cronjob_scheduler --cov-report=term --cov-report=html
.PHONY: test-verbose
# π§ͺ Run tests with verbose output and duration tracking
test-verbose:
uv run pytest -v --durations=10 --cov=cronjob_scheduler --cov-report=term
.PHONY: test-fast
# β‘ Run tests without coverage (faster)
test-fast:
uv run pytest
.PHONY: test-watch
# π Run tests in watch mode (requires pytest-watch)
test-watch:
uv run ptw
#####################
# Code Quality #
#####################
.PHONY: check
# π§Ή Run all checks (lint, format, typecheck)
check: lint format-check typecheck typos
.PHONY: lint
# π Lint code with ruff
lint:
uv run ruff check
.PHONY: lint-fix
# π§ Lint and auto-fix issues
lint-fix:
uv run ruff check --fix
.PHONY: format
# β¨ Format code with ruff
format:
uv run ruff format
.PHONY: format-check
# π Check code formatting without changes
format-check:
uv run ruff format --check
.PHONY: typecheck
# π Run type checking with pyright
typecheck:
uv run pyright
.PHONY: typos
# π€ Check for typos in codebase
typos:
@command -v uvx >/dev/null 2>&1 || { echo "uv is required."; exit 1; }
uvx typos
.PHONY: typos-fix
# π§ Fix typos automatically
typos-fix:
@command -v uvx >/dev/null 2>&1 || { echo "uv is required."; exit 1; }
uvx typos --write-changes
##############
# Docker #
##############
.PHONY: build
# π³ Build production Docker image
build:
docker build -t cronjob-scheduler:latest --target production .
.PHONY: build-test
# π³ Build test Docker image
build-test:
docker build -t cronjob-scheduler:test --target test .
.PHONY: docker-test
# π§ͺ Run tests inside Docker container
docker-test: build-test
docker run --rm cronjob-scheduler:test uv run pytest
.PHONY: docker-check
# π§Ή Run all checks inside Docker container
docker-check: build-test
@echo "Running ruff check..."
docker run --rm cronjob-scheduler:test uv run ruff check
@echo "Running ruff format check..."
docker run --rm cronjob-scheduler:test uv run ruff format --check
@echo "Running pyright..."
docker run --rm cronjob-scheduler:test uv run pyright
@echo "β
All Docker checks passed!"
.PHONY: security-scan
# π Scan Docker image for vulnerabilities
security-scan: build
@command -v docker >/dev/null 2>&1 || { echo "Docker is required."; exit 1; }
docker scout cves cronjob-scheduler:latest
##############
# Cleanup #
##############
.PHONY: clean
# π§Ή Clean up generated files and caches
clean:
rm -rf .pytest_cache .ruff_cache .mypy_cache .coverage htmlcov
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
find . -type f -name "*.pyc" -delete
.PHONY: clean-all
# π§Ή Clean everything including venv
clean-all: clean
rm -rf .venv uv.lock