-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (89 loc) · 2.89 KB
/
Makefile
File metadata and controls
111 lines (89 loc) · 2.89 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
#!/usr/bin/env make -f
#
# Configuration
#
BACKEND_DIR = ./src/backend
FRONTEND_DIR = ./src/frontend
#
# Setup
#
# - Ensure the .env file is copied over first
.env:
@cp sample.env .env
# - Include .env variables & set defaults (if needed)
-include .env
# - Directories
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SUBDIR_ROOTS := docs
DIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
GARBAGE_PATTERNS := *.pyc *~ *-checkpoint.ipynb *.egg-info __pycache__/
GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
#
# Recipes
#
.DEFAULT-GOAL := help-short
# Help
.PHONY: help-short
help-short:
@printf 'Usage: make \033[36m[target]\033[0m\n'
@echo ''
@echo 'Available targets:'
@grep -E '^[a-zA-Z_-]+:.*? ## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*? ## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ''
.PHONY: help
help: ## Shows the help menu for all targets.
@printf 'Usage: make \033[36m[target]\033[0m\n'
@echo ''
@echo 'Main targets:'
@grep -E '^[a-zA-Z_-]+:.*? ## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*? ## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ''
@echo 'Specific sub-targets:'
@grep -E '^[a-zA-Z_-]+:.*? ### .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*? ### "}; {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}'
@echo ''
# Environment
.PHONY: setup
setup: setup-backend setup-frontend ## Sets up the development environment.
.PHONY: setup-backend
setup-backend: ### Sets up the backend's development environment.
$(MAKE) -C $(BACKEND_DIR) setup
.PHONY: setup-frontend
setup-frontend: ### Sets up the frontend's development environment.
$(MAKE) -C $(FRONTEND_DIR) setup
.PHONY: teardown
teardown: ## Tears down the development environment.
$(MAKE) -C $(BACKEND_DIR) teardown
.PHONY: clean
clean: ## Cleans up unnecessary project files.
rm -rf $(GARBAGE)
$(MAKE) -C $(BACKEND_DIR) clean
# Unit testing
.PHONY: test
test: test-backend ## Runs the project's unit tests.
.PHONY: test-backend
test-backend: ## Runs the backend's unit tests.
$(MAKE) -C $(BACKEND_DIR) test
# Coverage
.PHONY: coverage
coverage: coverage-backend ## Runs code coverage checks.
.PHONY: coverage-backend
coverage-backend: ### Runs code coverage checks on the backend.
$(MAKE) -C $(BACKEND_DIR) coverage
# Linting
.PHONY: lint
lint: lint-backend ## Runs all code linting.
.PHONY: lint-backend
lint-backend: ### Runs code linting on the backend.
$(MAKE) -C $(BACKEND_DIR) lint
# Debugging
.PHONY: debug
debug: debug-backend ## Debugs the application on the local machine.
.PHONY: debug-backend
debug-backend: ### Runs the backend application for debugging.
$(MAKE) -C $(BACKEND_DIR) debug
.PHONY: debug-frontend
debug-frontend: ### Runs the frontend application for debugging.
$(MAKE) -C $(FRONTEND_DIR) debug
# Misc.
.PHONY: cloc
cloc: ## Count lines of code
cloc ./scripts ./src --exclude-dir=__pycache__,.nuxt,dist,node_modules