Add RocksDB test workflow with 5 comprehensive tests #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test RocksDB on Arm64 | |
| on: | |
| workflow_call: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - smoke_tests | |
| paths: | |
| - 'content/opensource_packages/rocksdb.md' | |
| - '.github/workflows/test-rocksdb.yml' | |
| jobs: | |
| test-rocksdb: | |
| runs-on: ubuntu-24.04-arm | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set test metadata | |
| id: metadata | |
| run: | | |
| echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_OUTPUT | |
| echo "package_slug=rocksdb" >> $GITHUB_OUTPUT | |
| echo "dashboard_link=/opensource_packages/rocksdb" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # Install RocksDB | |
| # ============================================================ | |
| - name: Install RocksDB dependencies and build tools | |
| id: install_deps | |
| run: | | |
| echo "Installing build dependencies..." | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libgflags-dev \ | |
| libsnappy-dev \ | |
| zlib1g-dev \ | |
| libbz2-dev \ | |
| liblz4-dev \ | |
| libzstd-dev \ | |
| build-essential \ | |
| cmake \ | |
| git | |
| - name: Install RocksDB | |
| id: install | |
| run: | | |
| echo "Installing RocksDB from Ubuntu repository..." | |
| # Install RocksDB library and tools | |
| sudo apt-get install -y librocksdb-dev rocksdb-tools | |
| # Verify installation | |
| if dpkg -l | grep -q rocksdb; then | |
| echo "RocksDB installed successfully" | |
| echo "install_status=success" >> $GITHUB_OUTPUT | |
| else | |
| echo "RocksDB installation failed" | |
| echo "install_status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| # ============================================================ | |
| # Detect version | |
| # ============================================================ | |
| - name: Detect RocksDB version | |
| id: version | |
| run: | | |
| # Try to get version from pkg-config | |
| if pkg-config --exists rocksdb; then | |
| VERSION=$(pkg-config --modversion rocksdb 2>/dev/null || echo "unknown") | |
| else | |
| # Fallback: check package version | |
| VERSION=$(dpkg -l | grep librocksdb | awk '{print $3}' | head -n1 | cut -d'-' -f1 || echo "unknown") | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Detected RocksDB version: $VERSION" | |
| # ============================================================ | |
| # Run tests | |
| # ============================================================ | |
| - name: Test 1 - Check RocksDB library is installed | |
| id: test1 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if dpkg -l | grep -q librocksdb; then | |
| echo "✓ RocksDB library package found" | |
| dpkg -l | grep rocksdb | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ RocksDB library package not found" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 2 - Check RocksDB header files exist | |
| id: test2 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if [ -f "/usr/include/rocksdb/db.h" ] || [ -f "/usr/include/aarch64-linux-gnu/rocksdb/db.h" ]; then | |
| echo "✓ RocksDB header files found" | |
| find /usr/include -name "db.h" -path "*/rocksdb/*" 2>/dev/null || true | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ RocksDB header files not found" | |
| echo "Searching for rocksdb headers:" | |
| find /usr -name "rocksdb" -type d 2>/dev/null || echo "No rocksdb directory found" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 3 - Check RocksDB shared library exists | |
| id: test3 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if ldconfig -p | grep -q librocksdb; then | |
| echo "✓ RocksDB shared library found" | |
| ldconfig -p | grep librocksdb | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ RocksDB shared library not found" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 4 - Check ldb tool (RocksDB command-line tool) | |
| id: test4 | |
| run: | | |
| START_TIME=$(date +%s) | |
| if command -v ldb &> /dev/null; then | |
| echo "✓ ldb tool found" | |
| which ldb | |
| ldb --version 2>&1 || ldb --help | head -5 || echo "ldb binary exists" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ ldb tool not found" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| - name: Test 5 - Create and query a simple RocksDB database | |
| id: test5 | |
| run: | | |
| START_TIME=$(date +%s) | |
| # Create a test directory | |
| TEST_DIR="/tmp/rocksdb_test" | |
| rm -rf "$TEST_DIR" | |
| mkdir -p "$TEST_DIR" | |
| # Use ldb to create and manipulate a database | |
| cd "$TEST_DIR" | |
| # Put a key-value pair | |
| echo "testvalue" | ldb put testkey --db="$TEST_DIR/testdb" --create_if_missing 2>&1 | |
| # Get the value back | |
| RESULT=$(ldb get testkey --db="$TEST_DIR/testdb" 2>&1 || echo "") | |
| # Clean up | |
| rm -rf "$TEST_DIR" | |
| if echo "$RESULT" | grep -q "testvalue"; then | |
| echo "✓ Successfully created database and retrieved value" | |
| echo "Result: $RESULT" | |
| echo "status=passed" >> $GITHUB_OUTPUT | |
| else | |
| echo "✗ Failed to create/query RocksDB database" | |
| echo "Result: $RESULT" | |
| echo "status=failed" >> $GITHUB_OUTPUT | |
| exit 1 | |
| fi | |
| END_TIME=$(date +%s) | |
| echo "duration=$((END_TIME - START_TIME))" >> $GITHUB_OUTPUT | |
| # ============================================================ | |
| # Calculate summary | |
| # ============================================================ | |
| - name: Calculate test summary | |
| if: always() | |
| id: summary | |
| run: | | |
| PASSED=0 | |
| FAILED=0 | |
| TOTAL_DURATION=0 | |
| # Test 1 | |
| if [ "${{ steps.test1.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test1.outputs.duration || 0 }})) | |
| # Test 2 | |
| if [ "${{ steps.test2.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test2.outputs.duration || 0 }})) | |
| # Test 3 | |
| if [ "${{ steps.test3.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test3.outputs.duration || 0 }})) | |
| # Test 4 | |
| if [ "${{ steps.test4.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test4.outputs.duration || 0 }})) | |
| # Test 5 | |
| if [ "${{ steps.test5.outputs.status }}" == "passed" ]; then | |
| PASSED=$((PASSED + 1)) | |
| else | |
| FAILED=$((FAILED + 1)) | |
| fi | |
| TOTAL_DURATION=$((TOTAL_DURATION + ${{ steps.test5.outputs.duration || 0 }})) | |
| echo "passed=$PASSED" >> $GITHUB_OUTPUT | |
| echo "failed=$FAILED" >> $GITHUB_OUTPUT | |
| echo "duration=$TOTAL_DURATION" >> $GITHUB_OUTPUT | |
| if [ $FAILED -eq 0 ]; then | |
| echo "overall_status=success" >> $GITHUB_OUTPUT | |
| echo "badge_status=passing" >> $GITHUB_OUTPUT | |
| else | |
| echo "overall_status=failure" >> $GITHUB_OUTPUT | |
| echo "badge_status=failing" >> $GITHUB_OUTPUT | |
| fi | |
| # ============================================================ | |
| # Generate JSON with RocksDB metadata | |
| # ============================================================ | |
| - name: Generate test results JSON | |
| if: always() | |
| run: | | |
| mkdir -p test-results | |
| cat > test-results/rocksdb.json << EOF | |
| { | |
| "schema_version": "1.0", | |
| "package": { | |
| "name": "RocksDB", | |
| "version": "${{ steps.version.outputs.version }}", | |
| "language": "c++", | |
| "category": "Database" | |
| }, | |
| "run": { | |
| "id": "${{ github.run_id }}", | |
| "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", | |
| "timestamp": "${{ steps.metadata.outputs.timestamp }}", | |
| "status": "${{ steps.summary.outputs.overall_status }}", | |
| "runner": { | |
| "os": "ubuntu-24.04", | |
| "arch": "arm64" | |
| } | |
| }, | |
| "tests": { | |
| "passed": ${{ steps.summary.outputs.passed }}, | |
| "failed": ${{ steps.summary.outputs.failed }}, | |
| "skipped": 0, | |
| "duration_seconds": ${{ steps.summary.outputs.duration }}, | |
| "details": [ | |
| { | |
| "name": "Check RocksDB library is installed", | |
| "status": "${{ steps.test1.outputs.status }}", | |
| "duration_seconds": ${{ steps.test1.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check RocksDB header files exist", | |
| "status": "${{ steps.test2.outputs.status }}", | |
| "duration_seconds": ${{ steps.test2.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check RocksDB shared library exists", | |
| "status": "${{ steps.test3.outputs.status }}", | |
| "duration_seconds": ${{ steps.test3.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Check ldb tool (RocksDB command-line tool)", | |
| "status": "${{ steps.test4.outputs.status }}", | |
| "duration_seconds": ${{ steps.test4.outputs.duration || 0 }} | |
| }, | |
| { | |
| "name": "Create and query a simple RocksDB database", | |
| "status": "${{ steps.test5.outputs.status }}", | |
| "duration_seconds": ${{ steps.test5.outputs.duration || 0 }} | |
| } | |
| ] | |
| }, | |
| "metadata": { | |
| "dashboard_link": "${{ steps.metadata.outputs.dashboard_link }}", | |
| "badge_status": "${{ steps.summary.outputs.badge_status }}" | |
| } | |
| } | |
| EOF | |
| echo "Generated test results:" | |
| cat test-results/rocksdb.json | |
| # ============================================================ | |
| # STANDARD STEPS - Commit results to repository | |
| # ============================================================ | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rocksdb-test-results | |
| path: test-results/rocksdb.json | |
| retention-days: 90 | |
| - name: Commit test results to repository | |
| if: always() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/smoke_tests') | |
| run: | | |
| git config --global user.name 'github-actions[bot]' | |
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
| mkdir -p data/test-results | |
| cp test-results/rocksdb.json data/test-results/rocksdb.json | |
| git add data/test-results/rocksdb.json | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update rocksdb test results [skip ci]" | |
| # Retry logic for push | |
| MAX_RETRIES=5 | |
| RETRY_COUNT=0 | |
| while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do | |
| if git push origin ${{ github.ref_name }}; then | |
| echo "Successfully pushed test results" | |
| break | |
| else | |
| RETRY_COUNT=$((RETRY_COUNT + 1)) | |
| if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then | |
| echo "Push failed, attempt $RETRY_COUNT of $MAX_RETRIES. Retrying in 5 seconds..." | |
| sleep 5 | |
| git pull --rebase origin ${{ github.ref_name }} | |
| else | |
| echo "Failed to push after $MAX_RETRIES attempts" | |
| exit 1 | |
| fi | |
| fi | |
| done | |
| else | |
| echo "No changes to commit" | |
| fi |