-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
156 lines (124 loc) · 6.67 KB
/
Makefile
File metadata and controls
156 lines (124 loc) · 6.67 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
# NOTE: This Makefile assumes that dependencies are installed and, if a virtual
# environment is used, it is activated.
## Variables ##################################################################
# NOTE: Define any variables here if needed in the future
## Documentation ##############################################################
# NOTE: Keep all the targets in alphabetical order for better readability.
default: help
.PHONY: help
help:
@echo "\nUsage: make [target] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Available targets:\n"
@echo "Code Quality ------------------------------------------------------------------"
@echo " \033[1m\033[35mformat-lint\033[0m \033[37m(fl)\033[0m: \033[36mRun linter, formatter, spellcheck.\033[0m"
@echo " \033[1m\033[35mprecommit-check\033[0m \033[37m(pc)\033[0m: \033[36mRun all pre-commit checks.\033[0m"
@echo " \033[1m\033[35msecurity\033[0m \033[37m(s)\033[0m: \033[36mRun security scans.\033[0m"
@echo " \033[1m\033[35mtype-check\033[0m \033[37m(tc)\033[0m: \033[36mPerform type checking.\033[0m\n"
{% if cookiecutter.add_docker_image == "y" %}
@echo "Deployment --------------------------------------------------------------------"
@echo " \033[1m\033[35mbuild-docker-image\033[0m \033[37m(bdi)\033[0m: \033[36mBuild the Docker image.\033[0m"
@echo " \033[1m\033[35mclean-docker-image\033[0m \033[37m(cdi)\033[0m: \033[36mRemove the Docker image.\033[0m"
@echo " \033[1m\033[35mrun-docker-image\033[0m \033[37m(rdi)\033[0m: \033[36mRun the Docker container.\033[\n"
{% endif %}
@echo "Documentation -----------------------------------------------------------------"
@echo " \033[1m\033[35mdocs\033[0m \033[37m(d)\033[0m: \033[36mGenerate project documentation.\033[0m\n"
@echo "Environment Management --------------------------------------------------------"
@echo " \033[1m\033[35mclean-venv\033[0m \033[37m(cv)\033[0m: \033[36mRemove virtual environment.\033[0m"
@echo " \033[1m\033[35minstall\033[0m \033[37m(i)\033[0m: \033[36mInstall app and dependencies.\033[0m"
@echo " \033[1m\033[35mvenv\033[0m \033[37m(v)\033[0m: \033[36mCreate virtual environment.\033[0m\n"
@echo "Miscellaneous -----------------------------------------------------------------"
@echo " \033[1m\033[35mupdate\033[0m \033[37m(u)\033[0m: \033[36mUpdate template.\033[0m\n"
@echo "Testing -----------------------------------------------------------------------"
@echo " \033[1m\033[35mtest\033[0m \033[37m(t)\033[0m: \033[36mRun all tests.\033[0m\n"
## Autogenerated Targets ######################################################
# NOTE: Keep all the targets in alphabetical order for better readability.
# NOTE: Do not modify the autogenerated targets, unless necessary, write custom
# targets in the custom section below..
{% if cookiecutter.add_docker_image == "y" %}
.PHONY: build-docker-image bdi
build-docker-image:
@echo "\nBuilding Docker image +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@docker build -t {{ cookiecutter.github_username }}/{{ cookiecutter.project_name_dashed }}:latest -f deployment/images/Dockerfile .
@echo "\nDocker image built successfully: {{ cookiecutter.github_username }}/{{ cookiecutter.project_name_dashed }}:latest\n"
bdi: build-docker-image
.PHONY: clean-docker-image cdi
clean-docker-image:
@echo "\nRemoving Docker image +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@docker rmi {{ cookiecutter.github_username }}/{{ cookiecutter.project_name_dashed }}:latest || echo "Docker image not found."
@echo "\nDocker image removed successfully (if it existed).\n"
cdi: clean-docker-image
{% endif %}
.PHONY: clean-venv cv
clean-venv:
@echo "\nRemoving the virtual environment ++++++++++++++++++++++++++++++++++++++++++++++\n"
@rm -rf .venv
cv: clean-venv
.PHONY: docs d
docs:
@echo "\nGenerating project documentation ++++++++++++++++++++++++++++++++++++++++++++++\n"
@poetry run sphinx-apidoc -f -o docs/source/pages {{ cookiecutter.project_name_underscored }}
@cd docs && make html
@echo "\nSummary ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Documentation generated successfully."
@echo "Open docs/build/html/index.html in your browser."
@echo "Or serve it locally using:"
@echo "python -m http.server -d docs/build/html/"
d: docs
.PHONY: format-lint fl
format-lint:
@echo "\nRunning linter and formatter using ruff and typos +++++++++++++++++++++++++++++\n"
@poetry run ruff format && poetry run ruff check --fix
@typos .
fl: format-lint
.PHONY: install i
install:
@echo "\nInstalling this package its dependencies +++++++++++++++++++++++++++++++++\n"
@poetry install --with=code_quality,docs,misc,test,types,vulnerability
i: install
.PHONY: precommit-check pc
precommit-check:
@echo "\nRunning pre-commit checks +++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@poetry run pre-commit run --all-files
pc: precommit-check
{% if cookiecutter.add_docker_image == "y" %}
.PHONY: run-docker-image rdi
run-docker-image:
@echo "\nRunning Docker container +++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@docker run --rm {{ cookiecutter.github_username }}/{{ cookiecutter.project_name_dashed }}:latest
@echo "\nDocker container executed successfully.\n"
rdi: run-docker-image
{% endif %}
.PHONY: security s
security:
@echo "\nRunning security scans using bandit and safety ++++++++++++++++++++++++++++++++\n"
@poetry run safety check --full-report
@poetry run bandit -c pyproject.toml -r {{ cookiecutter.project_name_underscored }}
s: security
.PHONY: test t
test:
@echo "\nRunning tests using pytest ++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@poetry run pytest tests/
t: test
.PHONY: type-check tc
type-check:
@echo "\nPerforming type checking with mypy ++++++++++++++++++++++++++++++++++++++++++++\n"
@poetry run mypy {{ cookiecutter.project_name_underscored }}
tc: type-check
.PHONY: update u
update:
@echo "\nUpdating the template +++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Using latest version from remote: https://github.com/elixir-cloud-aai/cookiecutter-python."
@poetry run cruft update -y
u: update
.PHONY: venv v
venv:
@echo "\nCreating a virtual environment ++++++++++++++++++++++++++++++++++++++++++++++++\n"
@python -m venv .venv
@echo "\nSummary +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
@echo "Virtual environment created successfully."
@echo "To activate the environment for this shell session, run:"
@echo "source .venv/bin/activate"
v: venv
## Custom Targets #############################################################
# NOTE: Keep all the targets in alphabetical order for better readability.
# NOTE: Add any custom targets here if needed in the future.