-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
207 lines (152 loc) · 5.56 KB
/
justfile
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
DOCKER_NETWORK := "feedback-fusion"
LOCAL_DOCKER_IMAGE := "feedback-fusion"
LOCAL_PLATFORM := "linux/" + replace(replace(arch(), "x86_64", "amd64"), "aarch64", "arm64")
DEFAULT_TEST := "postgres"
test-all:
just test postgres
just test mariadb
just test mysql
just test mssql
just test skytable
init:
pre-commit install
#
# Linting
#
check:
cargo check --all-features
clippy:
cargo clippy --all-features -- -D warnings
#
# Docker
#
build PLATFORM=LOCAL_PLATFORM DOCKERFILE="./Dockerfile":
@echo "Building for {{PLATFORM}}"
docker buildx build -t {{LOCAL_DOCKER_IMAGE}} --platform {{PLATFORM}} -f {{DOCKERFILE}} --load .
build-all DOCKERFILE="./Dockerfile":
just build linux/arm64,linux/amd64 {{DOCKERFILE}}
#
# Backend
#
backend TYPE=DEFAULT_TEST:
just build
docker run --name {{LOCAL_DOCKER_IMAGE}} -d -e FEEDBACK_FUSION_CONFIG="/etc/feedback-fusion/config.yaml" -v ./tests/_common/configs/{{TYPE}}.yaml:/etc/feedback-fusion/config.yaml -e RUST_LOG=DEBUG --network {{DOCKER_NETWORK}} -p 8000:8000 {{LOCAL_DOCKER_IMAGE}}
bench: docker oidc-server-mock postgres && cleanup
just backend postgres
GRPC_ENDPOINT=http://localhost:8000 OIDC_CLIENT_ID=client OIDC_CLIENT_SECRET=secret OIDC_PROVIDER=http://localhost:5151 cargo bench
protoc-docs:
docker run --rm -v ./docs/docs/reference:/out -v ./proto:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,api.md
#
# Testing requirements
#
@docker: cleanup
docker network create {{DOCKER_NETWORK}} > /dev/null
@oidc-server-mock:
docker compose -f tests/_common/oidc-mock/docker-compose.yaml up -d
sleep 5
curl -s -o /dev/null http://localhost:5151/.well-known/openid-configuration
@postgres:
docker run --name database -e POSTGRES_PASSWORD=password -e POSTGRES_USERNAME=postgres --network {{DOCKER_NETWORK}} -d postgres
sleep 5
@mysql:
docker run --name database -e MYSQL_ROOT_PASSWORD=password -e MYSQL_PASSWORD=password -e MYSQL_USER=username -e MYSQL_DATABASE=database --network {{DOCKER_NETWORK}} -d mysql
sleep 30
@mariadb:
docker run --name database -e MYSQL_ROOT_PASSWORD=password -e MYSQL_PASSWORD=password -e MYSQL_USER=username -e MYSQL_DATABASE=database --network {{DOCKER_NETWORK}} -d mariadb
sleep 10
@mssql:
docker run --name database -e ACCEPT_EULA=Y -e MSSQL_SA_PASSWORD=Password1 --network {{DOCKER_NETWORK}} -d mcr.microsoft.com/mssql/server:2022-latest
sleep 10
@skytable: postgres
docker run -p 2003:2003 --entrypoint skyd --rm --name skytable --network {{DOCKER_NETWORK}} -d skytable/skytable --auth-root-password=passwordpassword --endpoint=tcp@0.0.0.0:2003
#
# Testing
#
@cleanup:
-docker rm -f database > /dev/null 2>&1
-docker rm -f oidc-server-mock > /dev/null 2>&1
-docker rm -f feedback-fusion > /dev/null 2>&1
-docker rm -f skytable > /dev/null 2>&1
-docker network rm {{DOCKER_NETWORK}} > /dev/null 2>&1
unittest:
cargo test --bin feedback-fusion
integration:
OIDC_PROVIDER="http://localhost:5151" OIDC_CLIENT_ID="client" OIDC_CLIENT_SECRET="secret" RUST_LOG="INFO" GRPC_ENDPOINT="http://localhost:8000" cargo test --no-fail-fast --test integration_test || (docker logs feedback-fusion; exit 1)
test TYPE=DEFAULT_TEST: docker oidc-server-mock
just {{TYPE}}
if [ "{{TYPE}}" = "mariadb" ]; then just backend mysql; else just backend {{TYPE}}; fi
sleep 1
just integration
-docker rm -f database > /dev/null 2>&1
-docker rm -f feedback-fusion > /dev/null 2>&1
fuzz:
OIDC_PROVIDER="http://localhost:5151" OIDC_CLIENT_ID="client" OIDC_CLIENT_SECRET="secret" RUST_LOG="INFO" GRPC_ENDPOINT="http://localhost:8000" cargo fuzz run fuzz_create_and_export
#
# Lib & Docs
#
pnpm PACKAGE:
pnpm i -C {{PACKAGE}}
generate PACKAGE:
pnpm run -C {{PACKAGE}} protoc
lint PACKAGE:
pnpm run -C {{PACKAGE}} lint
lib-dev:
just pnpm docs
just pnpm lib
just generate lib
pnpm run -C lib dev
lib:
just pnpm lib
just generate lib
pnpm run -C lib build
translations:
pnpm run -C lib translations:extract
pnpm run -C lib translations:build
docs:
just lib
just pnpm docs
pnpm run -C docs docs:build
#
# Dashboard
#
dashboard: lib
just pnpm dashboard
just generate dashboard
pnpm run -C dashboard build
dashboard-dev: docker oidc-server-mock postgres && cleanup
just backend postgres
NUXT_PUBLIC_FEEDBACK_FUSION_ENDPOINT="http://localhost:8000" \
FEEDBACK_FUSION_OIDC_PROVIDER_AUTHORIZATION_URL="http://localhost:5151/connect/authorize" \
FEEDBACK_FUSION_OIDC_PROVIDER_TOKEN_URL="http://localhost:5151/connect/token" \
FEEDBACK_FUSION_OIDC_CLIENT_ID="client" \
FEEDBACK_FUSION_OIDC_CLIENT_SECRET="secret" \
FEEDBACK_FUSION_OIDC_REDIRECT_URL="http://localhost:3000/auth/oidc/callback" \
FEEDBACK_FUSION_OIDC_PROVIDER_DISCOVERY_URL="http://localhost:5151/.well-known/openid-configuration" \
pnpm run -C dashboard dev
#
# Helm
#
helm:
cd charts/feedback-fusion && helm-docs
cp charts/feedback-fusion/README.md docs/docs/deployment/helm.md
#
# Releases
#
prepare-release:
git checkout main
git pull
post-prepare-release TAG:
git checkout -b release/{{TAG}}
git add -A
-git commit -m "chore: release {{TAG}}"
git push origin -u HEAD
release-server LEVEL:
just prepare-release
cargo release --no-publish --no-push --no-tag --execute {{LEVEL}}
just post-prepare-release server-$(cargo pkgid | sed -n 's/.*#//p')
release-dashboard LEVEL:
just prepare-release
just post-prepare-release dashboard-$(pnpm version -C dashboard --no-git-tag-version {{LEVEL}} | sed 's/^v//')
release-lib LEVEL:
just prepare-release
just post-prepare-release dashboard-$(pnpm version -C lib --no-git-tag-version {{LEVEL}}| sed 's/^v//')