-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
220 lines (181 loc) · 9.87 KB
/
Copy pathTaskfile.yml
File metadata and controls
220 lines (181 loc) · 9.87 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
version: "3"
vars:
SRC_DIR: '{{default "app" .SRC_DIR}}'
SERVICE: '{{default "backend-api" (default (env "SERVICE") .SERVICE)}}'
tasks:
install:
cmds:
- poetry install
reformat:
desc: >-
Reformat the codebase.
cmds:
- poetry run black {{.SRC_DIR}}
lint:
cmds:
- poetry run mypy {{.SRC_DIR}}
- PYTHONPYCACHEPREFIX=/tmp/backend-api-pyc poetry run python -m compileall {{.SRC_DIR}}
- poetry run black --workers 1 --check --diff {{.SRC_DIR}}
- poetry run pydocstyle {{.SRC_DIR}}
verify:
cmds:
- task text-tools:lint
- task text-tools:test
- task rust-sbc-gateway:lint
- task rust-sbc-gateway:test
- bash -lc 'poetry run mypy {{.SRC_DIR}} && PYTHONPYCACHEPREFIX=/tmp/backend-api-pyc poetry run python -m compileall {{.SRC_DIR}} && poetry run black --workers 1 --check --diff {{.SRC_DIR}} && poetry run pydocstyle {{.SRC_DIR}} && poetry run python -m pytest && PYTHONPYCACHEPREFIX=/tmp/backend-api-pyc poetry run python -m compileall app alembic'
test:
cmds:
- poetry run python -m pytest
dev:
cmds:
- poetry run uvicorn app.main:create_app --factory --reload --host 0.0.0.0 --port 8000
build:
cmds:
- PYTHONPYCACHEPREFIX=/tmp/backend-api-pyc poetry run python -m compileall app alembic
service:lint:
desc: >-
Run lint/checks for SERVICE=backend-api, text-tools, rust-sbc-gateway, or all.
cmds:
- 'SERVICE="{{.SERVICE}}" bash -lc ''case "${SERVICE}" in backend-api) task lint ;; text-tools) task text-tools:lint ;; rust-sbc-gateway) task rust-sbc-gateway:lint ;; all) task text-tools:lint && task rust-sbc-gateway:lint && task lint ;; *) echo "Unknown SERVICE: ${SERVICE}. Use backend-api, text-tools, rust-sbc-gateway, or all." && exit 1 ;; esac'''
service:test:
desc: >-
Run tests for SERVICE=backend-api, text-tools, rust-sbc-gateway, or all.
cmds:
- 'SERVICE="{{.SERVICE}}" bash -lc ''case "${SERVICE}" in backend-api) task test ;; text-tools) task text-tools:test ;; rust-sbc-gateway) task rust-sbc-gateway:test ;; all) task text-tools:test && task rust-sbc-gateway:test && task test ;; *) echo "Unknown SERVICE: ${SERVICE}. Use backend-api, text-tools, rust-sbc-gateway, or all." && exit 1 ;; esac'''
service:build:
desc: >-
Build/check SERVICE=backend-api, text-tools, rust-sbc-gateway, or all.
cmds:
- 'SERVICE="{{.SERVICE}}" bash -lc ''case "${SERVICE}" in backend-api) task build ;; text-tools) task text-tools:build ;; rust-sbc-gateway) task rust-sbc-gateway:build ;; all) task text-tools:build && task rust-sbc-gateway:build && task build ;; *) echo "Unknown SERVICE: ${SERVICE}. Use backend-api, text-tools, rust-sbc-gateway, or all." && exit 1 ;; esac'''
text-tools:run:
desc: >-
Run the local Rust text tools sidecar.
dir: text-tools
cmds:
- TEXT_TOOLS_HOST="${TEXT_TOOLS_HOST:-127.0.0.1}" TEXT_TOOLS_PORT="${TEXT_TOOLS_PORT:-8081}" RUST_LOG="${RUST_LOG:-info}" cargo run
text-tools:fmt:
desc: >-
Format the Rust text tools sidecar.
dir: text-tools
cmds:
- cargo fmt
text-tools:lint:
desc: >-
Check formatting, clippy, and tests for the Rust text tools sidecar.
dir: text-tools
cmds:
- cargo fmt --check
- cargo clippy --all-targets -- -D warnings
text-tools:test:
desc: >-
Run the Rust text tools sidecar tests.
dir: text-tools
cmds:
- cargo test
text-tools:build:
desc: >-
Build the Rust text tools sidecar.
dir: text-tools
cmds:
- cargo build
rust-sbc-gateway:run:
desc: >-
Run the Rust SBC gateway service.
dir: rust-sbc-gateway
cmds:
- SBC_CONTROL_BIND="${SBC_CONTROL_BIND:-127.0.0.1:8082}" SBC_WS_BIND="${SBC_WS_BIND:-127.0.0.1:8083}" SBC_SIP_BIND="${SBC_SIP_BIND:-0.0.0.0:5060}" SBC_RTP_START_PORT="${SBC_RTP_START_PORT:-10000}" SBC_RTP_END_PORT="${SBC_RTP_END_PORT:-10100}" RUST_LOG="${RUST_LOG:-info}" cargo run
rust-sbc-gateway:fmt:
desc: >-
Format the Rust SBC gateway service.
dir: rust-sbc-gateway
cmds:
- cargo fmt
rust-sbc-gateway:lint:
desc: >-
Check formatting and clippy for the Rust SBC gateway service.
dir: rust-sbc-gateway
cmds:
- cargo fmt --check
- cargo clippy --all-targets -- -D warnings
rust-sbc-gateway:test:
desc: >-
Run tests for the Rust SBC gateway service.
dir: rust-sbc-gateway
cmds:
- cargo test
rust-sbc-gateway:build:
desc: >-
Build the Rust SBC gateway service.
dir: rust-sbc-gateway
cmds:
- cargo build
local-up:
cmds:
- bash ./local/scripts/up.sh
local-down:
cmds:
- bash ./local/scripts/down.sh
local-logs:
cmds:
- bash ./local/scripts/logs.sh
democtl:build:
desc: >-
Build the local Rust demo operator CLI.
dir: local/democtl
cmds:
- cargo build
democtl:test:
desc: >-
Run the local Rust demo operator CLI tests.
dir: local/democtl
cmds:
- cargo test
democtl:run:
desc: >-
Run the local Rust demo operator CLI.
dir: local/democtl
cmds:
- cargo run -- {{.CLI_ARGS}}
migrate:
cmds:
- poetry run python -m alembic upgrade head
makemigration:
cmds:
- test -n "${MESSAGE:-}" || (echo "Set MESSAGE=..." && exit 1)
- poetry run python -m alembic revision --autogenerate -m "${MESSAGE}"
docker-build:
cmds:
- SERVICE="{{.SERVICE}}" IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-backend-api}" TEXT_TOOLS_IMAGE_REPOSITORY="${TEXT_TOOLS_IMAGE_REPOSITORY:-demo-text-tools}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" IMAGE_TAG="${IMAGE_TAG:-}" bash ./deploy/scripts/build-image.sh
save-image:
cmds:
- SERVICE="{{.SERVICE}}" IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-backend-api}" TEXT_TOOLS_IMAGE_REPOSITORY="${TEXT_TOOLS_IMAGE_REPOSITORY:-demo-text-tools}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" IMAGE_TAG="${IMAGE_TAG:-}" bash ./deploy/scripts/save-image.sh
apply-runtime-secret:
cmds:
- 'test -n "{{.CLI_ARGS}}" || (echo "Usage: task apply-runtime-secret -- SECRET_KEY SECRET_VALUE [SECRET_KEY SECRET_VALUE ...]" && exit 1)'
- 'SECRET_NAME="${SECRET_NAME:-backend-api-secrets}" NAMESPACE="${NAMESPACE:-demo}" bash ./deploy/scripts/apply-runtime-secret.sh {{.CLI_ARGS}}'
copy-bundle:
cmds:
- SERVICE="{{.SERVICE}}" IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-backend-api}" TEXT_TOOLS_IMAGE_REPOSITORY="${TEXT_TOOLS_IMAGE_REPOSITORY:-demo-text-tools}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" IMAGE_TAG="${IMAGE_TAG:-}" DEPLOY_TARGET="${DEPLOY_TARGET:-ubuntu@openclaw}" DEPLOY_PATH="${DEPLOY_PATH:-/home/ubuntu/backend-api-deploy}" SSH_OPTS="${SSH_OPTS:-}" bash ./deploy/scripts/copy-deploy-bundle.sh
deploy:
cmds:
- SERVICE="{{.SERVICE}}" RELEASE_NAME="${RELEASE_NAME:-backend-api}" TEXT_TOOLS_RELEASE_NAME="${TEXT_TOOLS_RELEASE_NAME:-demo-text-tools}" RUST_SBC_RELEASE_NAME="${RUST_SBC_RELEASE_NAME:-demo-rust-sbc-gateway}" NAMESPACE="${NAMESPACE:-demo}" VALUES_FILE="${VALUES_FILE:-deploy/helm/backend-api/values-demo.yaml}" TEXT_TOOLS_VALUES_FILE="${TEXT_TOOLS_VALUES_FILE:-deploy/helm/text-tools/values-demo.yaml}" RUST_SBC_VALUES_FILE="${RUST_SBC_VALUES_FILE:-deploy/helm/rust-sbc-gateway/values-demo.yaml}" IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-backend-api}" TEXT_TOOLS_IMAGE_REPOSITORY="${TEXT_TOOLS_IMAGE_REPOSITORY:-demo-text-tools}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" IMAGE_TAG="${IMAGE_TAG:-}" bash ./deploy/scripts/deploy.sh
rust-sbc-gateway:deploy:
desc: >-
Deploy only the Rust SBC gateway service.
cmds:
- SERVICE="rust-sbc-gateway" RUST_SBC_RELEASE_NAME="${RUST_SBC_RELEASE_NAME:-demo-rust-sbc-gateway}" NAMESPACE="${NAMESPACE:-demo}" RUST_SBC_VALUES_FILE="${RUST_SBC_VALUES_FILE:-deploy/helm/rust-sbc-gateway/values-demo.yaml}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" IMAGE_TAG="${IMAGE_TAG:-}" bash ./deploy/scripts/deploy.sh
ship-deploy:
cmds:
- SERVICE="{{.SERVICE}}" RELEASE_NAME="${RELEASE_NAME:-backend-api}" TEXT_TOOLS_RELEASE_NAME="${TEXT_TOOLS_RELEASE_NAME:-demo-text-tools}" RUST_SBC_RELEASE_NAME="${RUST_SBC_RELEASE_NAME:-demo-rust-sbc-gateway}" NAMESPACE="${NAMESPACE:-demo}" VALUES_FILE="${VALUES_FILE:-deploy/helm/backend-api/values-demo.yaml}" TEXT_TOOLS_VALUES_FILE="${TEXT_TOOLS_VALUES_FILE:-deploy/helm/text-tools/values-demo.yaml}" RUST_SBC_VALUES_FILE="${RUST_SBC_VALUES_FILE:-deploy/helm/rust-sbc-gateway/values-demo.yaml}" IMAGE_REPOSITORY="${IMAGE_REPOSITORY:-backend-api}" TEXT_TOOLS_IMAGE_REPOSITORY="${TEXT_TOOLS_IMAGE_REPOSITORY:-demo-text-tools}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" DEPLOY_TARGET="${DEPLOY_TARGET:-ubuntu@openclaw}" DEPLOY_PATH="${DEPLOY_PATH:-/home/ubuntu/backend-api-deploy}" SSH_OPTS="${SSH_OPTS:-}" KEEP_REMOTE_RELEASES="${KEEP_REMOTE_RELEASES:-3}" bash ./deploy/scripts/ship-deploy.sh
rust-sbc-gateway:ship-deploy:
desc: >-
Build, ship, and deploy only the Rust SBC gateway service.
cmds:
- SERVICE="rust-sbc-gateway" RUST_SBC_RELEASE_NAME="${RUST_SBC_RELEASE_NAME:-demo-rust-sbc-gateway}" NAMESPACE="${NAMESPACE:-demo}" RUST_SBC_VALUES_FILE="${RUST_SBC_VALUES_FILE:-deploy/helm/rust-sbc-gateway/values-demo.yaml}" RUST_SBC_IMAGE_REPOSITORY="${RUST_SBC_IMAGE_REPOSITORY:-demo-rust-sbc-gateway}" DEPLOY_TARGET="${DEPLOY_TARGET:-ubuntu@openclaw}" DEPLOY_PATH="${DEPLOY_PATH:-/home/ubuntu/backend-api-deploy}" SSH_OPTS="${SSH_OPTS:-}" KEEP_REMOTE_RELEASES="${KEEP_REMOTE_RELEASES:-3}" bash ./deploy/scripts/ship-deploy.sh
rollback:
cmds:
- RELEASE_NAME="${RELEASE_NAME:-backend-api}" NAMESPACE="${NAMESPACE:-demo}" REVISION="${REVISION:-}" bash ./deploy/scripts/rollback.sh
history:
cmds:
- helm history "${RELEASE_NAME:-backend-api}" --namespace "${NAMESPACE:-demo}"