-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (76 loc) · 2.33 KB
/
Makefile
File metadata and controls
99 lines (76 loc) · 2.33 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
TEMPLATE_FILES_IN = $(filter-out ./.build/% ./apache/% ./venv/% ./MANIFEST.in, $(shell find . -type f -name '*.in'))
TEMPLATE_FILES = $(TEMPLATE_FILES_IN:.in=)
ENV_FILES = config/env.default config/env.dev
ifdef CONFIG
ENV_FILES += $(CONFIG)
endif
ifneq ($(wildcard config/env.local),)
ENV_FILES += config/env.local
endif
SRC_DIRS = c2corg_api es_migration
DOCKER_COMPOSE = docker compose
DOCKER_EXEC = $(DOCKER_COMPOSE) exec
DB_EXEC = $(DOCKER_EXEC) -u postgres -T postgresql
help:
@echo "Usage: make <target>"
@echo
@echo "Main targets:"
@echo
@echo "- bootstrap" Bootstraps the project for the first time
@echo "- run-syncer Run the ElasticSearch syncer script."
@echo "- run-background-jobs" Run the background jobs
@echo
@echo "- test Run the unit tests"
@echo "- lint Run flake8 checker on the Python code"
@echo
@echo "Secondary targets:"
@echo
@echo "- start" Start the docker containers
@echo "- stop" Stop the docker containers
@echo "- serve" Start the Python webserver
@echo
@echo "- init-database" Initialize the dev database
@echo "- init-test-database" Initialize the test database
@echo "- init-elastic" Initialize the elasticsearch index
@echo "- flush-redis Clear the Redis cache"
@echo
@echo "- install Install the project dependencies"
@echo "- loadenv Replace the env vars in the .in templates"
bootstrap:
$(MAKE) start
$(MAKE) install
$(MAKE) load-env
$(MAKE) init-database
$(MAKE) init-test-database
$(MAKE) init-elastic
start:
$(DOCKER_COMPOSE) up -d
stop:
$(DOCKER_COMPOSE) stop
serve:
pserve development.ini --reload
lint:
flake8 $(SRC_DIRS)
@echo "Wonderful, python style is Ok!"
test:
pytest
init-database:
$(DB_EXEC) /v6_api/scripts/database/create_schema.sh
initialize_c2corg_api_db development.ini
init-test-database:
$(DB_EXEC) /v6_api/scripts/database/create_test_schema.sh
init-elastic:
fill_es_index development.ini
install:
pip install -e ".[dev]"
run-syncer:
python c2corg_api/scripts/es/syncer.py development.ini
run-background-jobs:
python c2corg_api/scripts/jobs/scheduler.py development.ini
flush-redis:
python c2corg_api/scripts/redis-flushdb.py development.ini
load-env: $(TEMPLATE_FILES)
development.ini: common.ini
.PHONY: $(TEMPLATE_FILES)
$(TEMPLATE_FILES): %: %.in
scripts/env_replace ${ENV_FILES} < $< > $@