-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathjustfile
More file actions
405 lines (325 loc) · 12.2 KB
/
justfile
File metadata and controls
405 lines (325 loc) · 12.2 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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
# Justfile for Beancount Language Server
# Run `just --list` to see all available commands
# Default recipe - show help
default:
@just --list
# Run all tests
test:
cargo test --all-features --workspace
# Run library tests only
test-lib:
cargo test --lib --all-features
# Run all tests including ignored ones
test-all:
cargo test --all-features --workspace -- --include-ignored
# Run tests in watch mode (requires cargo-watch)
test-watch:
cargo watch -x "test --all-features --workspace"
# Run tests for a specific test name pattern
test-filter PATTERN:
cargo test --all-features --workspace {{PATTERN}}
# Run clippy lints
clippy:
cargo clippy --all-targets --all-features -- -D warnings
# Run clippy and automatically fix issues
clippy-fix:
cargo clippy --all-targets --all-features --fix --allow-dirty --allow-staged
# Check all feature combinations (requires cargo-hack)
hack-check:
cargo hack check --feature-powerset
# Build in debug mode
build:
cargo build --all-features
# Build in release mode
build-release:
cargo build --release --all-features
# Build with specific features
build-features FEATURES:
cargo build --features {{FEATURES}}
# Clean build artifacts
clean:
cargo clean
# Format code
fmt:
cargo fmt --all
# Check formatting without modifying files
fmt-check:
cargo fmt --all -- --check
# Generate code coverage report (HTML)
coverage:
cargo llvm-cov --all-features --locked --workspace --html
# Generate code coverage report (LCOV format for CI)
coverage-lcov:
cargo llvm-cov --all-features --locked --workspace --lcov --output-path lcov.info
# Generate coverage and open in browser
coverage-open:
cargo llvm-cov --all-features --locked --workspace --html --open
# Clean coverage artifacts
coverage-clean:
cargo llvm-cov clean
# Run all CI checks (format, clippy, test, build)
ci: fmt-check clippy hack-check test build-release
@echo "✅ All CI checks passed!"
# Quick check before committing
check: fmt clippy test
@echo "✅ Pre-commit checks passed!"
# Install the language server locally
install:
cargo install --path crates/lsp/ --all-features
# Install with Python embedded support
install-python:
cargo install --path crates/lsp/ --features python-embedded
# Run the language server
run:
cargo run --bin beancount-language-server
# Run the language server with debug logging
run-debug:
RUST_LOG=debug cargo run --bin beancount-language-server
# Check for security vulnerabilities
audit:
cargo audit
# Update dependencies
update:
cargo update
# Show outdated dependencies
outdated:
cargo outdated
# Generate documentation
doc:
cargo doc --all-features --no-deps
# Generate and open documentation
doc-open:
cargo doc --all-features --no-deps --open
# Benchmark tests (if any exist)
bench:
cargo bench --all-features
# Run nix flake checks
nix-check:
nix flake check
# Build with nix
nix-build:
nix build
# Enter nix development shell
nix-shell:
nix develop
# Run tree-sitter tests (if needed)
tree-sitter-test:
tree-sitter test
# Combined: format, lint, test, and build
all: fmt clippy hack-check test build
@echo "✅ All tasks completed successfully!"
# Release preparation: all checks plus coverage
release-prep: fmt-check clippy hack-check test-all build-release coverage-lcov
@echo "✅ Release preparation complete!"
@echo "📊 Coverage report generated at lcov.info"
# lazy version so it will only be executed when we need it
VSCODE_EXT_VERSION:="(jq -r '.version' vscode/package.json)"
CARGO_VERSION:="(grep -A5 '^\\[workspace.package\\]' Cargo.toml | grep '^version =' | head -n1 | sed 's/version = \"\\(.*\\)\"/\\1/')"
# ========================================
# VSCode Extension
# ========================================
# Build the VSCode extension VSIX with Nix (default)
vscode-build:
#!/usr/bin/env bash
set -euo pipefail
echo "🔨 Building VSIX with Nix..."
nix build .#beancount-vscode-vsix
echo "✅ VSIX built:"
ls -lh result/*.vsix
# Install the VSCode extension locally for testing
vscode-install: vscode-build
#!/usr/bin/env bash
set -euo pipefail
VSIX=$(ls result/*.vsix 2>/dev/null | head -n1)
if [[ -z "$VSIX" ]]; then
echo "❌ No VSIX file found. Run 'just vscode-build' first."
exit 1
fi
echo "📥 Installing $VSIX..."
code --install-extension "$VSIX" --force
echo "✅ Extension installed! Reload VSCode to use it."
# Test the VSCode extension (build, install, and show testing guide)
vscode-test: vscode-install
#!/usr/bin/env bash
set -euo pipefail
echo "🧪 Extension installed and ready for testing!"
echo ""
echo "📝 Testing checklist:"
echo " 1. Open a .beancount file"
echo " 2. Check 'Output > Beancount Language Server' for logs"
echo " 3. Test completions (Ctrl+Space)"
echo " 4. Test formatting (Shift+Alt+F)"
echo " 5. Verify diagnostics appear for errors"
echo ""
echo "🔍 To view extension logs:"
echo " - VSCode: View > Output > Select 'Beancount Language Server'"
echo ""
echo "✅ Happy testing!"
# Uninstall the VSCode extension
vscode-uninstall:
code --uninstall-extension polarmutex.beancount-langserver
# Install VSCode extension dependencies
vscode-deps:
#!/usr/bin/env bash
set -euo pipefail
cd vscode
if command -v pnpm &> /dev/null; then
pnpm install
else
echo "⚠️ pnpm not found. Running via nix develop..."
cd .. && nix develop -c bash -c 'cd vscode && pnpm install'
fi
echo "✅ VSCode dependencies installed!"
# Clean VSCode build artifacts
vscode-clean:
#!/usr/bin/env bash
rm -rf result
cd vscode 2>/dev/null && rm -rf dist/ out/ node_modules/ .cache/ || true
echo "✅ Cleaned VSCode build artifacts"
# Check VSCode extension formatting and linting (auto-installs dependencies if needed)
vscode-lint:
#!/usr/bin/env bash
set -euo pipefail
# Install dependencies if node_modules doesn't exist
if [[ ! -d "vscode/node_modules" ]]; then
echo "📦 Installing dependencies first..."
just vscode-deps
fi
cd vscode
if command -v pnpm &> /dev/null; then
pnpm run lint
else
echo "⚠️ pnpm not found. Running via nix develop..."
cd .. && nix develop -c bash -c 'cd vscode && pnpm run lint'
fi
echo "✅ VSCode extension lint check passed!"
# Auto-fix VSCode extension formatting and linting issues (auto-installs dependencies if needed)
vscode-fix:
#!/usr/bin/env bash
set -euo pipefail
# Install dependencies if node_modules doesn't exist
if [[ ! -d "vscode/node_modules" ]]; then
echo "📦 Installing dependencies first..."
just vscode-deps
fi
cd vscode
if command -v pnpm &> /dev/null; then
pnpm run fix
else
echo "⚠️ pnpm not found. Running via nix develop..."
cd .. && nix develop -c bash -c 'cd vscode && pnpm run fix'
fi
echo "✅ VSCode extension formatting and linting fixed!"
# Run all VSCode extension checks (lint + build)
vscode-check: vscode-lint vscode-build
@echo "✅ All VSCode extension checks passed!"
# Create a release tag (X.Y.Z) using version from Cargo.toml workspace
# Both Rust and VSCode releases use the same version/tag
tag-release:
#!/usr/bin/env bash
set -euo pipefail
VERSION=$(grep -A5 "^\[workspace.package\]" Cargo.toml | grep "^version =" | head -n1 | sed 's/version = "\(.*\)"/\1/')
git tag -a "$VERSION" -m "chore(release): $VERSION"
echo "✅ Created tag: $VERSION"
echo "📋 Next step: git push origin $VERSION"
# ========================================
# Release Management
# ========================================
# Update CHANGELOG using git-cliff
changelog:
git cliff --output CHANGELOG.md
# Update CHANGELOG for unreleased changes
changelog-unreleased:
git cliff --unreleased --output CHANGELOG.md
# Bump version and update changelog (requires cargo-edit)
# Usage: just release-bump [patch|minor|major]
release-bump LEVEL:
#!/usr/bin/env bash
set -euo pipefail
# Verify clean working directory
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Error: Working directory is not clean. Commit or stash changes first."
exit 1
fi
# Get current version from workspace
CURRENT_VERSION=$(grep -A5 "^\[workspace.package\]" Cargo.toml | grep "^version =" | head -n1 | sed 's/version = "\(.*\)"/\1/')
echo "📦 Current version: $CURRENT_VERSION"
# Bump version using cargo-set-version
echo "⬆️ Bumping {{LEVEL}} version..."
cargo set-version --workspace --bump {{LEVEL}}
# Update Cargo.lock with new version
echo "🔄 Updating Cargo.lock..."
cargo update --workspace
# Get new version from workspace
NEW_VERSION=$(grep -A5 "^\[workspace.package\]" Cargo.toml | grep "^version =" | head -n1 | sed 's/version = "\(.*\)"/\1/')
echo "📦 New version: $NEW_VERSION"
# Update vscode/package.json version
echo "📝 Updating vscode/package.json version to $NEW_VERSION..."
jq --arg version "$NEW_VERSION" '.version = $version' vscode/package.json > vscode/package.json.tmp
mv vscode/package.json.tmp vscode/package.json
# Update CHANGELOG (prepend new release, keep existing)
echo "📝 Updating CHANGELOG..."
git cliff --unreleased --tag "$NEW_VERSION" --prepend CHANGELOG.md
# Stage changes
git add Cargo.toml crates/*/Cargo.toml vscode/package.json CHANGELOG.md Cargo.lock
# Commit
echo "💾 Creating release commit..."
git commit -m "chore(release): prepare for v$NEW_VERSION"
echo ""
echo "✅ Release v$NEW_VERSION prepared!"
# Prepare patch release (0.0.x)
release-patch: release-prep
just release-bump patch
# Prepare minor release (0.x.0)
release-minor: release-prep
just release-bump minor
# Prepare major release (x.0.0)
release-major: release-prep
just release-bump major
# Auto-detect version bump from conventional commits and prepare release
release-auto: release-prep
#!/usr/bin/env bash
set -euo pipefail
# Verify clean working directory
if [[ -n $(git status --porcelain) ]]; then
echo "❌ Error: Working directory is not clean. Commit or stash changes first."
exit 1
fi
# Get current version from workspace
CURRENT_VERSION=$(grep -A5 "^\[workspace.package\]" Cargo.toml | grep "^version =" | head -n1 | sed 's/version = "\(.*\)"/\1/')
echo "📦 Current version: $CURRENT_VERSION"
# Auto-detect next version using git-cliff
echo "🔍 Analyzing conventional commits to determine version bump..."
BUMPED_VERSION=$(git cliff --unreleased --bumped-version 2>/dev/null | tail -1 | sed 's/^v//')
if [[ -z "$BUMPED_VERSION" ]]; then
echo "❌ Error: Could not determine version bump from commits."
echo "💡 Hint: Use conventional commits (feat:, fix:, BREAKING CHANGE:)"
echo " - feat: → minor version bump"
echo " - fix: → patch version bump"
echo " - BREAKING CHANGE: → major version bump"
exit 1
fi
echo "⬆️ Detected version bump: $CURRENT_VERSION → $BUMPED_VERSION"
# Set version directly
echo "📝 Updating version to $BUMPED_VERSION..."
cargo set-version --workspace "$BUMPED_VERSION"
# Update Cargo.lock with new version
echo "🔄 Updating Cargo.lock..."
cargo update --workspace
# Update vscode/package.json version
echo "📝 Updating vscode/package.json version to $BUMPED_VERSION..."
jq --arg version "$BUMPED_VERSION" '.version = $version' vscode/package.json > vscode/package.json.tmp
mv vscode/package.json.tmp vscode/package.json
# Update CHANGELOG (prepend new release, keep existing)
echo "📝 Updating CHANGELOG..."
git cliff --unreleased --tag "$BUMPED_VERSION" --prepend CHANGELOG.md
# Stage changes
git add Cargo.toml crates/*/Cargo.toml vscode/package.json CHANGELOG.md Cargo.lock
# Commit
echo "💾 Creating release commit..."
git commit -m "chore(release): prepare for v$BUMPED_VERSION"
echo ""
echo "✅ Release v$BUMPED_VERSION prepared!"
echo "📋 Next steps:"
echo " 1. Review the changes: git show HEAD"
echo " 2. Create and push tag: git tag v$BUMPED_VERSION && git push origin v$BUMPED_VERSION"