-
Notifications
You must be signed in to change notification settings - Fork 5
/
makefile
123 lines (101 loc) · 3.99 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
.ONESHELL:
SHELL:= /bin/bash
.PHONY: test
BACKEND_DOCKER_EXEC=@docker exec -it django_react_starter_api
BACKEND_BASH_EXEC=$(BACKEND_DOCKER_EXEC) bash -c
FRONTEND_DOCKER_EXEC=@docker exec -it django_react_starter_front
FRONTEND_BASH_EXEC=$(FRONTEND_DOCKER_EXEC) bash -c
# Args
cmd=
env_file='.env'
opts=
# --------------------------------------------------
# Private
# --------------------------------------------------
_manage_py:
$(BACKEND_BASH_EXEC) "\
cd backend && \
source $(env_file) && \
python manage.py $(cmd) \
$(opts)"
# --------------------------------------------------
# Backend Utils
# --------------------------------------------------
api_bash:
$(BACKEND_DOCKER_EXEC) bash
api_ruff:
$(BACKEND_BASH_EXEC) "cd backend \
&& ruff check --select=I --fix . \
&& ruff check --fix --unsafe-fixes ."
api_shell:
@$(MAKE) -s _manage_py cmd=shell
# --------------------------------------------------
# Backend Database
# --------------------------------------------------
api_migrate:
@$(MAKE) -s _manage_py cmd=migrate
@$(MAKE) -s _manage_py cmd=migrate env_file='.env.test'
api_makemigrations:
@$(MAKE) -s _manage_py cmd=makemigrations
# --------------------------------------------------
# Backend Tests
# --------------------------------------------------
api_test:
@$(MAKE) -s _manage_py cmd=test env_file='.env.test' opts="--exclude-tag=integration"
api_coverage:
$(BACKEND_BASH_EXEC) "\
cd backend && \
source .env.test && \
coverage run --source='.' manage.py test && \
coverage report && \
coverage html"
api_test_debug:
@$(MAKE) -s _manage_py cmd=test env_file='.env.test' opts="--tag=debug"
api_test_integration:
@$(MAKE) -s _manage_py cmd=test env_file='.env.test' opts="--tag=integration"
# --------------------------------------------------
# Frontend
# --------------------------------------------------
front_bash:
$(FRONTEND_DOCKER_EXEC) bash
front_biome:
$(FRONTEND_BASH_EXEC) "yarn biome:check:apply-unsafe"
front_tsc:
$(FRONTEND_BASH_EXEC) "yarn tsc"
front_test:
$(FRONTEND_BASH_EXEC) "yarn test"
front_coverage:
$(FRONTEND_BASH_EXEC) "yarn test:coverage"
# --------------------------------------------------
# Others
# --------------------------------------------------
setup_hooks:
@git config core.hooksPath .githooks
help:
@echo "Usage: make [TARGET]"
@echo ""
@echo "----- BACKEND UTILS -------------------------------------------------------------------------"
@echo " api_bash Opens a bash session in the api container"
@echo " api_ruff Runs ruff to fix imports, format, and lint code"
@echo " api_shell Opens the Django shell for the running instance"
@echo ""
@echo "----- BACKEND DATABASE ----------------------------------------------------------------------"
@echo " api_migrate Generates new migrations based on models"
@echo " api_makemigrations Runs the migration"
@echo ""
@echo "----- BACKEND TEST --------------------------------------------------------------------------"
@echo " api_test Runs all non-integration tests"
@echo " api_coverage Runs tests and generates coverage report"
@echo " api_test_debug Runs tests with debug tag"
@echo " api_test_integration Runs tests with integration tag"
@echo ""
@echo "----- FRONTEND ------------------------------------------------------------------------------"
@echo " front_bash Opens a bash session in the frontend container"
@echo " front_biome Runs biome checks and fixes"
@echo " front_tsc Runs tsc"
@echo " front_test Runs tests"
@echo " front_coverage Runs tests and generates coverage report"
@echo ""
@echo "----- OTHERS --------------------------------------------------------------------------------"
@echo " setup_hooks Setups the git pre-commit hooks"
@echo " help Prints this help message"