-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
352 lines (265 loc) · 8.42 KB
/
justfile
File metadata and controls
352 lines (265 loc) · 8.42 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# Install Just: https://github.com/casey/just
##########
## Rust ##
##########
# Build Debug Binary
build:
cargo build
# Build Release Binary
build-release:
cargo build --release
# Build and Run a Develop Binay
run:
RUST_BACKTRACE=full cargo run
# Build and Run a Release Binary
run-release:
RUST_BACKTRACE=full cargo run --release
# Check Rust Code
check:
cargo check --workspace --locked
# Check Rust Code using the SQLx Cache
check_w_sqlx_cache:
SQLX_OFFLINE=true cargo check --locked
# Check Rust Linting
clippy:
cargo clippy --workspace --locked --all-targets -- --deny warnings
# Check Rust Linting using SQLx Cache
clippy_w_sqlx_cache:
SQLX_OFFLINE=true cargo clippy --workspace --locked -- --deny warnings
# Apply Rust Formating
fmt:
cargo fmt --verbose
# Check Rust Formating
fmt-check:
cargo fmt --check --verbose
# Check Rust Unittest
test:
cargo test --workspace --locked
# Install SQLx-CLI
sqlx-install:
cargo install sqlx-cli --locked
# SQLx DB Migration
sqlx-migrate:
sqlx migrate run
# SQLx DB Revert
sqlx-revert:
sqlx migrate revert
# SQLx DB Reset
sqlx-reset:
sqlx database reset
# Refresh SQLx Cache
sqlx-prepare:
cargo sqlx prepare
# Check SQLx Cache
sqlx-check:
cargo sqlx prepare --check
# Install Cargo Deny
deny-install:
cargo install cargo-deny --locked
# Check Rust advisories, bans, licenses, sources
deny:
cargo deny check
################
## Key Hasher ##
################
# Hash a given key (or any value really) with optional cost factor
hash key cost="12":
RUST_BACKTRACE=full cargo run --package key_hasher -- --key {{ key }} --cost {{ cost }}
##############
## Markdown ##
##############
# Lint all Markdown files
markdownlint:
npx markdownlint-cli2 --config .markdownlint-cli2.jsonc
# Fix lints for Markdown files
markdownlint-fix:
npx markdownlint-cli2 --fix --config .markdownlint-cli2.jsonc
################
## PostgreSQL ##
################
# Create the network that we allow others to connect to PostgreSQL
pg-init-network client="docker":
{{ client }} network create pg_network
# Create the network that we allow others to connect to PostgreSQL
pg-init-network-podman: (pg-init-network "podman")
# Start a local PostgreSQL instance for development.
pg-start client="docker":
{{ client }} run \
-t \
--detach \
--rm \
--name fletcher_postgresql \
--network=pg_network \
--env POSTGRES_USER=fletcher_user \
--env POSTGRES_PASSWORD=password \
--env POSTGRES_DB=fletcher_db \
--volume fletcher_postgresql:/var/lib/postgresql/data \
--publish 5432:5432 \
docker.io/library/postgres:alpine
# Start local PostgreSQL via Podman
pg-start-podman: (pg-start "podman")
# Stop local PostgreSQL
pg-stop client="docker":
{{ client }} stop fletcher_postgresql
# Stop local PostgreSQL via Podman
pg-stop-podman: (pg-stop "podman")
# Connect to PostgreSQL via Rainfrog (https://github.com/achristmascarl/rainfrog)
pg-cli:
rainfrog \
--username=fletcher_user \
--password=password \
--host=localhost \
--port=5432 \
--database=fletcher_db \
--driver=postgres
############
## Python ##
############
# Pyright check
py-right-check:
uv --directory locust/ run pyright
# Pyright file watcher
py-right-check-watch:
uv --directory locust/ run pyright --watch
# Ruff Linting check
py-ruff-check:
uv --directory locust/ run ruff check
# Ruff Linting fix
py-ruff-fix:
uv --directory locust/ run ruff check --fix
# Ruff Linting file watcher
py-ruff-check-watch:
uv --directory locust/ run ruff check --watch
# Ruff Formatting
py-ruff-fmt:
uv --directory locust/ run ruff format
# Ruff Formatting check
py-ruff-fmt-check:
uv --directory locust/ run ruff format --check
# Scan for vulnerable dependencies
py-audit:
uv --directory locust/ run pip-audit
#################
## Stress Test ##
#################
# Build and Run a Release Binary with settings for stress testing
run-stress max_connections="30":
MAX_CONNECTIONS={{ max_connections }} cargo run --release
# Run Locust Server
locust:
uv --directory locust/ run locust \
--locustfile src/locustfile.py \
--host "http://127.0.0.1:3000"
# Run Locust Server for stress testing
locust-demo:
uv --directory locust/ run locust \
--locustfile src/locustfile.py \
--host "http://127.0.0.1:3000" \
--users 1 \
--spawn-rate 1 \
--mode loop \
--tags api \
--autostart
# Run Locust Server for busiest day testing
locust-busiest-day:
uv --directory locust/ run locust \
--locustfile src/locustfile.py \
--host "http://127.0.0.1:3000" \
--users 300 \
--spawn-rate 2 \
--mode once \
--autostart
# Run Locust Server for stress testing
locust-stress:
uv --directory locust/ run locust \
--locustfile src/locustfile.py \
--host "http://127.0.0.1:3000" \
--users 2500 \
--spawn-rate 2 \
--mode loop \
--autostart
#####################
## Docker / Podman ##
#####################
# Build the Docker image in release mode
docker-build client="docker" mode="release":
{{ client }} build \
. \
--file Containerfile \
--tag localhost/fletcher:{{ mode }} \
--build-arg BUILD_MODE={{ mode }}
# Build the Docker image in debug mode
docker-build-debug: (docker-build "docker" "debug")
# Build the Docker image via Podman in release mode
podman-build: (docker-build "podman" "release")
# Build the Docker image via Podman in debug mode
podman-build-debug: (docker-build "podman" "debug")
# Run the Docker container in Detached mode
docker-run client="docker" mode="release":
{{ client }} run \
--name=fletcher \
--detach \
--rm \
--network=pg_network \
--publish=3000:3000 \
--env BASE_URL='0.0.0.0:3000' \
--env DATABASE_URL='postgres://fletcher_user:password@fletcher_postgresql/fletcher_db' \
--env SECRET_KEY='GRNr3wdyenBu9BJW3TNQLene6b2xij1avk4UmPnrBkFbOKM5883EZUncLgeSdwLs63Wg21tbBV2WqanwTAXtqloXHkmLLiecDsxH' \
--env REMOTE_APIS='[{"service": "remote", "hash": "$2b$10$4i5iCctUtWc5szV6M8CJNur1ng2md/gT372tlOv6BemwLryOw5ZGu", "roles": ["publish", "pause", "update", "disable"]}]' \
localhost/fletcher:{{ mode }}
# Run the Docker debug container in Detached mode
docker-run-debug: (docker-run "docker" "debug")
# Run the Docker container in Detached mode via Podman in release mode
podman-run: (docker-run "podman" "release")
# Run the Docker container in Detached mode via Podman in debug mode
podman-run-debug: (docker-run "podman" "debug")
# Dump logs from container
docker-logs client="docker":
{{ client }} logs fletcher
# Dump logs from container via Podman
podman-logs: (docker-logs "podman")
# Follow logs from container
docker-follow client="docker":
{{ client }} logs --follow fletcher
# Follow logs from container via Podman
podman-follow: (docker-follow "podman")
# Kill the Detached Docker container
docker-kill client="docker":
{{ client }} kill fletcher
# Kill the Detached Docker container via Podman
podman-kill: (docker-kill "podman")
# Test the Healthcheck and that the service came up (Docker only)
docker-healthcheck:
sh ./scripts/healthcheck.sh
###########
## Trivy ##
###########
# Trivy Scan the code repo
trivy-repo:
trivy repo .
# Trivy Scan the Docker image
trivy-image mode="release":
trivy image localhost/fletcher:{{ mode }}
# Trivy Scan the debug Docker image
trivy-image-debug: (trivy-image "debug")
############
## Github ##
############
# Run all Github Rust Checks
github-rust-checks: sqlx-check check_w_sqlx_cache clippy_w_sqlx_cache fmt-check test deny
# Run all Github Markdown Checks
github-markdown-checks: markdownlint
# Run all Github Python Checks
github-py-checks: py-right-check py-ruff-check py-ruff-fmt-check py-audit
# Run all Github Docker Checks
github-docker-checks mode="debug": (docker-build "docker" mode) (docker-run "docker" mode) docker-healthcheck (docker-kill "docker")
# Run all Github Docker Checks via Podman (excluding Healthcheck)
github-podman-checks: (docker-build "podman" "debug")
# Run all Github Trivy Checks
github-trivy-checks client="docker": trivy-repo (docker-build client "debug") (trivy-image "debug")
# Run all Github Trivy Checks (via Podman)
github-trivy-checks-podman: (github-trivy-checks "podman")
# Run all Github Checks
github-checks: github-rust-checks github-markdown-checks github-py-checks github-docker-checks (github-trivy-checks "docker")
# Run all Github Checks (with Podman)
github-checks-podman: github-rust-checks github-markdown-checks github-py-checks github-podman-checks (github-trivy-checks "podman")