forked from arayabrain/barebone-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
149 lines (121 loc) · 4.45 KB
/
Makefile
File metadata and controls
149 lines (121 loc) · 4.45 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
#
# optinist Makefile
#
############################## For Testing ##############################
define rm_unused_docker_containers
docker ps -a --filter "status=exited" --filter "name=$(1)" --format "{{.ID}}" | xargs --no-run-if-empty docker rm
endef
define cleanup_test_env
docker compose -f docker-compose.test.yml down
docker compose -f docker-compose.test.yml rm -f
@$(call rm_unused_docker_containers, $(1))
endef
define run_test_service
docker compose -f docker-compose.test.yml build $(1)
docker compose -f docker-compose.test.yml run $(1) $(2)
endef
PYTEST = poetry run pytest -s
.PHONY: test_run_all
test_run_all:
# cleanup
@$(call cleanup_test_env, test_studio_backend)
@$(call cleanup_test_env, test_studio_frontend)
# build containers once (performance optimization)
docker compose -f docker-compose.test.yml build test_studio_backend
docker compose -f docker-compose.test.yml build test_studio_frontend
# backend tests (studio/tests/app/ only)
docker compose -f docker-compose.test.yml run test_studio_backend $(PYTEST) studio/tests/app/ -m "not heavier_processing"
# frontend tests
docker compose -f docker-compose.test.yml run test_studio_frontend
# lambda tests (reuse backend container)
docker compose -f docker-compose.test.yml run test_studio_backend $(PYTEST) studio/tests/infrastructure/ -v
.PHONY: test_backend
test_backend:
# cleanup
@$(call cleanup_test_env, test_studio_backend)
# build/run
@$(call run_test_service, test_studio_backend, $(PYTEST) studio/tests/app/ -m "not heavier_processing")
.PHONY: test_backend_full
test_backend_full:
# cleanup
@$(call cleanup_test_env, test_studio_backend)
# build/run
@$(call run_test_service, test_studio_backend, $(PYTEST) studio/tests/app/)
.PHONY: test_frontend
test_frontend:
# cleanup
@$(call cleanup_test_env, test_studio_frontend)
# build/run
@$(call run_test_service, test_studio_frontend)
.PHONY: test_lambda
test_lambda:
# cleanup
@$(call cleanup_test_env, test_studio_backend)
# build/run
@$(call run_test_service, test_studio_backend, $(PYTEST) studio/tests/infrastructure/ -v)
.PHONY: test_contract
test_contract:
# API contract tests - validates backend responses match frontend TypeScript interfaces
# NOTE: These tests are a subset of test_backend. Use this target for running contract tests only.
# cleanup
@$(call cleanup_test_env, test_studio_backend)
# build/run
@$(call run_test_service, test_studio_backend, $(PYTEST) studio/tests/app/common/routers/test_*_contract.py -v)
############################## For Building ##############################
VERSION := $(shell poetry version -s)
.PHONY: version
version:
echo "Current Optinist Version: $(VERSION)"
.PHONY: build_frontend
build_frontend:
# cleanup
docker compose -f docker-compose.build.yml down
docker compose -f docker-compose.build.yml rm -f
@$(call rm_unused_docker_containers, studio-build-fe)
# build/run
docker compose -f docker-compose.build.yml build studio-build-fe
docker compose -f docker-compose.build.yml run studio-build-fe
.PHONY: format
format:
black studio *.py
isort studio *.py
flake8 studio *.py
codespell --skip="./dist,./frontend/node_modules,./logs"
.PHONY: docs
docs:
rm -rf docs/_build/
poetry install --with doc --no-root
# sphinx-apidoc -f -o ./docs/_build/modules ./studio
sphinx-autobuild -b html docs docs/_build --port 8001
.PHONY: local_build
local_build:
rm -rf dist
cd frontend && yarn install --ignore-scripts && yarn build
poetry build
############################## For Deployment ##############################
.PHONY: push_testpypi
push_testpypi:
poetry publish -r testpypi
.PHONY: install_testpypi
install_testpypi:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ optinist==${ver}
pip show optinist
.PHONY: build_test_docker
build_test_docker:
docker build --no-cache -t optinist-release-test:${ver} -f studio/config/docker/Dockerfile .
.PHONY: run_test_docker
run_test_docker:
docker run -it \
-v ${volume}:/app/studio_data \
--env OPTINIST_DIR="/app/studio_data" \
--name optinist-release-test -d -p 8000:8000 optinist-release-test:${ver} \
poetry run python main.py --host 0.0.0.0 --port 8000
.PHONY: push_pypi
push_pypi:
poetry publish
.PHONY: push_dockerhub
push_dockerhub:
docker build --rm -t oistncu/optinist:latest -f studio/config/docker/Dockerfile . --platform=linux/amd64
docker tag oistncu/optinist:latest oistncu/optinist:${VERSION}
docker push oistncu/optinist:${VERSION}
docker push oistncu/optinist:latest