-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathjustfile
More file actions
249 lines (198 loc) · 6.43 KB
/
Copy pathjustfile
File metadata and controls
249 lines (198 loc) · 6.43 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
# hstry justfile (Rust workspace)
# Default recipe - show help
default:
@just --list
# === Development ===
# Install all binaries
install:
cargo install --path .
# Install all binaries from workspace
install-all:
@for crate in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.targets[] | .kind[] == "bin") | .manifest_path | split("/") | .[-2]'); do \
echo "Installing $crate..."; \
cargo install --path crates/$crate; \
done
@if command -v hstry >/dev/null 2>&1; then \
echo "Updating adapters..."; \
hstry adapters update; \
fi
# Install a specific crate
install-crate CRATE:
cargo install --path crates/{{CRATE}}
# Uninstall all binaries
uninstall:
@for crate in $(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.targets[] | .kind[] == "bin") | .name'); do \
echo "Uninstalling $crate..."; \
cargo uninstall $crate 2>/dev/null || true; \
done
# === Building ===
# Debug build (all crates)
build:
cargo build --workspace
# Release build (all crates)
build-release:
cargo build --workspace --release
# Build a specific crate
build-crate CRATE:
cargo build -p {{CRATE}}
# Build with all features
build-all:
cargo build --workspace --all-features
# Fast compile check
check:
cargo check --workspace
# Check a specific crate
check-crate CRATE:
cargo check -p {{CRATE}}
# Clean build artifacts
clean:
cargo clean
# === Testing ===
# Run all tests
test:
cargo test --workspace
# Run tests for a specific crate
test-crate CRATE:
cargo test -p {{CRATE}}
# Run tests with all features
test-all:
cargo test --workspace --all-features
# Run tests verbosely
test-v:
cargo test --workspace -- --nocapture
# Run a specific test
test-one TEST:
cargo test --workspace {{TEST}}
# === Code Quality ===
# Format all code
fmt:
cargo fmt --all
# Check formatting
fmt-check:
cargo fmt --all -- --check
# Run clippy on all crates
clippy:
cargo clippy --workspace
# Alias for clippy
lint: clippy lint-rust-ai-guardrails
# Install ast-grep (advanced structural linting)
install-ast-grep:
cargo install ast-grep --locked
# Rust AI guardrails via ast-grep
lint-rust-ai-guardrails:
./scripts/lint/rust-ai-guardrails.sh
# Clippy on a specific crate
clippy-crate CRATE:
cargo clippy -p {{CRATE}}
# Auto-fix clippy warnings
fix:
cargo clippy --workspace --fix --allow-dirty
# Run all checks
check-all: fmt-check clippy lint-rust-ai-guardrails test
# === Documentation ===
# Generate docs for all crates
docs:
cargo doc --workspace --no-deps
# Generate and open docs
docs-open:
cargo doc --workspace --no-deps --open
# Docs for a specific crate
docs-crate CRATE:
cargo doc -p {{CRATE}} --no-deps --open
# === Dependencies ===
# Update all dependencies
update:
cargo update
# Check for outdated dependencies
outdated:
cargo outdated --workspace
# === Workspace Info ===
# List all crates in workspace
list:
@cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | "\(.name) (\(.version))"'
# List binary crates
list-bins:
@cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.targets[] | .kind[] == "bin") | .name'
# List library crates
list-libs:
@cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.targets[] | .kind[] == "lib") | .name'
# === Release ===
# Release build and show binary sizes
release: build-release
@echo "Binary sizes:"
@find target/release -maxdepth 1 -type f -perm +111 ! -name "*.d" -exec ls -lh {} \; 2>/dev/null || true
# Bump the workspace version locally (level = patch | minor | major)
bump level="patch":
#!/usr/bin/env bash
set -euo pipefail
LEVEL="{{level}}"
CURRENT=$(grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "([^"]+)"/\1/')
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "$LEVEL" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
*) echo "Error: level must be patch, minor, or major"; exit 1 ;;
esac
NEW="$MAJOR.$MINOR.$PATCH"
sed -i "s/^version = .*/version = \"$NEW\"/" Cargo.toml
cargo update --workspace --offline >/dev/null 2>&1 || true
echo "Bumped version: $CURRENT -> $NEW"
echo "Review, then 'just release-bump $NEW' to commit, tag, and push."
# Release: bump version, commit, tag, and push
release-bump version:
#!/usr/bin/env bash
set -euo pipefail
VERSION="{{version}}"
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in format X.Y.Z"
exit 1
fi
echo "Bumping version to $VERSION"
# Update workspace version
sed -i "s/^version = .*/version = \"$VERSION\"/" Cargo.toml
git add Cargo.toml
git commit -m "chore: bump version to $VERSION"
git tag "v$VERSION"
git push origin main
git push origin "v$VERSION"
echo "Release v$VERSION pushed! Workflow will start automatically."
# Check release readiness
release-check:
#!/usr/bin/env bash
set -euo pipefail
echo "Checking release readiness..."
cargo test --workspace --quiet
cargo clippy --workspace --quiet -- -D warnings
cargo fmt --all -- --check
echo "All checks passed!"
# Tag and push a release
release-tag VERSION:
git tag v{{VERSION}}
git push --tags
# Set up GitHub secrets for automated releases (requires byt)
setup-secrets:
byt secrets setup hstry
# Update CHANGELOG for release
changelog version:
#!/usr/bin/env bash
set -euo pipefail
VERSION="{{version}}"
DATE=$(date +%Y-%m-%d)
echo "## [$VERSION] - $DATE" > /tmp/changelog_new.md
echo "" >> /tmp/changelog_new.md
echo "### Added" >> /tmp/changelog_new.md
echo "" >> /tmp/changelog_new.md
echo "### Changed" >> /tmp/changelog_new.md
echo "" >> /tmp/changelog_new.md
echo "### Fixed" >> /tmp/changelog_new.md
cat CHANGELOG.md >> /tmp/changelog_new.md
mv /tmp/changelog_new.md CHANGELOG.md
echo "CHANGELOG.md updated for $VERSION"
# === Adapters ===
# Copy latest adapters to config directory (overwrites existing)
update-adapters:
@mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/hstry/adapters"
@rm -rf "${XDG_CONFIG_HOME:-$HOME/.config}/hstry/adapters/"*
@cp -r adapters/* "${XDG_CONFIG_HOME:-$HOME/.config}/hstry/adapters/"
@echo "Adapters updated in ${XDG_CONFIG_HOME:-$HOME/.config}/hstry/adapters"