-
Notifications
You must be signed in to change notification settings - Fork 562
Expand file tree
/
Copy pathMakefile
More file actions
163 lines (129 loc) · 5.22 KB
/
Copy pathMakefile
File metadata and controls
163 lines (129 loc) · 5.22 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.EXPORT_ALL_VARIABLES:
DOCKER_TAG ?= flagsmith/flagsmith-api:local
COMPOSE_FILE ?= ../docker/api/docker-compose.local.yml
COMPOSE_PROJECT_NAME ?= flagsmith
DOTENV_OVERRIDE_FILE ?= .env
POETRY_VERSION ?= 2.2.1
SAML_REVISION ?= v1.6.5
RBAC_REVISION ?= v0.11.6
-include .env-local
-include $(DOTENV_OVERRIDE_FILE)
.PHONY: install-pip
install-pip:
python -m pip -q install --upgrade pip
.PHONY: install-poetry
install-poetry:
python -m pip -q install poetry==${POETRY_VERSION}
.PHONY: install-packages
install-packages:
poetry install --no-root $(opts)
.PHONY: install-private-modules
install-private-modules:
$(eval SITE_PACKAGES_DIR := $(shell poetry run python -c 'import site; print(site.getsitepackages()[0])'))
git clone https://github.com/flagsmith/flagsmith-saml --depth 1 --branch ${SAML_REVISION} && mv ./flagsmith-saml/saml $(SITE_PACKAGES_DIR)
git clone https://github.com/flagsmith/flagsmith-rbac --depth 1 --branch ${RBAC_REVISION} && mv ./flagsmith-rbac/rbac $(SITE_PACKAGES_DIR)
rm -rf ./flagsmith-saml ./flagsmith-rbac
.PHONY: install
install: install-pip install-poetry install-packages
.PHONY: lint
lint:
poetry run pre-commit run -a
.PHONY: typecheck
typecheck:
poetry run mypy .
.PHONY: docker-up
docker-up:
docker compose up --force-recreate --remove-orphans -d
docker compose ps
.PHONY: docker-down
docker-down:
docker compose stop
.PHONY: docker-logs
docker-logs:
docker compose logs --follow
.PHONY: docker-build
docker-build:
@docker build \
--tag=$(DOCKER_TAG) \
--file=../Dockerfile \
--target=oss-api \
../
.PHONY: test
test:
poetry run pytest $(opts)
.PHONY: django-make-migrations
django-make-migrations:
poetry run python manage.py waitfordb
poetry run python manage.py makemigrations $(opts)
.PHONY: django-squash-migrations
django-squash-migrations:
poetry run python manage.py waitfordb
poetry run python manage.py squashmigrations $(opts)
.PHONY: django-migrate
django-migrate:
poetry run python manage.py waitfordb
poetry run python manage.py migrate
poetry run python manage.py createcachetable
.PHONY: django-shell
django-shell:
poetry run python manage.py shell
.PHONY: django-collect-static
django-collect-static:
poetry run python manage.py collectstatic --noinput
.PHONY: serve
serve: docker-up
poetry run flagsmith start --reload api
.PHONY: run-task-processor
run-task-processor: docker-up
poetry run flagsmith start --reload --bind 0.0.0.0:8001 task-processor
.PHONY: serve-with-task-processor
serve-with-task-processor: TASK_RUN_METHOD=TASK_PROCESSOR
serve-with-task-processor:
make -j2 serve run-task-processor
.PHONY: generate-ld-client-types
generate-ld-client-types:
curl -sSL https://app.launchdarkly.com/api/v2/openapi.json | \
npx openapi-format /dev/fd/0 \
--filterFile openapi-filter-launchdarkly.yaml | \
datamodel-codegen \
--output integrations/launch_darkly/types.py \
--output-model-type typing.TypedDict \
--target-python-version 3.10 \
--use-double-quotes \
--use-standard-collections \
--wrap-string-literal \
--special-field-name-prefix=
.PHONY: generate-grafana-client-types
generate-grafana-client-types:
curl -sSL https://raw.githubusercontent.com/grafana/grafana/refs/heads/main/public/openapi3.json | \
npx openapi-format /dev/fd/0 \
--filterFile openapi-filter-grafana.yaml | \
datamodel-codegen \
--output integrations/grafana/types.py \
--output-model-type typing.TypedDict \
--target-python-version 3.10 \
--use-double-quotes \
--use-standard-collections \
--wrap-string-literal \
--special-field-name-prefix=
.PHONY: integrate-private-tests
integrate-private-tests:
$(eval WORKFLOW_REVISION := $(shell grep -A 1 "\[tool.poetry.group.workflows.dependencies\]" pyproject.toml | awk -F '"' '{printf $$4}'))
$(eval TASK_PROCESSOR_REVISION := $(shell grep -A 0 "flagsmith-task-processor" pyproject.toml | awk -F '"' '{printf $$4}'))
$(eval AUTH_CONTROLLER_REVISION := $(shell grep -A 1 "\[tool.poetry.group.auth-controller.dependencies\]" pyproject.toml | awk -F '"' '{printf $$4}'))
git clone https://github.com/flagsmith/flagsmith-saml --depth 1 --branch ${SAML_REVISION} && mv ./flagsmith-saml/tests tests/saml_tests
git clone https://github.com/flagsmith/flagsmith-rbac --depth 1 --branch ${RBAC_REVISION} && mv ./flagsmith-rbac/tests tests/rbac_tests
git clone https://github.com/flagsmith/flagsmith-workflows --depth 1 --branch ${WORKFLOW_REVISION} && mv ./flagsmith-workflows/tests tests/workflow_tests
git clone https://github.com/flagsmith/flagsmith-auth-controller --depth 1 --branch ${AUTH_CONTROLLER_REVISION} && mv ./flagsmith-auth-controller/tests tests/auth_controller_tests
git clone https://github.com/flagsmith/flagsmith-task-processor --depth 1 --branch ${TASK_PROCESSOR_REVISION} && mv ./flagsmith-task-processor/tests tests/task_processor_tests
rm -rf ./flagsmith-saml ./flagsmith-rbac ./flagsmith-workflows ./flagsmith-auth-controller ./flagsmith-task-processor
.PHONY: generate-docs
generate-docs:
poetry run flagsmith docgen metrics > ../docs/docs/administration-and-security/platform-configuration/metrics.md
.PHONY: add-known-sdk-version
add-known-sdk-version:
poetry run python scripts/add-known-sdk-version.py $(opts)
.PHONY: reset
reset: docker-up
poetry run python manage.py waitfordb
poetry run python manage.py reset_local_database