forked from kellnr/kellnr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
358 lines (279 loc) · 10.4 KB
/
justfile
File metadata and controls
358 lines (279 loc) · 10.4 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
353
354
355
356
357
358
############################################
# Just commands for Kellnr
#
# It's recommended to use the just commands
# instead of the cargo commands, as they
# provide additional functionality.
############################################
# Use PowerShell on Windows, sh elsewhere
set windows-powershell := true
set shell := ["sh", "-c"]
# Helper to setup MSVC environment on Windows before running cargo commands
# Usage: {{setup-msvc}} cargo build
setup-msvc := if os_family() == "windows" { ". ./.github/scripts/setup-msvc-env.ps1;" } else { "" }
##########################################
# Common commands
##########################################
@_default:
{{ just_executable() }} --list
[unix]
check:
cargo check
[windows]
check:
{{ setup-msvc }} cargo check --no-default-features
[unix]
build:
cargo build
[windows]
build:
{{ setup-msvc }} cargo build --no-default-features
[unix]
build-release: npm-build
cargo build --release
[windows]
build-release: npm-build
{{ setup-msvc }} cargo build --release --no-default-features
[unix]
clippy:
cargo clippy --workspace --all-targets --all-features
[windows]
clippy:
{{ setup-msvc }} cargo clippy --workspace --all-targets --no-default-features
# Run clippy and fail on first warning (for CI)
[unix]
clippy-deny:
cargo clippy --workspace --all-targets --all-features -- --deny warnings
[windows]
clippy-deny:
{{ setup-msvc }} cargo clippy --workspace --all-targets --no-default-features -- --deny warnings
# Check formatting without modifying files (for CI)
[unix]
fmt-check:
cargo fmt --all -- --check
[windows]
fmt-check:
cargo fmt --all -- --check
[unix]
run *ARGS='start': npm-build build
cargo run -- {{ARGS}}
[windows]
run *ARGS='start': npm-build build
{{ setup-msvc }} cargo run --no-default-features -- {{ARGS}}
[unix]
test: npm-build
cargo nextest run --workspace -E 'not test(~postgres_)'
[windows]
test: npm-build
{{ setup-msvc }} cargo nextest run --workspace --no-default-features -E 'not test(~postgres_)'
[unix]
test-ui:
{{ test_ui_chromium }}
[unix]
test-ui-all-browser:
{{ test_ui_all_browsers }}
[unix]
test-ui-chromium:
{{ test_ui_chromium }}
[unix]
test-ui-firefox:
{{ test_ui_firefox }}
[unix]
test-ui-webkit:
{{ test_ui_webkit }}
[unix]
test-ui-headed:
{{ test_ui_headed }}
[windows]
test-ui:
@echo "UI tests with Docker are not supported on Windows yet"
[windows]
test-ui-all-browser:
@echo "UI tests with Docker are not supported on Windows yet"
[windows]
test-ui-chromium:
@echo "UI tests with Docker are not supported on Windows yet"
[windows]
test-ui-firefox:
@echo "UI tests with Docker are not supported on Windows yet"
[windows]
test-ui-webkit:
@echo "UI tests with Docker are not supported on Windows yet"
[windows]
test-ui-headed:
@echo "UI tests with Docker are not supported on Windows yet"
[unix]
test-pgdb: npm-build
{{ test_pgdb }}
[windows]
test-pgdb: npm-build
@echo "PostgreSQL Docker tests are not supported on Windows yet"
[unix]
test-all: test test-pgdb test-ui
[windows]
test-all: test
# Generate SBOM (Software Bill of Materials) in CycloneDX format
sbom:
cargo cyclonedx --format json --manifest-path crates/kellnr/Cargo.toml
@echo "SBOM generated: crates/kellnr/kellnr.cdx.json"
clean:
cargo clean
[unix]
clean-node:
rm -rf ui/node_modules
rm -rf ui/package-lock.json
[windows]
clean-node:
if (Test-Path ui/node_modules) { Remove-Item -Recurse -Force ui/node_modules }
if (Test-Path ui/package-lock.json) { Remove-Item -Force ui/package-lock.json }
clean-all: clean clean-node
# Reformat all code `cargo fmt`. If nightly is available, use it for better results
[unix]
fmt:
#!/usr/bin/env bash
set -euo pipefail
if (rustup toolchain list | grep nightly && rustup component list --toolchain nightly | grep rustfmt) &> /dev/null; then
echo 'Reformatting Rust code using nightly Rust fmt to sort imports'
cargo +nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate
else
echo 'Reformatting Rust with the stable cargo fmt. Install nightly with `rustup install nightly` for better results'
cargo fmt --all
fi
[windows]
fmt:
$nightlyInstalled = (rustup toolchain list) -match 'nightly'; $fmtInstalled = if ($nightlyInstalled) { (rustup component list --toolchain nightly) -match 'rustfmt' } else { $false }; if ($nightlyInstalled -and $fmtInstalled) { Write-Host 'Reformatting Rust code using nightly Rust fmt to sort imports'; cargo +nightly fmt --all -- --config imports_granularity=Module,group_imports=StdExternalCrate } else { Write-Host 'Reformatting Rust with the stable cargo fmt. Install nightly with rustup install nightly for better results'; cargo fmt --all }
[unix]
npm-dev:
cd ui && npm run dev
[windows]
npm-dev:
cd ui; npm run dev
[unix]
npm-build: npm-install
cd ui && npm run build
mkdir -p crates/embedded-resources/static
rm -rf crates/embedded-resources/static/*
cp -r ui/dist/* crates/embedded-resources/static/
[windows]
npm-build: npm-install
cd ui; npm run build
New-Item -ItemType Directory -Force -Path crates/embedded-resources/static | Out-Null
if (Test-Path crates/embedded-resources/static/*) { Remove-Item -Recurse -Force crates/embedded-resources/static/* }
Copy-Item -Recurse -Force ui/dist/* crates/embedded-resources/static/
# Install NPM dependencies without updating package-lock.json
[unix]
npm-install:
cd ui && npm ci
# Install NPM dependencies without updating package-lock.json
[windows]
npm-install:
cd ui; npm ci
# Update the npmDepsHash in flake.nix after ui/package-lock.json changes
[unix]
update-npm-hash:
#!/usr/bin/env bash
set -euo pipefail
NEW_HASH=$(nix run nixpkgs#prefetch-npm-deps -- ui/package-lock.json)
sed -i.bak "s|npmDepsHash = \".*\"|npmDepsHash = \"$NEW_HASH\"|" flake.nix && rm flake.nix.bak
echo "Updated npmDepsHash to: $NEW_HASH"
##########################################
# Commands used by the Github Actions CI
##########################################
# Set the target for the ci-release command.
# The target can be "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu",
# "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl".
# It's used by the Github Actions CI to build the release binary for the specified target.
target := "x86_64-unknown-linux-gnu"
[unix]
ci-release: clean npm-build
cross build --release --target {{ target }} --features vendored-openssl
[windows]
ci-release:
@echo "ci-release with cross is not supported on Windows"
##########################################
# Commands for cross-rs to build the
# release binary for different targets
##########################################
[unix]
x-aarch64-musl:
cross build --target aarch64-unknown-linux-musl --features vendored-openssl
[unix]
x-aarch64-gnu:
cross build --target aarch64-unknown-linux-gnu --features vendored-openssl
[unix]
x-x86_64-musl:
cross build --target x86_64-unknown-linux-musl --features vendored-openssl
[unix]
x-x86_64-gnu:
cross build --target x86_64-unknown-linux-gnu --features vendored-openssl
[unix]
x-all: x-aarch64-musl x-aarch64-gnu x-x86_64-musl x-x86_64-gnu
[windows]
x-aarch64-musl:
@echo "cross compilation is not supported on Windows"
[windows]
x-aarch64-gnu:
@echo "cross compilation is not supported on Windows"
[windows]
x-x86_64-musl:
@echo "cross compilation is not supported on Windows"
[windows]
x-x86_64-gnu:
@echo "cross compilation is not supported on Windows"
[windows]
x-all:
@echo "cross compilation is not supported on Windows"
##########################################
# Aliases
##########################################
alias b := build
alias br := build-release
alias r := run
alias t := test
alias c := check
alias tui := test-ui
alias tuic := test-ui-chromium
# "true" if docker is installed, "false" otherwise
# Docker is needed for the Postgresql integration tests
# These variables only work on Unix systems
has_docker := if os_family() == "unix" { if `command -v docker > /dev/null 2>&1; echo $?` == "0" { "true" } else { "false" } } else { "false" }
test_pgdb := if has_docker == "true" { "cargo nextest run --workspace -E 'test(~postgres_)'" } else { "echo 'ERROR: Docker is not installed. The Postgresql integration tests require Docker'" }
test_ui_all_browsers := if has_docker == "true" { "cd tests && npm ci && PLAYWRIGHT_UI=1 npx playwright test" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
test_ui_chromium := if has_docker == "true" { "cd tests && npm ci && PLAYWRIGHT_UI=1 npx playwright test --project=chromium" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
test_ui_firefox := if has_docker == "true" { "cd tests && npm ci && PLAYWRIGHT_UI=1 npx playwright test --project=firefox" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
test_ui_webkit := if has_docker == "true" { "cd tests && npm ci && PLAYWRIGHT_UI=1 npx playwright test --project=webkit" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
test_ui_headed := if has_docker == "true" { "cd tests && npm ci && PLAYWRIGHT_UI=1 npx playwright test --headed" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
test_ui_cov := if has_docker == "true" { "cd tests && npm ci && COVERAGE=1 npx playwright test --project=chromium && echo '' && echo 'Coverage data saved to tests/coverage/*.json'" } else { "echo 'ERROR: Docker is not installed. The UI tests require Docker'" }
##########################################
# Coverage commands
##########################################
# Run unit tests with coverage, generate HTML report
[unix]
test-cov: npm-build
cargo llvm-cov nextest --workspace -E 'not test(~postgres_)' --html --open
# Run PostgreSQL tests with coverage, generate HTML report
[unix]
test-pgdb-cov: npm-build
cargo llvm-cov nextest --workspace -E 'test(~postgres_)' --html --open
# Run all Rust tests with combined coverage
[unix]
test-all-cov: npm-build
cargo llvm-cov nextest --workspace --html --open
# Generate coverage summary to terminal
[unix]
test-cov-summary: npm-build
cargo llvm-cov nextest --workspace
# Clean coverage artifacts
[unix]
clean-cov:
cargo llvm-cov clean --workspace
# Run UI tests with frontend coverage
[unix]
test-ui-cov:
{{ test_ui_cov }}
[unix]
docker:
echo "{{ has_docker }}"
[windows]
docker:
@echo "Docker check not implemented for Windows"