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
# Makefile for rust-rule-engine crate
# =================================
.PHONY: help build test clean check format lint docs examples publish-dry publish-real release setup git-commit
# Default target
help:
@echo "๐ Rust Rule Engine - Makefile Commands"
@echo "======================================="
@echo ""
@echo "๐ฆ Build & Test:"
@echo " make build - Build the project"
@echo " make test - Run all tests"
@echo " make examples - Run all examples"
@echo " make check - Run cargo check"
@echo ""
@echo "๐ง Code Quality:"
@echo " make format - Format code with rustfmt"
@echo " make lint - Run clippy lints"
@echo " make docs - Generate documentation"
@echo ""
@echo "๐ Git & Publishing:"
@echo " make git-commit - Add all files and commit"
@echo " make publish-dry - Dry run publish (test only)"
@echo " make publish - Publish to crates.io"
@echo " make release - Full release process"
@echo ""
@echo "๐งน Cleanup:"
@echo " make clean - Clean build artifacts"
@echo ""
# Build the project
build:
@echo "๐จ Building rust-rule-engine..."
cargo build
# Build in release mode
build-release:
@echo "๐จ Building rust-rule-engine (release)..."
cargo build --release
# Run tests
test:
@echo "๐งช Running tests..."
cargo test
# Run benchmarks
bench:
@echo "โก Running benchmarks..."
cargo bench
# Run benchmarks with baseline
bench-baseline:
@echo "โก Running benchmarks with baseline..."
cargo bench -- --save-baseline main
# Compare benchmarks
bench-compare:
@echo "โก Comparing benchmarks..."
cargo bench -- --baseline main
# Open benchmark report
bench-report:
@echo "๐ Opening benchmark report..."
@if [ -f target/criterion/index.html ]; then \
echo "๐ Opening benchmark report in browser..."; \
xdg-open target/criterion/index.html 2>/dev/null || open target/criterion/index.html 2>/dev/null || echo "Please open target/criterion/index.html manually"; \
else \
echo "โ No benchmark report found. Run 'make bench' first."; \
fi
# Run all examples
examples:
@echo "๐ฏ Running all examples..."
@echo "================================"
@for example in ecommerce fraud_detection grule_demo method_calls_demo rule_file_functions_demo custom_functions_demo; do \
echo ""; \
echo "๐ Running example: $$example"; \
echo "----------------------------"; \
cargo run --example $$example || true; \
echo ""; \
done
# Check the project
check:
@echo "โ
Checking project..."
cargo check
# Format code
format:
@echo "๐จ Formatting code..."
cargo fmt
# Run clippy lints
lint:
@echo "๐ Running clippy lints..."
cargo clippy -- -D warnings
# Generate documentation
docs:
@echo "๐ Generating documentation..."
cargo doc --open
# Clean build artifacts
clean:
@echo "๐งน Cleaning build artifacts..."
cargo clean
# Git operations
git-status:
@echo "๐ Git status:"
git status --short
git-add:
@echo "โ Adding all files to git..."
git add .
git-commit: git-add
@echo "๐พ Committing changes..."
@read -p "Enter commit message: " msg; \
git commit -m "$$msg"
# Pre-publish checks
pre-publish: format lint test
@echo "๐ Pre-publish checks completed successfully!"
# Dry run publish (test only)
publish-dry: pre-publish
@echo "๐งช Dry run publish to crates.io..."
@echo "โ ๏ธ This will test the publish process without actually publishing"
@echo ""
@echo "๐ Package info:"
@grep "^name\|^version\|^description" Cargo.toml
@echo ""
@echo "๐ Files to be included:"
@cargo package --list | head -20
@echo ""
@read -p "Continue with dry run? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
cargo publish --dry-run --allow-dirty; \
else \
echo "โ Dry run cancelled"; \
fi
# Real publish to crates.io
publish: pre-publish git-status
@echo "๐ Publishing to crates.io..."
@echo "โ ๏ธ This will ACTUALLY publish the crate!"
@echo ""
@echo "๐ Package info:"
@grep "^name\|^version\|^description" Cargo.toml
@echo ""
@echo "๐ Git status:"
@git status --short
@echo ""
@if [ -n "$$(git status --porcelain)" ]; then \
echo "โ ๏ธ Warning: You have uncommitted changes!"; \
echo "Run 'make git-commit' first or use --allow-dirty"; \
echo ""; \
read -p "Publish with uncommitted changes? (y/N): " dirty; \
if [ "$$dirty" = "y" ] || [ "$$dirty" = "Y" ]; then \
echo "Publishing with --allow-dirty..."; \
cargo publish --allow-dirty; \
else \
echo "โ Publish cancelled. Commit your changes first."; \
exit 1; \
fi; \
else \
read -p "Continue with publish? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
cargo publish; \
else \
echo "โ Publish cancelled"; \
fi; \
fi
# Full release process
release:
@echo "๐ Starting full release process..."
@echo "=================================="
@echo ""
@echo "This will:"
@echo "1. ๐จ Format code"
@echo "2. ๐ Run lints"
@echo "3. ๐งช Run tests"
@echo "4. ๐ฏ Run examples"
@echo "5. ๐พ Commit changes (if needed)"
@echo "6. ๐ Publish to crates.io"
@echo ""
@read -p "Continue with full release? (y/N): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
$(MAKE) format; \
$(MAKE) lint; \
$(MAKE) test; \
$(MAKE) examples; \
if [ -n "$$(git status --porcelain)" ]; then \
echo ""; \
echo "๐พ Changes detected, committing..."; \
$(MAKE) git-commit; \
fi; \
echo ""; \
echo "๐ Ready to publish!"; \
$(MAKE) publish-real; \
else \
echo "โ Release cancelled"; \
fi
# Setup development environment
setup:
@echo "๐ง Setting up development environment..."
@echo "Installing required tools..."
rustup component add rustfmt clippy
@echo "โ
Setup complete!"
# Version bump helpers
version-patch:
@echo "๐ Bumping patch version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new patch version (e.g., 0.1.1): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
version-minor:
@echo "๐ Bumping minor version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new minor version (e.g., 0.2.0): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
version-major:
@echo "๐ Bumping major version..."
@current=$$(grep "^version" Cargo.toml | cut -d'"' -f2); \
echo "Current version: $$current"; \
read -p "Enter new major version (e.g., 1.0.0): " new_version; \
sed -i 's/^version = ".*"/version = "'$$new_version'"/' Cargo.toml; \
echo "โ
Version updated to $$new_version"
# Package information
package-info:
@echo "๐ฆ Package Information"
@echo "====================="
@echo ""
@echo "๐ Basic Info:"
@grep "^name\|^version\|^description\|^authors" Cargo.toml
@echo ""
@echo "๐ Files to be packaged:"
@cargo package --list 2>/dev/null | head -20 || echo "Run 'cargo check' first"
@echo ""
@echo "๐ Package size:"
@cargo package --list 2>/dev/null | wc -l || echo "Run 'cargo check' first"
@echo " files total"
# All quality checks
qa: format lint test
@echo "โ
All quality assurance checks passed!"