-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (92 loc) · 5.21 KB
/
Makefile
File metadata and controls
127 lines (92 loc) · 5.21 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
# -*- Mode: Makefile -*-
ROOT_DIR := $(shell git rev-parse --show-toplevel)
include $(ROOT_DIR)/Make.rules
DOCKER_BUILDKIT := 1
.PHONY: clean lint test test-units test-integrations mypy logs shell restart delete down up build dirs help package publish tag publish-tag uv-sync uv-lock uv-add uv-add-dev uv-upgrade profile
test-integrations: .venv
PYTHONPATH=`pwd` $(UV_RUN) pytest -m integration asimap/
test-units: .venv
PYTHONPATH=`pwd` $(UV_RUN) pytest -m "not integration" asimap/
test: .venv
PYTHONPATH=`pwd` $(UV_RUN) pytest asimap/
coverage: .venv
PYTHONPATH=`pwd` $(UV_RUN) coverage run -m pytest asimap/
$(UV_RUN) coverage html
open 'htmlcov/index.html'
build: version ## `docker build` for both `prod` and `dev` targets
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker build --build-arg PYTHON_VERSION="$(PYTHON_VERSION)" --build-arg VERSION="$(VERSION)" --target prod --tag asimap:$(VERSION) --tag asimap:prod .
COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker build --build-arg PYTHON_VERSION="$(PYTHON_VERSION)" --build-arg VERSION=$(VERSION) --target dev --tag asimap:$(VERSION)-dev --tag asimap:dev .
uv-sync: .venv ## Sync .venv with uv.lock (run after updating pyproject.toml or pulling changes)
@uv sync
uv-lock: ## Update uv.lock file from pyproject.toml dependencies
@uv lock
uv-add: ## Add a new dependency (usage: make uv-add PACKAGE=requests)
@if [ -z "$(PACKAGE)" ]; then \
echo "Error: PACKAGE not specified. Usage: make uv-add PACKAGE=requests"; \
exit 1; \
fi
@uv add $(PACKAGE)
uv-add-dev: ## Add a new dev dependency (usage: make uv-add-dev PACKAGE=pytest-xdist)
@if [ -z "$(PACKAGE)" ]; then \
echo "Error: PACKAGE not specified. Usage: make uv-add-dev PACKAGE=pytest-xdist"; \
exit 1; \
fi
@uv add --dev $(PACKAGE)
uv-upgrade: ## Upgrade all dependencies to latest compatible versions
@uv sync --upgrade
asimap_test_dir: ## Create directory running local development
@mkdir -p $(ROOT_DIR)/asimap_test_dir
traces_dir: ## Create traces directory for running local development
@mkdir -p $(ROOT_DIR)/asimap_test_dir/traces
ssl: ## Creates the ssl directory used to hold development ssl cert and key
@mkdir -p $(ROOT_DIR)/asimap_test_dir/ssl
dirs: asimap_test_dir ssl traces_dir
# XXX Should we have an option to NOT use certs/mkcert (either just make
# self-signed ourself) in case a developer does not want to go through the
# potential risks associated with mkcert?
#
asimap_test_dir/ssl/ssl_key.pem asimap_test_dir/ssl/ssl_crt.pem:
@mkcert -key-file $(ROOT_DIR)/asimap_test_dir/ssl/ssl_key.pem \
-cert-file $(ROOT_DIR)/asimap_test_dir/ssl/ssl_crt.pem \
`hostname` localhost 127.0.0.1 ::1
certs: ssl asimap_test_dir/ssl/ssl_key.pem asimap_test_dir/ssl/ssl_crt.pem ## uses `mkcert` to create certificates for local development.
up: build dirs certs ## build and then `docker compose up` for the `dev` profile. Use this to rebuild restart services that have changed.
@docker compose --profile dev up --remove-orphans --detach
down: ## `docker compose down` for the `dev` profile
@docker compose --profile dev down --remove-orphans
rebuild-restart: down build up ## docker compose down -> build -> up for the `dev` profile
delete: clean ## docker compose down for `dev` and `prod` and `make clean`.
@docker compose --profile dev down --remove-orphans
@docker compose --profile prod down --remove-orphans
restart: ## docker compose restart for the `dev` profile
@docker compose --profile dev restart
shell: ## Make a bash shell an ephemeral dev container
@docker compose run --rm -ti asimap-dev /bin/bash
exec-shell: ## Make a bash shell in the docker-compose running imap-dev container
@docker compose exec -ti asimap-dev /bin/bash
profile: ## Open a root shell in the running dev container for py-spy profiling
@docker compose exec -u root -ti asimap-dev /bin/bash
.package: version .venv $(PY_FILES) pyproject.toml README.md LICENSE Makefile
@PYTHONPATH=`pwd` $(UV_RUN) python -m build
@touch .package
package: .package ## build python package (.tar.gz and .whl)
install: version package ## Install asimap via pip install of the package wheel
pip install --force-reinstall -U $(ROOT_DIR)/dist/asimap-$(VERSION)-py3-none-any.whl
# Should mark the published tag as a release on github
release: package ## Make a release. Tag based on the version.
publish: package ## Publish the package to pypi
tag: version ## Tag the git repo with the current version of asimapd.
@if git rev-parse "$(VERSION)" >/dev/null 2>&1; then \
echo "Tag '$(VERSION)' already exists (skipping 'git tag')" ; \
else \
git tag --sign "$(VERSION)" -m "Version $(VERSION)"; \
echo "Tagged with '$(VERSION)'" ; \
fi
publish-tag: version tag ## Tag (if not already tagged) and publish the tag of the current version to git `origin` branch
@git push origin tag $(VERSION)
help: ## Show this help.
@grep -hE '^[A-Za-z0-9_ \-]*?:.*##.*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
clean:: ## Swab the decks! Does not touch docker images or volumes.
@rm -rf $(ROOT_DIR)/asimap_test_dir $(ROOT_DIR)/.package $(ROOT_DIR)/dist
logs: ## Tail the logs for imap-dev container
@docker compose logs -f imap-dev