-
Notifications
You must be signed in to change notification settings - Fork 16
/
makefile
147 lines (116 loc) · 4.33 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
IMAGE_NAME ?= context-aware-config
DOCKER_DNS ?= localhost
TENANT ?= dev
SHELL := /usr/bin/env bash
FEATURES ?= ssr
.PHONY:
db-init
setup
kill
run
ci-test
validate-aws-connection
validate-psql-connection
cac
db-init:
diesel migration run --locked-schema --config-file=crates/context_aware_config/diesel.toml
-diesel migration run --locked-schema --config-file=crates/experimentation_platform/diesel.toml
cleanup:
-docker rm -f $$(docker container ls --filter name=^context-aware-config -a -q)
-docker rmi -f $$(docker images | grep context-aware-config-postgres | cut -f 10 -d " ")
cac-migration: cleanup
docker-compose up -d postgres
cp .env.example .env
while ! make validate-psql-connection; \
do echo "waiting for postgres bootup"; \
sleep 0.5; \
done
diesel migration run --locked-schema --config-file=crates/context_aware_config/diesel.toml
docker-compose down
exp-migration: cleanup
docker-compose up -d postgres
cp .env.example .env
while ! make validate-psql-connection; \
do echo "waiting for postgres bootup"; \
sleep 0.5; \
done
--diesel migration run --locked-schema --config-file=crates/experimentation_platform/diesel.toml
docker-compose down
migration: cac-migration exp-migration
legacy_db_setup:
grep 'DATABASE_URL=' .env | sed -e 's/DATABASE_URL=//' | xargs ./scripts/legacy-db-setup.sh
tenant:
grep 'DATABASE_URL=' .env | sed -e 's/DATABASE_URL=//' | xargs ./scripts/create-tenant.sh -t $(TENANT) -d
validate-aws-connection:
aws --no-cli-pager --endpoint-url=http://$(DOCKER_DNS):4566 --region=ap-south-1 sts get-caller-identity
validate-psql-connection:
pg_isready -h $(DOCKER_DNS) -p 5432
env-setup:
npm ci
-docker-compose up -d postgres localstack
cp .env.example .env
while ! make validate-psql-connection validate-aws-connection; \
do echo "waiting for postgres, localstack bootup"; \
sleep 0.5; \
done
test-tenant:
make tenant TENANT='test'
dev-tenant:
make tenant TENANT='dev'
ci-setup: env-setup test-tenant
npm ci --loglevel=error
make run -e DOCKER_DNS=$(DOCKER_DNS) 2>&1 | tee test_logs &
while ! grep -q "starting in Actix" test_logs; \
do echo "ci-test: waiting for bootup..." && sleep 4; \
done
# NOTE: `make db-init` finally starts a postgres container and runs all the migrations with locked-schema option
# to prevent update of schema.rs for both cac and experimentation.
# NOTE: The container spinned-up here is the actual container being used in development
echo setup completed successfully!!!
setup: env-setup
kill:
-pkill -f target/debug/superposition &
get-password:
export DB_PASSWORD=`./docker-compose/localstack/get_db_password.sh` && echo $$DB_PASSWORD
superposition:
cargo run --color always --bin superposition --no-default-features --features=$(FEATURES)
superposition-example:
cargo run --bin cac-demo-app
superposition_legacy:
cargo run --color always --bin superposition --no-default-features --features='ssr superposition_types/disable_db_data_validation context_aware_config/disable_db_data_validation experimentation_platform/disable_db_data_validation'
superposition_dev:
# export DB_PASSWORD=`./docker-compose/localstack/get_db_password.sh`
cargo watch -x 'run --color always --bin superposition --no-default-features --features=$(FEATURES)'
frontend:
cd crates/frontend && \
wasm-pack build --target web --dev --no-default-features --features hydrate
cd crates/frontend && \
npx tailwindcss -i ./styles/tailwind.css -o ./pkg/style.css
-rm -rf target/site
mkdir target/site && mkdir target/site/pkg
mv crates/frontend/pkg target/site/
cp -a crates/frontend/assets/. target/site/
backend:
-rm -rf target/node_modules
npm --prefix ./crates/context_aware_config/ ci
mv crates/context_aware_config/node_modules target/
cargo build --color always
build: frontend backend
run: kill frontend
while ! make validate-psql-connection validate-aws-connection; \
do echo "waiting for postgres, localstack bootup"; \
sleep 0.5; \
done
make superposition -e DOCKER_DNS=$(DOCKER_DNS)
run_legacy: kill build
while ! make validate-psql-connection validate-aws-connection; \
do echo "waiting for postgres, localstack bootup"; \
sleep 0.5; \
done
make superposition_legacy -e DOCKER_DNS=$(DOCKER_DNS)
ci-test: ci-setup
cargo test
npm run test
tailwind:
cd crates/frontend && npx tailwindcss -i ./styles/tailwind.css -o ./pkg/style.css --watch
default: dev-build