-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (116 loc) · 5.49 KB
/
Copy pathMakefile
File metadata and controls
123 lines (116 loc) · 5.49 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
112
113
114
115
116
117
118
119
120
121
122
123
# Check if 'uv' is being called with arguments
ifeq (uv,$(firstword $(MAKECMDGOALS)))
UV_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
UV_CMD := $(firstword $(UV_ARGS))
UV_EXTRA_ARGS := $(wordlist 2,$(words $(UV_ARGS)),$(UV_ARGS))
$(eval $(UV_ARGS):;@:)
endif
uv:
ifeq ($(UV_CMD),translate)
cd jdav_web && uv run python manage.py makemessages --locale de --no-location --no-obsolete
else
@echo "Usage: make uv [translate]"
@echo " make uv translate - Generate translation files using uv"
endif
# Check if 'dev' is being called with arguments
ifeq (dev,$(firstword $(MAKECMDGOALS)))
DEV_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
DEV_CMD := $(firstword $(DEV_ARGS))
DEV_EXTRA_ARGS := $(wordlist 2,$(words $(DEV_ARGS)),$(DEV_ARGS))
# Create empty targets for extra arguments only (not for DEV_CMD to avoid conflicts)
$(eval $(DEV_EXTRA_ARGS):;@:)
endif
dev:
ifeq ($(DEV_CMD),build)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose build $(BUILD_ARGS)
else ifeq ($(DEV_CMD),up)
ifeq ($(detach), true)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose up -d
else
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose up
endif
else ifeq ($(DEV_CMD),down)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose down
else ifeq ($(DEV_CMD),shell)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd jdav_web && bash"
else ifeq ($(DEV_CMD),translate)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd jdav_web && python3 manage.py makemessages --locale de --no-location --no-obsolete && python3 manage.py compilemessages"
else ifeq ($(DEV_CMD),createsuperuser)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd jdav_web && python3 manage.py createsuperuser"
else ifeq ($(DEV_CMD),docs)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd docs && make html"
@echo ""
@echo "Generated documentation. To read it, point your browser to:"
@echo ""
@echo "file://$$(pwd)/docs/build/html/index.html"
else ifeq ($(DEV_CMD),test)
ifneq ($(keepdb),false)
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd jdav_web && coverage run manage.py test --keepdb $(DEV_EXTRA_ARGS); coverage html"
else
cd docker/development; USER_ID=$$(id -u) GROUP_ID=$$(id -g) USERNAME=$$(id -un) docker compose exec master bash -c "cd jdav_web && coverage run manage.py test $(DEV_EXTRA_ARGS); coverage html"
endif
@echo ""
@echo "Generated coverage report. To read it, point your browser to:"
@echo ""
@echo "file://$$(pwd)/jdav_web/htmlcov/index.html"
else
@echo "Usage: make dev [build|up|down|shell|manage|translate|createsuperuser|docs|test]"
@echo " make dev build - Build development containers"
@echo " make dev build BUILD_ARGS=--no-cache - Build with docker compose args"
@echo " make dev up - Start development environment"
@echo " make dev up detach=true - Start in background"
@echo " make dev down - Stop development environment"
@echo " make dev shell - Open shell in running container"
@echo " make dev translate - Generate and compile translation files"
@echo " make dev createsuperuser - Create a superuser account"
@echo " make dev docs - Build Sphinx documentation"
@echo " make dev test [<test-args>] - Run tests with coverage (keepdb=true by default)"
@echo " make dev test keepdb=false [<test-args>] - Run tests without keeping database"
endif
build-test:
ifeq ($(quiet), true)
@cd docker/test; docker compose build > /dev/null 2>&1
else
cd docker/test; docker compose build
endif
test-only:
ifeq ($(quiet), true)
@mkdir -p docker/test/htmlcov
@chmod 777 docker/test/htmlcov
ifeq ($(keepdb), true)
@cd docker/test; DJANGO_TEST_KEEPDB=1 DJANGO_TEST_VERBOSITY=$(or $(verbosity),2) docker compose up -d > /dev/null 2>&1 \
|| { echo "Container setup failed."; exit 1; }
else
@cd docker/test; DJANGO_TEST_VERBOSITY=$(or $(verbosity),2) docker compose up -d > /dev/null 2>&1 \
|| { echo "Container setup failed."; exit 1; }
endif
@cd docker/test; docker compose wait master > /dev/null 2>&1 || true; \
python3 parse_output.py htmlcov; _EXIT=$$?; \
docker compose down > /dev/null 2>&1; \
exit $$_EXIT
else
mkdir -p docker/test/htmlcov
chmod 777 docker/test/htmlcov
# Show output from all containers
ifeq ($(keepdb), true)
cd docker/test; DJANGO_TEST_KEEPDB=1 DJANGO_TEST_VERBOSITY=$(or $(verbosity),2) docker compose up --exit-code-from master
else
cd docker/test; DJANGO_TEST_VERBOSITY=$(or $(verbosity),2) docker compose up --exit-code-from master
endif
echo "Generated coverage report. To read it, point your browser to:\n\nfile://$$(pwd)/docker/test/htmlcov/index.html"
endif
# Only execute the test target if it's not being called via 'make dev test'
ifneq (dev,$(firstword $(MAKECMDGOALS)))
test: build-test test-only
else
test:
@:
endif
# Only execute the docs target if it's not being called via 'make dev docs'
ifneq (dev,$(firstword $(MAKECMDGOALS)))
# No standalone docs target
else
.PHONY: docs
docs:
@:
endif