CODITECT CODI Build and Test Guide
Prerequisitesโ
1. System Requirementsโ
# Check Rust installation
rustc --version # Should be 1.82+
cargo --version
# If Rust not installed:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
2. Required Dependenciesโ
# Ubuntu/Debian
sudo apt update
sudo apt install -y build-essential pkg-config libssl-dev
# macOS
brew install openssl pkg-config
# CentOS/RHEL
sudo yum install -y gcc openssl-devel pkgconfig
3. FoundationDB (Optional for full features)โ
# Download and install FoundationDB 7.3
wget https://github.com/apple/foundationdb/releases/download/7.3.43/foundationdb-clients_7.3.43-1_amd64.deb
sudo dpkg -i foundationdb-clients_7.3.43-1_amd64.deb
# Start service
sudo systemctl start foundationdb
sudo systemctl enable foundationdb
Step-by-Step Build Processโ
Step 1: Navigate to CODI Directoryโ
cd /home/halcasteel/coditect.foundationdb.0001/build/decisions/v4/.codi
Step 2: Check Build Dependenciesโ
# Verify Cargo.toml exists and is valid
cat Cargo.toml | head -20
# Check if all source files are present
ls -la src/
Step 3: Build in Debug Mode (First)โ
# Clean previous build artifacts
cargo clean
# Build debug version (faster compilation, larger binary)
echo "๐จ Building CODI in debug mode..."
cargo build
# Check if build succeeded
if [ $? -eq 0 ]; then
echo "โ
Debug build successful!"
ls -lh target/debug/codi
else
echo "โ Debug build failed!"
exit 1
fi
Step 4: Test Debug Binaryโ
# Test basic functionality
echo "๐งช Testing debug binary..."
# Test help command
./target/debug/codi --help
# Test log command
./target/debug/codi log "Test message from debug binary"
# Test status command
./target/debug/codi status
# Test verbose mode
./target/debug/codi --verbose log "Verbose test message"
Step 5: Run Unit Testsโ
# Run all tests
echo "๐งช Running unit tests..."
cargo test
# Run tests with output
cargo test -- --nocapture
# Run specific test module
cargo test commands::log::tests
Step 6: Build Release Versionโ
# Build optimized release version
echo "๐ Building CODI release version..."
cargo build --release
# Check release build
if [ $? -eq 0 ]; then
echo "โ
Release build successful!"
ls -lh target/release/codi
# Compare sizes
echo "๐ Binary size comparison:"
echo "Debug: $(du -h target/debug/codi | cut -f1)"
echo "Release: $(du -h target/release/codi | cut -f1)"
else
echo "โ Release build failed!"
exit 1
fi
Step 7: Test Release Binaryโ
echo "๐งช Testing release binary..."
# Test all core commands
./target/release/codi --help
./target/release/codi log "Release binary test"
./target/release/codi status --detailed
./target/release/codi search "test" --limit 5
Step 8: Feature Testingโ
# Test with different feature flags
echo "๐๏ธ Testing feature configurations..."
# Build lite version (no FoundationDB)
cargo build --release --no-default-features --features lite
ls -lh target/release/codi
# Build full version with all features
cargo build --release --features full
ls -lh target/release/codi
Step 9: Integration Testingโ
echo "๐ Running integration tests..."
# Test configuration loading
./target/release/codi config list
# Test database connectivity (if FDB available)
./target/release/codi db stats
# Test dynamic command system (simulated)
./target/release/codi help
Step 10: Performance Testingโ
echo "โก Performance testing..."
# Measure startup time
time ./target/release/codi --version
# Measure command execution time
time ./target/release/codi log "Performance test message"
# Memory usage test
/usr/bin/time -v ./target/release/codi status 2>&1 | grep "Maximum resident"
Comprehensive Test Scriptโ
Create and run this complete test:
#!/bin/bash
# comprehensive-test.sh
set -e
echo "๐ CODITECT CODI Comprehensive Build and Test"
echo "=============================================="
# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'
# Test counters
TESTS_PASSED=0
TESTS_FAILED=0
run_test() {
local test_name="$1"
local command="$2"
echo -e "\n${BLUE}Testing: $test_name${NC}"
if eval "$command"; then
echo -e "${GREEN}โ
PASS: $test_name${NC}"
((TESTS_PASSED++))
else
echo -e "${RED}โ FAIL: $test_name${NC}"
((TESTS_FAILED++))
fi
}
# Build tests
run_test "Clean build" "cargo clean"
run_test "Debug build" "cargo build"
run_test "Release build" "cargo build --release"
run_test "Unit tests" "cargo test"
# Binary tests
run_test "Help command" "./target/release/codi --help"
run_test "Version command" "./target/release/codi --version"
run_test "Log command" "./target/release/codi log 'Test message'"
run_test "Status command" "./target/release/codi status"
run_test "Config command" "./target/release/codi config list"
# Feature tests
run_test "Lite build" "cargo build --release --no-default-features --features lite"
run_test "Full build" "cargo build --release --features full"
# Performance tests
run_test "Startup performance" "time timeout 5 ./target/release/codi --version"
echo -e "\n๐ฏ Test Results Summary"
echo "======================"
echo -e "${GREEN}Passed: $TESTS_PASSED${NC}"
echo -e "${RED}Failed: $TESTS_FAILED${NC}"
echo "Total: $((TESTS_PASSED + TESTS_FAILED))"
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "\n${GREEN}๐ All tests passed! CODI is ready to use.${NC}"
echo -e "Binary location: $(pwd)/target/release/codi"
echo -e "Binary size: $(du -h target/release/codi | cut -f1)"
else
echo -e "\n${RED}โ ๏ธ Some tests failed. Check the output above.${NC}"
fi
Troubleshooting Common Build Issuesโ
Issue 1: Compilation Errorsโ
# Clear cache and try again
cargo clean
cargo update
cargo build
# Check for specific dependency issues
cargo tree
Issue 2: FoundationDB Connection Issuesโ
# Check if FoundationDB is running
sudo systemctl status foundationdb
# Check cluster file
ls -la /etc/foundationdb/fdb.cluster
# Set environment variable
export FDB_CLUSTER_FILE="/etc/foundationdb/fdb.cluster"
Issue 3: OpenSSL Issuesโ
# Ubuntu/Debian
sudo apt install libssl-dev pkg-config
# Set environment variables if needed
export OPENSSL_DIR="/usr/lib/ssl"
export PKG_CONFIG_PATH="/usr/lib/pkgconfig"
Issue 4: Memory Issues During Buildโ
# Reduce parallel jobs
cargo build --release -j 2
# Or build specific features only
cargo build --release --no-default-features --features lite
Installation After Buildโ
Local Installationโ
# Copy to local bin directory
cp target/release/codi ~/.local/bin/
# Or create symlink
ln -s $(pwd)/target/release/codi ~/.local/bin/codi
# Add to PATH if needed
export PATH="$HOME/.local/bin:$PATH"
System Installationโ
# Install system-wide (requires sudo)
sudo cp target/release/codi /usr/local/bin/
# Verify installation
which codi
codi --version
Final Verificationโ
echo "๐ Final verification..."
# Test from any directory
cd /tmp
codi --version
codi log "Installation test"
codi status
echo "โ
CODI successfully built, tested, and installed!"
This guide provides a complete path from source code to a fully functional CODI binary with comprehensive testing.