-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
185 lines (148 loc) · 5.67 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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
ENVIRONMENT ?= development
TAG ?= latest
ANSIBLE_AI_PROJECT_NAME ?= Ansible AI Connect
# Choose between docker and podman based on what is available
ifeq (, $(shell which podman))
CONTAINER_RUNTIME ?= docker
else
CONTAINER_RUNTIME ?= podman
endif
# Choose between docker-compose and podman-compose based on what is available
ifeq (, $(shell which podman-compose))
COMPOSE_RUNTIME ?= docker-compose
else
COMPOSE_RUNTIME ?= podman-compose
endif
ifeq ($(ENVIRONMENT),development)
export ANSIBLE_AI_DATABASE_HOST := localhost
export ANSIBLE_AI_DATABASE_NAME := wisdom
export ANSIBLE_AI_DATABASE_PASSWORD := wisdom
export ANSIBLE_AI_DATABASE_USER := wisdom
export ARI_KB_PATH := ../ari/kb/
export DJANGO_SETTINGS_MODULE := ansible_ai_connect.main.settings.development
export ENABLE_ARI_POSTPROCESS := False
export PYTHONUNBUFFERED := 1
export SECRET_KEY := somesecret
export DJANGO_SUPERUSER_PASSWORD := somesecret
export SOCIAL_AUTH_OIDC_OIDC_ENDPOINT := https://sso.redhat.com/auth/realms/redhat-external
export SOCIAL_AUTH_OIDC_KEY := ansible-wisdom-staging
ifeq ($(wildcard $(PWD)/.env/.),)
ifneq ($(wildcard $(PWD)/.env),)
include $(PWD)/.env
endif
endif
endif
DEPRECATED:
@echo
@echo [WARN] This target has been deprecated. See Makefile for more information.
@echo
# DEPRECATED: Please use build-wisdom-container instead
ansible-wisdom-container: build-wisdom-container DEPRECATED
.PHONY: build-wisdom-container
build-wisdom-container:
${CONTAINER_RUNTIME} build -f wisdom-service.Containerfile -t ansible_wisdom .
# DEPRECATED: Please use run-server instead
run-django: run-server DEPRECATED
.PHONY: run-server
# Run Django application
run-server:
wisdom-manage runserver
# DEPRECATED: Please use run-server-containerized instead
run-django-container: run-server-containerized DEPRECATED
.PHONY: run-server-containerized
# Run Django application in container
run-server-containerized:
${CONTAINER_RUNTIME} run -it --rm -p 8000:8000 --name ansible-wisdom localhost/ansible_wisdom
.PHONY: docker-compose
docker-compose:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose.yaml up --remove-orphans
.PHONY: start-db
# Run db in container for running Django application from source
start-db:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose-db.yaml up --remove-orphans -d
.PHONY: stop-db
# stop db container
stop-db:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose-db.yaml up down
.PHONY: start-backends
# Run backend services in container for running Django application from source
start-backends:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose-db.yaml -f tools/docker-compose/compose-prom-grafana.yaml up --remove-orphans -d
.PHONY: stop-backends
# Stop backend services
stop-backends:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose-db.yaml -f tools/docker-compose/compose-prom-grafana.yaml down
.PHONY: update-openapi-schema
# Update OpenAPI 3.0 schema while running the service in development env
update-openapi-schema:
curl -X GET http://localhost:8000/api/schema/ -o tools/openapi-schema/ansible-ai-connect-service.yaml
.PHONY: docker-compose-clean
docker-compose-clean:
${COMPOSE_RUNTIME} -f tools/docker-compose/compose.yaml down
.PHONY: pip-compile
pip-compile:
${COMPOSE_RUNTIME} -f tools/docker-compose/pip-compile.yaml up --remove-orphans
# DEPRECATED: Please use create-superuser-containerized instead
docker-create-superuser: create-superuser-containerized DEPRECATED
.PHONY: create-superuser-containerized
create-superuser-containerized:
${CONTAINER_RUNTIME} exec -it docker-compose_django_1 wisdom-manage createsuperuser
.PHONY: migrate
migrate:
wisdom-manage migrate
.PHONY: makemigrations
makemigrations:
wisdom-manage makemigrations
.PHONY: create-cachetable
create-cachetable: migrate
wisdom-manage createcachetable
.PHONY: create-superuser
create-superuser: create-cachetable
wisdom-manage createsuperuser --noinput --username admin --email admin@example.com
.PHONY: create-testuser
create-testuser: create-superuser
wisdom-manage createtoken --username testuser --password testuser --token-name testuser_token --create-user
.PHONY: create-application
create-application: create-testuser
wisdom-manage createapplication --name "${ANSIBLE_AI_PROJECT_NAME} for VS Code" --client-id Vu2gClkeR5qUJTUGHoFAePmBznd6RZjDdy5FW2wy --redirect-uris "vscode://redhat.ansible" public authorization-code
.PHONY: test
test:
export MOCK_WCA_SECRETS_MANAGER=False && \
wisdom-manage test $$WISDOM_TEST
.PHONY: code-coverage
# Run unit tests, calculate code coverage and display results in chrome
code-coverage:
coverage erase && \
coverage run --rcfile=setup.cfg -m ansible_ai_connect.manage test ansible_ai_connect && \
coverage html && \
google-chrome htmlcov/index.html
# ============================
# Admin Portal related commands
# ============================
# Compile and bundle Admin Portal into Django application
.PHONY: admin-portal-bundle
admin-portal-bundle:
npm --prefix ./ansible_ai_connect_admin_portal run build
# Run tests for Admin Portal
.PHONY: admin-portal-test
admin-portal-test:
npm --prefix ./ansible_ai_connect_admin_portal run test
# Run lint checks for Admin Portal
.PHONY: admin-portal-lint
admin-portal-lint:
npm --prefix ./ansible_ai_connect_admin_portal run lint
# ============================
# Chatbot UI related commands
# ============================
# Compile and bundle Chatbot UI into Django application
.PHONY: chatbot-bundle
chatbot-bundle:
npm --prefix ./ansible_ai_connect_chatbot run build
# Run tests for Chatbot UI with code coverage
.PHONY: chatbot-test
chatbot-test:
npm --prefix ./ansible_ai_connect_chatbot run coverage
# Run lint checks for Admin Portal
.PHONY: chatbot-lint
chatbot-lint:
npm --prefix ./ansible_ai_connect_chatbot run eslint