-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
136 lines (105 loc) Β· 3.93 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
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
####----Basic configurations----####
.PHONY: pre-commit
install_pre_commit: ## configure and install pre commit tool
@poetry run pre-commit install
uninstall_pre_commit: ## configure and install pre commit tool
@poetry run pre-commit uninstall
.PHONY: install
install: ## Install the poetry and python environment
@echo "π Creating virtual environment using pyenv and poetry"
@poetry install
@poetry shell
install-poetry: ## Install the poetry environment
@echo "π Creating virtual environment using pyenv and poetry"
@poetry install
@poetry shell
install-pdm: ## Install the poetry environment
@echo "π Creating virtual environment using pyenv and PDM"
@pdm install
@pdm use
.PHONY: check_project
check_project: ## Run code quality tools.
@echo "π Checking Poetry lock file consistency with 'pyproject.toml': Running poetry lock --check"
@poetry lock --check
@echo "π Linting code: Running pre-commit"
@poetry run pre-commit run -a
# echo "π Checking for obsolete dependencies: Running deptry"
# poetry run deptry .
.PHONE: poetry_plugins
# poetry self add poetry-git-version-plugin
poetry_plugins_install: ## Install and configure the poetry plugins
@echo "Install poetry-plugin-sort"
@poetry self add poetry-plugin-sort
@poetry self add poetry-plugin-up
poetry_plugins: ## Launch the poetry plugins
@echo "Launching poetry-plugin-sort"
@poetry sort
.PHONY: test
test: ## Test the code with pytest.
@echo "π Testing code: Running pytest"
@poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml tests
### Project specific tasks
.PHONY: project
launch_py3:
python3 app/main.py
.PHONY: project
launch_py:
python app/main.py
####----Package Release----####
.PHONY: build
build: clean-build ## Build wheel file using poetry
@echo "π Creating wheel file"
@poetry build
.PHONY: clean-build
clean-build: ## clean build artifacts
@rm -rf dist
.PHONY: publish
publish: ## publish a release to pypi.
@echo "π Publishing: Dry run."
@poetry config pypi-token.pypi $(PYPI_TOKEN)
@poetry publish --dry-run
@echo "π Publishing."
@poetry publish
.PHONY: build-and-publish
build-and-publish: build publish ## Build and publish.
####----Documentation----####
.PHONY: docs-test
docs-test: ## Test if documentation can be built without warnings or errors
@mkdocs build -s
.PHONY: docs
docs: ## Build and serve the documentation
@mkdocs serve
####----Docker----####
.PHONY: docker
create_network: ## create the docker network for the project
docker network create template
launch: ## launch the python application containers
docker-compose -p template up --build -d
launch_all: ## launch the backend project containers only
docker-compose -p template up --build -d app
launch_db: ## launch the database container only
docker-compose -p template up --build -d db
check: ## check the status of the docker containers
docker ps -a | grep "template"
check_logs: ## check the logs of the application container
docker logs -t app
check_exec: ## exec bash in the python app container
docker exec -it app /bin/bash
stop: ## stop all containers
docker-compose -p template down
# docker-compose down -v
stop_clear: ## stop containers and clean the volumes
docker-compose -p template down -v
clean_volumes: ## clean the docker volumes
docker volume prune
####----Project----####
.PHONY: help
help: ## Ask for help in the Makefile
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: project_clean
clean: ## Clean the projects of unwanted cached folders
rm -rf **/.ipynb_checkpoints **/.pytest_cache **/__pycache__ **/**/__pycache__ ./notebooks/ipynb_checkpoints .pytest_cache ./dist ./volumes
.PHONY: project_restore
restore: ## Restore the projects to the start (hard clean)
rm -rf **/.ipynb_checkpoints **/.pytest_cache **/__pycache__ **/**/__pycache__ ./notabooks/ipynb_checkpoints .pytest_cache ./dist .venv poetry.lock
.DEFAULT_GOAL := help