Repository navigation
Expand file tree
/
Copy pathjustfile
More file actions
230 lines (195 loc) · 8.19 KB
/
Copy pathjustfile
File metadata and controls
230 lines (195 loc) · 8.19 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
# Build the project in debug mode
build-debug:
@echo "Building project in debug mode..."
@cargo build
@echo "Debug build complete."
# Build the project in release mode
build-release:
@echo "Building project in release mode..."
@cargo build --release
@echo "Release build complete."
# Install required cargo tools
install-tools:
@echo "Installing required cargo and Rust tools..."
@cargo install tokei
@cargo install cargo-edit
@cargo install cargo-llvm-cov
@rustup component add clippy
@echo "Cargo and Rust tools installed."
# Install pre-commit hooks using 'prek'
install-pre-commit-hooks:
@echo "Installing pre-commit hooks using prek..."
@prek install
@echo "Pre-commit hooks installed."
# Update pre-commit hooks using 'prek'
pre-commit-update:
@echo "Updating pre-commit hooks using prek..."
@prek auto-update
@echo "Pre-commit hooks updated."
# Upgrade project dependencies using 'cargo'
upgrade-dependencies:
@echo "Upgrading project dependencies..."
@cargo update --verbose
@echo "Dependencies upgraded."
# Bump the patch version of the project using 'cargo'
bump-patch:
@echo "Current project version: $(cargo pkgid | cut -d# -f2)"
@cargo set-version --bump patch
@echo "Updated project to: $(cargo pkgid | cut -d# -f2)"
# Format the code
format:
@echo "Formatting code..."
@cargo fmt
@echo "Code formatted."
# Run the type checker and linter
type-check-and-lint:
@echo "Running type checker and linter..."
@cargo check
@cargo clippy -- -D warnings
@echo "Type checking and linting complete."
# Fix with clippy
type-check-and-lint-fix:
@echo "Running clippy with automatic fixes..."
@cargo clippy --fix --allow-dirty --allow-staged
@echo "Clippy fixes applied."
# Generate crate documentation
generate-docs-and-show-in-browser:
@echo "Cleaning old documentation..."
@rm -rf target/doc
@echo "Generating crate documentation..."
@cargo doc --no-deps --open
@echo "Documentation generated and opened in browser."
export RUN_INTEGRATION_TESTS := "1"
# Run comprehensive tests, including downloading models
test-comprehensive $RUN_INTEGRATION_TESTS="1":
@echo "Running all tests, including downloading models, with --test-threads=1 to avoid shared-state conflicts in integration downloads..."
@cargo test -- --include-ignored --test-threads=1
@echo "All tests complete."
# Generate comprehensive test coverage report (including integration tests) and show in browser
coverage-comprehensive-and-show-in-browser $RUN_INTEGRATION_TESTS="1":
@echo "Generating comprehensive test coverage report (including integration tests) with --test-threads=1 for stable integration coverage, and opening it in browser..."
@cargo llvm-cov --all-targets --html --open -- --include-ignored --test-threads=1
@echo "Comprehensive coverage report generated and opened in browser."
# Run tests
test $RUN_INTEGRATION_TESTS="0":
@echo "Running tests..."
@cargo test
@echo "Tests complete."
# Generate test coverage report and show in browser
coverage-and-show-in-browser $RUN_INTEGRATION_TESTS="0":
@echo "Generating test coverage report and opening it in browser..."
@cargo llvm-cov --all-targets --html --open
@echo "Coverage report generated and opened in browser."
# Count lines of code and documentation
count-lines:
@echo "Counting lines of code and documentation..."
@tokei --hidden --exclude target
@echo "Line count complete."
# Run the Open Source Vulnerability scanner
vulnerability-scan:
@echo "Running Open Source Vulnerability scanner..."
@osv-scanner scan source -r .
@echo "Vulnerability scan complete."
# Publish the crate to crates.io
publish:
@echo "Publishing crate to crates.io..."
@cargo publish --locked
@echo "Crate published to crates.io."
# Advisory helper for Homebrew formula updates.
# It does NOT edit any formula. It prints the lines to update.
#
# Required:
# release_tag: tag used in the source archive URL (for example: v0.1.1).
# Optional:
# repo_base_url: repository base URL (for example: https://github.com/anirbanbasu/odir).
# If omitted, this recipe derives it from `git remote get-url origin`.
# formula_url: publicly accessible raw formula URL for showing current url/sha256 values.
#
# Example:
# just brew-formula-advise v0.1.1
# or
# just brew-formula-advise v0.1.1 https://github.com/anirbanbasu/odir https://raw.githubusercontent.com/anirbanbasu/homebrew-tap/refs/heads/main/Formula/odir.rb
# Advisory helper for Homebrew formula updates.
brew-formula-advise release_tag repo_base_url="" formula_url="":
#!/usr/bin/env bash
set -euo pipefail
release_tag="{{ release_tag }}"
repo_base_url="{{ repo_base_url }}"
formula_url="{{ formula_url }}"
if [[ -z "$repo_base_url" ]]; then
origin_url="$(git remote get-url origin)"
if [[ "$origin_url" =~ ^https?:// ]]; then
repo_base_url="${origin_url%.git}"
elif [[ "$origin_url" =~ ^git@([^:]+):(.+)\.git$ ]]; then
repo_base_url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
elif [[ "$origin_url" =~ ^ssh://git@([^/]+)/(.+)\.git$ ]]; then
repo_base_url="https://${BASH_REMATCH[1]}/${BASH_REMATCH[2]}"
else
echo "Could not derive repository base URL from origin: $origin_url" >&2
echo "Pass repo_base_url explicitly." >&2
exit 1
fi
fi
if [[ "$repo_base_url" =~ ^https://github\.com/([^/]+)/([^/]+)$ ]]; then
gh_owner="${BASH_REMATCH[1]}"
gh_repo="${BASH_REMATCH[2]}"
gh_release_api_url="https://api.github.com/repos/$gh_owner/$gh_repo/releases/tags/$release_tag"
if ! curl -fsSL "$gh_release_api_url" >/dev/null 2>&1; then
echo "Failed to validate GitHub release tag '$release_tag' via $gh_release_api_url." >&2
echo "The tag may be invalid, or the lookup may have failed due to rate limiting or network/API issues." >&2
exit 1
fi
fi
release_tarball_url="$repo_base_url/archive/refs/tags/$release_tag.tar.gz"
hash_cmd=""
if command -v shasum >/dev/null 2>&1; then
hash_cmd='shasum -a 256'
elif command -v sha256sum >/dev/null 2>&1; then
hash_cmd='sha256sum'
else
echo "Neither shasum nor sha256sum is available." >&2
exit 1
fi
echo "Repository base URL: $repo_base_url"
echo "Computed release archive URL: $release_tarball_url"
echo "Computing sha256 for release archive: $release_tarball_url"
tmp_archive="$(mktemp)"
trap 'rm -f "$tmp_archive"' EXIT
if ! curl -fsSL -o "$tmp_archive" "$release_tarball_url" >/dev/null 2>&1; then
echo "Failed to download release tarball: $release_tarball_url" >&2
exit 1
fi
if [[ "$hash_cmd" == "shasum -a 256" ]]; then
new_sha256="$(shasum -a 256 "$tmp_archive" | awk '{print $1}')"
else
new_sha256="$(sha256sum "$tmp_archive" | awk '{print $1}')"
fi
current_url=""
current_sha=""
current_sha_value=""
if [[ -n "$formula_url" ]]; then
formula_body="$(curl -fsSL "$formula_url")"
current_url="$(printf '%s\n' "$formula_body" | awk '/^[[:space:]]*url[[:space:]]+"/{print; exit}')"
current_sha="$(printf '%s\n' "$formula_body" | awk '/^[[:space:]]*sha256[[:space:]]+"/{print; exit}')"
current_sha_value="$(printf '%s\n' "$current_sha" | cut -d'"' -f2 | tr 'A-F' 'a-f')"
if [[ -n "$current_sha_value" && "$current_sha_value" == "$new_sha256" ]]; then
echo "Your Homebrew formula does not require any changes."
exit 0
fi
fi
echo
echo "Write these values into your formula:"
echo " url \"$release_tarball_url\""
echo " sha256 \"$new_sha256\""
echo
if [[ -n "$formula_url" ]]; then
echo "Inspecting current values from formula URL: $formula_url"
if [[ -n "$current_url" || -n "$current_sha" ]]; then
echo
echo "Current formula values (first match):"
[[ -n "$current_url" ]] && echo " $current_url"
[[ -n "$current_sha" ]] && echo " $current_sha"
else
echo "Could not find url/sha256 lines in formula content."
fi
fi