-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
90 lines (72 loc) · 2.35 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
# -- General
SHELL := /bin/bash
# -- 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_TEST_RUN = $(COMPOSE_RUN)
COMPOSE_TEST_RUN_APP = $(COMPOSE_TEST_RUN) app
# -- OBC
OBC_IMAGE_NAME ?= obc
OBC_IMAGE_TAG ?= development
# ==============================================================================
# RULES
default: help
bootstrap: ## bootstrap the project for development
bootstrap: \
build \
dev
.PHONY: bootstrap
build: ## build the app container
build:
OBC_IMAGE_NAME=$(OBC_IMAGE_NAME) \
OBC_IMAGE_TAG=$(OBC_IMAGE_TAG) \
$(COMPOSE) build app
.PHONY: build
dev: ## perform editable install from mounted project sources
DOCKER_USER=0 docker compose run --rm app pip install -e ".[dev]"
.PHONY: dev
# 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 \
lint-pydocstyle
.PHONY: lint
lint-black: ## lint back-end python sources with black
@echo 'lint:black started…'
@$(COMPOSE_TEST_RUN_APP) black src/obc tests
.PHONY: lint-black
lint-flake8: ## lint back-end python sources with flake8
@echo 'lint:flake8 started…'
@$(COMPOSE_TEST_RUN_APP) flake8
.PHONY: lint-flake8
lint-isort: ## automatically re-arrange python imports in back-end code base
@echo 'lint:isort started…'
@$(COMPOSE_TEST_RUN_APP) isort --atomic .
.PHONY: lint-isort
lint-pylint: ## lint back-end python sources with pylint
@echo 'lint:pylint started…'
@$(COMPOSE_TEST_RUN_APP) pylint src/obc tests
.PHONY: lint-pylint
lint-bandit: ## lint back-end python sources with bandit
@echo 'lint:bandit started…'
@$(COMPOSE_TEST_RUN_APP) bandit -qr src/obc
.PHONY: lint-bandit
lint-pydocstyle: ## lint Python docstrings with pydocstyle
@echo 'lint:pydocstyle started…'
@$(COMPOSE_TEST_RUN_APP) pydocstyle
.PHONY: lint-pydocstyle
test: ## run back-end tests
bin/pytest
.PHONY: test
# -- 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