-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (66 loc) · 2.1 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
.PHONY: help install lint test start image push docker-compose-start deploy-k8s doc pypi clean
tag ?= v0.1.0
releaseName = toolbox
dockerhubUser = tyvek2zhang
toolboxDir = toolbox
deployDir = deploy
help:
@echo "Available make targets:"
@echo " install Install project dependencies using poetry."
@echo " lint Perform static code analysis."
@echo " test Run unit tests."
@echo " start Start the project."
@echo " image Build the Docker image for the project."
@echo " push Push Docker image to dockerHub."
@echo " docker-compose-start Start the project using Docker Compose."
@echo " deploy-k8s Deploy the project to Kubernetes."
@echo " doc Make doc for this project."
@echo " pypi Build and publish to pypi."
@echo " clean Remove temporary files."
@echo "Use 'make <target>' to run a specific command."
install:
cd $(toolboxDir) && \
poetry shell && \
poetry install
lint:
python -m pip install pre-commit && \
pre-commit run --all-files --verbose --show-diff-on-failure
test:
cd $(toolboxDir); \
rm -rf migrations/db/toolbox.db; \
rm -rf htmlcov; \
alembic upgrade head; \
coverage run -m pytest; \
coverage html
start:
cd $(toolboxDir) && \
alembic upgrade head && \
python apiserver.py
clean:
find . -type f -name '*.pyc' -delete; \
find . -type d -name __pycache__ -delete; \
rm -rf .pytest_cache; \
rm -rf .ruff_cache; \
rm -rf dist; \
rm -rf log; \
rm -rf poetry.lock; \
rm -rf docs/build; \
rm -rf $(toolboxDir)/htmlcov; \
rm -rf $(toolboxDir)/migrations/db/toolbox.db; \
rm -rf $(toolboxDir)/.env_toolbox; \
rm -rf $(toolboxDir)/.coverage; \
image: clean
docker build -t $(dockerhubUser)/$(releaseName):$(tag) .
push: image
docker push $(dockerhubUser)/$(releaseName):$(tag)
docker-compose-start:
cd ${deployDir} && \
docker-compose up -d
deploy-k8s:
kubectl apply -f ${deployDir}/k8s
doc:
pip install -r docs/requirements.txt; \
sphinx-build -M html docs/source/ docs/build/
pypi:
poetry build; \
poetry publish