-
-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathjustfile
More file actions
288 lines (227 loc) · 8.24 KB
/
justfile
File metadata and controls
288 lines (227 loc) · 8.24 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
# Justfile for hl project - convenient command runner
# Run `just --list` to see all available commands
previous-tag := "git tag -l \"v*.*.*\" --merged HEAD --sort=-version:refname | head -1"
# NixOS helpers
nix-files := "."
nix-docker-image := "hl-nixos-helper"
nix-docker-base := """
docker run --rm \
-it \
--platform=linux/$(uname -m) \
--security-opt seccomp=unconfined \
-v "$(pwd)":/etc/nixos \
-w /etc/nixos \
"""
nix-docker := nix-docker-base + nix-docker-image + " "
nix-result := ".build/nix"
# Recipes
# Default recipe, executed on `just` without arguments
[private]
default:
@just --list
[doc('Build the project in debug mode')]
build: (setup "build")
cargo build
[doc('Build the project in release mode')]
build-release: (setup "build")
cargo build --release
[doc('Run the application, example: `just run -- --help`')]
run *args: build
cargo run -- {{ args }}
[doc('Run tests for all packages in the workspace')]
test: (setup "build")
cargo test --workspace
[doc('Check the code for errors without building an executable')]
check: (setup "build")
cargo check --workspace --locked
[doc('Lint all code')]
lint: lint-rust lint-markdown
[doc('• Lint Rust')]
lint-rust: clippy
[doc('• Lint Markdown files')]
lint-markdown: (setup "markdown-lint")
@markdownlint-cli2 "*.md"
# Run the Rust linter (clippy)
[private]
clippy: (setup "clippy")
cargo clippy --workspace --all-targets --all-features
[doc('Automatically fix linting issues where possible')]
fix: fix-markdown fix-clippy
[private]
fix-clippy: (setup "clippy")
cargo clippy --workspace --all-targets --all-features --fix --allow-dirty --allow-staged
[private]
fix-markdown: (setup "markdown-lint")
@markdownlint-cli2 "*.md" --fix
[doc('Check for security vulnerabilities in dependencies')]
audit: (setup "audit")
cargo audit
[doc('Check for outdated dependencies')]
outdated: (setup "outdated")
cargo outdated --workspace
[doc('Format all Rust and Nix files')]
fmt: fmt-rust fmt-nix fmt-toml
@echo "✓ All files formatted successfully"
[doc('Format Rust code')]
fmt-rust: (setup "build-nightly")
cargo +nightly fmt --all
[doc('Format Nix files')]
fmt-nix: (run-nixfmt nix-files)
[doc('Format TOML files')]
fmt-toml: (setup "schema")
tombi format
[doc('Check formatting without applying changes (for CI)')]
fmt-check: fmt-check-rust fmt-check-nix
@echo "✓ Formatting is correct"
[doc('Check Rust formatting')]
fmt-check-rust: (setup "build-nightly")
@cargo +nightly fmt --all --check
[doc('Check Nix formatting')]
fmt-check-nix:
@if command -v nix > /dev/null; then \
nix fmt --check; \
fi
[doc('Clean build artifacts')]
clean:
cargo clean
@rm -f result*
[doc('Run all CI checks locally')]
ci: check test lint audit fmt-check check-schema
@echo "✅ All local CI checks passed"
[doc('Generate code coverage')]
coverage: (setup "coverage")
@bash build/ci/coverage.sh
[doc('Show uncovered changed lines comparing to {{base}}')]
uncovered base="origin/master": (setup "coverage")
@scripts/coverage-diff-analysis.py -q --ide-links {{ base }}
[doc('Run benchmarks')]
bench *args: (setup "build")
cargo bench --workspace --locked {{ args }}
[doc('Check schema validation')]
check-schema: (setup "schema")
tombi lint
taplo check
[doc('Install binary and man pages')]
install: (setup "build") build-release install-man-pages
cargo install --path . --locked
[doc('Install binary and man pages and copy with versioned name')]
install-versioned: install
@cp ~/.cargo/bin/hl ~/.cargo/bin/$(~/.cargo/bin/hl --version | tr ' ' '-')
[doc('Install man pages')]
install-man-pages:
#!/usr/bin/env bash
set -euo pipefail
mkdir -p ~/share/man/man1
cargo run --release --locked -- --config - --man-page >~/share/man/man1/hl.1.tmp
mv -f ~/share/man/man1/hl.1.tmp ~/share/man/man1/hl.1
echo $(tput setaf 3)NOTE:$(tput sgr0) ensure $(tput setaf 2)~/share/man$(tput sgr0) is added to $(tput setaf 2)MANPATH$(tput sgr0) environment variable
[doc('Build and publish new release')]
release type="patch": (setup "cargo-edit")
gh workflow run -R pamburus/hl release.yml --ref $(git branch --show-current) --field release-type={{ type }}
[doc('Show current version')]
version:
@cargo read-manifest | jq -r .version
[doc('Bump version')]
bump type="alpha": (setup "cargo-edit")
cargo set-version --package hl --bump {{ type }}
[doc('List changes since the previous release')]
changes since="auto": (setup "git-cliff" "bat" "gh")
#!/usr/bin/env bash
set -euo pipefail
since=$(if [ "{{ since }}" = auto ]; then {{ previous-tag }}; else echo "{{ since }}"; fi)
version=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "hl") | .version')
GITHUB_REPO=pamburus/hl \
GITHUB_TOKEN=$(gh auth token) \
git-cliff --tag "v${version:?}" "${since:?}..HEAD" \
| bat -l md --paging=never
[doc('Show previous release tag')]
previous-tag:
@{{ previous-tag }}
[doc('Create screenshots')]
screenshots: (setup "screenshots") build
@bash contrib/bin/screenshot.sh light cafe.log
@bash contrib/bin/screenshot.sh dark cafe.log
[doc('Nix-specific commands (require Nix to be installed)')]
nix-dev:
nix develop
[doc('Run all Nix flake checks')]
nix-check: (run-nix "flake" "check" "--all-systems" "--print-build-logs")
[doc('Update all Nix flake inputs')]
nix-update: (run-nix "flake" "update")
[doc('Build all defined Nix package variants')]
nix-build: (run-nix "build" ".#default" "--out-link" (nix-result / "default")) (run-nix "build" ".#bin" "--out-link" (nix-result / "bin"))
[doc('Show the dependency tree of the Nix derivation')]
nix-deps:
#!/usr/bin/env bash
set -euo pipefail
if command -v nix-tree > /dev/null; then
nix-tree ./result
else
echo "Error: nix-tree is not installed. Run 'nix develop' to enter a shell where it is available"
fi
[doc('Show `hl --help`')]
usage *args: build
@./target/debug/hl --config - --help {{ args }}
[doc('Show `hl --help=long`')]
usage-long *args: build
@./target/debug/hl --config - --help=long {{ args }}
[doc('Convert all Mermaid (.mmd) files to SVG')]
mmd2svg:
#!/usr/bin/env bash
set -euo pipefail
# Check if Docker is available
if ! command -v docker > /dev/null; then
echo "Error: Docker is not installed"
echo "Please install Docker from: https://www.docker.com/get-started"
exit 1
fi
# Check if Docker daemon is running
if ! docker info > /dev/null 2>&1; then
echo "Error: Docker is not running"
echo "Please start Docker Desktop or your Docker daemon"
exit 1
fi
# Find and convert all .mmd files
find . -name "*.mmd" -type f | while read -r mmd_file; do
svg_file="${mmd_file%.mmd}.svg"
# Get absolute paths
abs_mmd_file=$(pwd)/"$mmd_file"
abs_svg_file=$(pwd)/"$svg_file"
mmd_dir=$(dirname "$abs_mmd_file")
mmd_name=$(basename "$mmd_file")
svg_name=$(basename "$svg_file")
echo "Converting: $mmd_file → $svg_file"
# Run mermaid-cli in Docker
docker run --rm -u $(id -u):$(id -g) \
-v "$mmd_dir":/data \
minlag/mermaid-cli:latest \
-i "/data/$mmd_name" \
-o "/data/$svg_name" \
-b transparent
done
echo "✓ All Mermaid files converted to SVG"
# Helper function to run a command locally or in Docker if not installed
[private]
nix-run-local-or-docker docker cmd *args:
#!/usr/bin/env bash
set -euo pipefail
if command -v {{ cmd }} >/dev/null 2>&1; then
{{ cmd }} {{ args }}
else
just build-nix-docker-image
{{ docker }} {{ cmd }} {{ args }}
fi
# Helper function to run nix commands locally or in Docker
[private]
run-nix *args: (nix-run-local-or-docker nix-docker "nix" args)
# Helper function to run nixfmt commands locally or in Docker
[private]
run-nixfmt *args: (nix-run-local-or-docker nix-docker "nixfmt" args)
# Helper function to build NixOS docker image
[private]
build-nix-docker-image:
docker build -t {{ nix-docker-image }} build/docker/nix
# Helper recipe to ensure required tools are available for a given task
[private]
setup *tools:
@contrib/bin/setup.sh {{ tools }}