-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (77 loc) · 2.75 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
# -- Docker
# Get the current user ID to use for docker run and docker exec commands
DOCKER_UID = $(shell id -u)
DOCKER_GID = $(shell id -g)
DOCKER_USER = $(DOCKER_UID):$(DOCKER_GID)
COMPOSE = DOCKER_USER=$(DOCKER_USER) docker compose
COMPOSE_RUN = $(COMPOSE) run --rm
COMPOSE_RUN_APP = $(COMPOSE_RUN) app
MKDOCS = $(COMPOSE_RUN) -e HOME=/app/.jupyterlab --publish "8000:8000" app mkdocs
JUPYTER = $(COMPOSE_RUN) -e HOME=/app/.jupyterlab --publish "8888:8888"
COMPOSE_RUN_JUPYTER = $(JUPYTER) app jupyter lab
default: help
# ======================================================================================
# FILES
# ======================================================================================
.jupyterlab:
mkdir -p .jupyterlab
# ======================================================================================
# RULES
# ======================================================================================
build: ## build the docker container
@$(COMPOSE) build
.PHONY: build
down: ## stop and remove the docker container
rm -rf .jupyterlab
@$(COMPOSE) down --rmi all -v --remove-orphans
.PHONY: down
docs-build: ## build documentation site
@$(MKDOCS) build
.PHONY: docs-build
docs-deploy: ## deploy documentation site
@$(MKDOCS) gh-deploy
.PHONY: docs-deploy
docs-serve: ## run mkdocs live server
@$(MKDOCS) serve --dev-addr 0.0.0.0:8000
.PHONY: docs-serve
jupyter: \
.jupyterlab
jupyter: ## run jupyter lab
@$(COMPOSE_RUN_JUPYTER) --notebook-dir=/app/docs --ip "0.0.0.0"
.PHONY: jupyter
test: ## run tests
bin/pytest -vv
.PHONY: test
# Nota bene: Black should come after isort just in case they don't agree...
lint: ## lint back-end python sources
lint: \
lint-isort \
lint-black \
lint-flake8 \
lint-pylint \
lint-bandit
.PHONY: lint
lint-black: ## lint back-end python sources with black
@echo 'lint:black started…'
@$(COMPOSE_RUN_APP) black src/multicons tests
.PHONY: lint-black
lint-flake8: ## lint back-end python sources with flake8
@echo 'lint:flake8 started…'
@$(COMPOSE_RUN_APP) flake8
.PHONY: lint-flake8
lint-isort: ## automatically re-arrange python imports in back-end code base
@echo 'lint:isort started…'
@$(COMPOSE_RUN_APP) isort --atomic .
.PHONY: lint-isort
lint-pylint: ## lint back-end python sources with pylint
@echo 'lint:pylint started…'
@$(COMPOSE_RUN_APP) pylint src/multicons tests
.PHONY: lint-pylint
lint-bandit: ## lint back-end python sources with bandit
@echo 'lint:bandit started…'
@$(COMPOSE_RUN_APP) bandit -qr src/multicons
.PHONY: lint-bandit
# -- Misc
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help