-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
137 lines (107 loc) · 3.94 KB
/
justfile
File metadata and controls
137 lines (107 loc) · 3.94 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
# Display available commands and their descriptions (default target)
default:
@just --list
## Workspace management
alias clean := cargo-clean
# Clean cargo build artifacts (cargo clean)
[group: 'workspace']
cargo-clean:
cargo clean
## Code formatting and linting
alias fmt := fmt-rs
alias fmt-check := fmt-rs-check
# Format Rust code (cargo fmt)
[group: 'format']
fmt-rs:
cargo +nightly fmt --all
# Check Rust code format (cargo fmt --check)
[group: 'format']
fmt-rs-check:
cargo +nightly fmt --all -- --check
# Format specific Rust file (cargo fmt <file>)
[group: 'format']
fmt-rs-file FILE:
cargo +nightly fmt -- {{FILE}}
## Check
alias check := check-rs
# Check Rust code (cargo check --all-targets)
[group: 'check']
check-rs *EXTRA_FLAGS:
cargo check --all-targets {{EXTRA_FLAGS}}
# Lint Rust code (cargo clippy --all-targets)
[group: 'check']
clippy *EXTRA_FLAGS:
cargo clippy --all-targets {{EXTRA_FLAGS}}
## Build
alias build := build-ampup
# Build ampup binary (cargo build --release)
[group: 'build']
build-ampup *EXTRA_FLAGS:
cargo build --release -p ampup {{EXTRA_FLAGS}}
## Testing
# Run tests
[group: 'test']
test *EXTRA_FLAGS:
#!/usr/bin/env bash
set -e # Exit on error
if command -v "cargo-nextest" &> /dev/null; then
cargo nextest run {{EXTRA_FLAGS}}
else
>&2 echo "================================================================="
>&2 echo "WARNING: cargo-nextest not found - using 'cargo test' fallback"
>&2 echo ""
>&2 echo "For faster test execution, consider installing cargo-nextest:"
>&2 echo " cargo install --locked cargo-nextest@^0.9"
>&2 echo "================================================================="
sleep 1 # Give the user a moment to read the warning
cargo test {{EXTRA_FLAGS}}
fi
## Misc
PRECOMMIT_CONFIG := ".github/pre-commit-config.yaml"
PRECOMMIT_DEFAULT_HOOKS := "pre-commit pre-push"
# Install Git hooks
[group: 'misc']
install-git-hooks HOOKS=PRECOMMIT_DEFAULT_HOOKS:
#!/usr/bin/env bash
set -e # Exit on error
# Check if prek is installed
if ! command -v "prek" &> /dev/null; then
>&2 echo "=============================================================="
>&2 echo "Required command 'prek' not available"
>&2 echo ""
>&2 echo "Please install prek using your preferred package manager:"
>&2 echo " brew install prek"
>&2 echo " cargo install --locked prek"
>&2 echo " uv tool install prek"
>&2 echo " pip install prek"
>&2 echo " npm install -g @j178/prek"
>&2 echo ""
>&2 echo "See: https://github.com/j178/prek"
>&2 echo "=============================================================="
exit 1
fi
# Install all Git hooks (see PRECOMMIT_HOOKS for default hooks)
prek install --config {{PRECOMMIT_CONFIG}} {{replace_regex(HOOKS, "\\s*([a-z-]+)\\s*", "--hook-type $1 ")}}
# Remove Git hooks
[group: 'misc']
remove-git-hooks HOOKS=PRECOMMIT_DEFAULT_HOOKS:
#!/usr/bin/env bash
set -e # Exit on error
# Check if prek is installed
if ! command -v "prek" &> /dev/null; then
>&2 echo "=============================================================="
>&2 echo "Required command 'prek' not available"
>&2 echo ""
>&2 echo "Please install prek using your preferred package manager:"
>&2 echo " brew install prek"
>&2 echo " cargo install --locked prek"
>&2 echo " uv tool install prek"
>&2 echo " pip install prek"
>&2 echo " npm install -g @j178/prek"
>&2 echo ""
>&2 echo "See: https://github.com/j178/prek"
>&2 echo "=============================================================="
exit 1
fi
# Remove all Git hooks (see PRECOMMIT_HOOKS for default hooks)
prek uninstall --config {{PRECOMMIT_CONFIG}} {{replace_regex(HOOKS, "\\s*([a-z-]+)\\s*", "--hook-type $1 ")}}