cqlite-cli 0.11.0

Command-line interface for CQLite โ€” read Apache Cassandra 5.0 SSTables without a cluster
Documentation
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
406
407
408
409
410
411
name: ๐Ÿ˜ Cassandra Compatibility Testing

on:
  # Run on pushes to main branch
  push:
    branches: [ main ]
  
  # Run on pull requests
  pull_request:
    branches: [ main ]
    
  # Run daily to catch new Cassandra releases
  schedule:
    - cron: '0 6 * * *'  # 6 AM UTC daily
    
  # Allow manual triggering
  workflow_dispatch:
    inputs:
      cassandra_versions:
        description: 'Cassandra versions to test (comma-separated)'
        required: false
        default: '4.0,4.1,5.0,5.1,6.0'
      test_suite:
        description: 'Test suite level'
        required: false
        default: 'comprehensive'
        type: choice
        options:
          - basic
          - comprehensive
          - full

env:
  CARGO_TERM_COLOR: always

jobs:
  detect-versions:
    name: ๐Ÿ” Detect Available Cassandra Versions
    runs-on: ubuntu-latest
    outputs:
      versions: ${{ steps.detect.outputs.versions }}
      matrix: ${{ steps.detect.outputs.matrix }}
    steps:
      - name: Detect Available Versions
        id: detect
        run: |
          # Get available Cassandra Docker images
          VERSIONS=$(curl -s "https://hub.docker.com/v2/repositories/cassandra/tags/?page_size=100" \
            | jq -r '.results[] | select(.name | test("^[0-9]+\\.[0-9]+$")) | .name' \
            | sort -V \
            | tail -10 \
            | tr '\n' ',' | sed 's/,$//')
          
          # Use input versions if provided, otherwise use detected versions
          if [ "${{ github.event.inputs.cassandra_versions }}" != "" ]; then
            VERSIONS="${{ github.event.inputs.cassandra_versions }}"
          fi
          
          echo "versions=$VERSIONS" >> $GITHUB_OUTPUT
          
          # Create matrix for parallel testing
          MATRIX=$(echo "$VERSIONS" | jq -R 'split(",") | map({version: .})')
          echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
          
          echo "๐Ÿ˜ Will test Cassandra versions: $VERSIONS"

  compatibility-matrix:
    name: ๐Ÿงช Test Cassandra ${{ matrix.version }}
    runs-on: ubuntu-latest
    needs: detect-versions
    strategy:
      fail-fast: false
      matrix:
        include: ${{ fromJson(needs.detect-versions.outputs.matrix) }}
    
    steps:
      - name: ๐Ÿ“ฅ Checkout Code
        uses: actions/checkout@v4
        
      - name: ๐Ÿฆ€ Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true
          
      - name: ๐Ÿ“ฆ Cache Cargo Dependencies
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/registry
            ~/.cargo/git
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
          
      - name: ๐Ÿณ Setup Docker Buildx
        uses: docker/setup-buildx-action@v3
        
      - name: ๐Ÿ˜ Start Cassandra ${{ matrix.version }}
        run: |
          echo "๐Ÿš€ Starting Cassandra ${{ matrix.version }}"
          
          # Calculate unique port for this version
          VERSION_HASH=$(echo "${{ matrix.version }}" | sha256sum | cut -c1-4)
          PORT=$((9042 + 0x$VERSION_HASH % 100))
          
          docker run -d \
            --name cassandra-${{ matrix.version }} \
            -p $PORT:9042 \
            -e CASSANDRA_START_RPC=true \
            -e CASSANDRA_RPC_ADDRESS=0.0.0.0 \
            -e CASSANDRA_LISTEN_ADDRESS=auto \
            -e CASSANDRA_BROADCAST_ADDRESS=127.0.0.1 \
            -e CASSANDRA_BROADCAST_RPC_ADDRESS=127.0.0.1 \
            cassandra:${{ matrix.version }}
          
          echo "PORT=$PORT" >> $GITHUB_ENV
          
          # Wait for Cassandra to be ready
          echo "โณ Waiting for Cassandra to be ready..."
          for i in {1..30}; do
            if docker exec cassandra-${{ matrix.version }} cqlsh -e "DESCRIBE KEYSPACES;" > /dev/null 2>&1; then
              echo "โœ… Cassandra ${{ matrix.version }} is ready!"
              break
            fi
            echo "โณ Attempt $i/30..."
            sleep 10
          done
          
      - name: ๐Ÿ—๏ธ Build Compatibility Test Suite
        run: |
          cd tests/compatibility
          cargo build --release --bin compatibility-checker
          
      - name: ๐Ÿ“Š Generate Test Data
        run: |
          cd tests/compatibility
          ./target/release/compatibility-checker generate \
            --version ${{ matrix.version }} \
            --rows 10000 \
            --complex \
            --output ./test-data
            
      - name: ๐Ÿงช Run Compatibility Tests
        run: |
          cd tests/compatibility
          ./target/release/compatibility-checker test \
            --version ${{ matrix.version }} \
            --suite ${{ github.event.inputs.test_suite || 'comprehensive' }} \
            --detailed \
            --output ./results
            
      - name: ๐Ÿ“ˆ Analyze Performance
        run: |
          cd tests/compatibility
          echo "๐Ÿ“Š Performance Analysis for Cassandra ${{ matrix.version }}"
          
          # Run performance benchmarks
          cargo run --bin compatibility-checker -- test \
            --version ${{ matrix.version }} \
            --suite performance \
            --output ./performance-results
            
      - name: ๐Ÿ” Detect Format Changes
        if: matrix.version != '4.0'  # Skip baseline version
        run: |
          cd tests/compatibility
          ./target/release/compatibility-checker detect \
            --sstable-dir ./test-data/cassandra-${{ matrix.version }} \
            --baseline 4.0
            
      - name: ๐Ÿ“„ Upload Test Results
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: compatibility-results-${{ matrix.version }}
          path: |
            tests/compatibility/results/
            tests/compatibility/performance-results/
          retention-days: 30
          
      - name: ๐Ÿ“Š Generate Version Report
        run: |
          cd tests/compatibility/results
          
          # Create summary for this version
          echo "# Cassandra ${{ matrix.version }} Compatibility Report" > version-summary.md
          echo "" >> version-summary.md
          echo "**Test Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> version-summary.md
          echo "**Version:** ${{ matrix.version }}" >> version-summary.md
          echo "" >> version-summary.md
          
          if [ -f "compatibility-${{ matrix.version }}.json" ]; then
            SCORE=$(jq -r '.compatibility_score' compatibility-${{ matrix.version }}.json)
            ISSUES=$(jq -r '.issues | length' compatibility-${{ matrix.version }}.json)
            
            echo "**Compatibility Score:** ${SCORE}%" >> version-summary.md
            echo "**Issues Found:** $ISSUES" >> version-summary.md
            
            if (( $(echo "$SCORE >= 95" | bc -l) )); then
              echo "**Status:** โœ… Fully Compatible" >> version-summary.md
            elif (( $(echo "$SCORE >= 80" | bc -l) )); then
              echo "**Status:** ๐ŸŸก Mostly Compatible" >> version-summary.md
            else
              echo "**Status:** โŒ Compatibility Issues" >> version-summary.md
            fi
          fi
          
      - name: ๐Ÿณ Cleanup Docker Container
        if: always()
        run: |
          docker stop cassandra-${{ matrix.version }} || true
          docker rm cassandra-${{ matrix.version }} || true

  compatibility-report:
    name: ๐Ÿ“Š Generate Compatibility Report
    runs-on: ubuntu-latest
    needs: [detect-versions, compatibility-matrix]
    if: always()
    
    steps:
      - name: ๐Ÿ“ฅ Checkout Code
        uses: actions/checkout@v4
        
      - name: ๐Ÿ“„ Download All Test Results
        uses: actions/download-artifact@v3
        with:
          path: ./all-results
          
      - name: ๐Ÿฆ€ Setup Rust
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal
          override: true
          
      - name: ๐Ÿ“Š Generate Matrix Report
        run: |
          cd tests/compatibility
          cargo build --release --bin compatibility-checker
          
          # Combine all results into matrix report
          ./target/release/compatibility-checker matrix \
            --format markdown \
            --output ./final-report
            
      - name: ๐Ÿ“ˆ Create Dashboard
        run: |
          cat > compatibility-dashboard.md << 'EOF'
          # ๐Ÿ˜ CQLite Cassandra Compatibility Dashboard
          
          **Last Updated:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
          **Workflow Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
          
          ## ๐Ÿ“Š Compatibility Matrix
          
          | Version | Status | Score | Issues | Performance |
          |---------|--------|-------|--------|-------------|
          EOF
          
          # Process each version result
          for artifact_dir in ./all-results/compatibility-results-*; do
            if [ -d "$artifact_dir" ]; then
              VERSION=$(basename "$artifact_dir" | sed 's/compatibility-results-//')
              
              if [ -f "$artifact_dir/compatibility-$VERSION.json" ]; then
                SCORE=$(jq -r '.compatibility_score' "$artifact_dir/compatibility-$VERSION.json")
                ISSUES=$(jq -r '.issues | length' "$artifact_dir/compatibility-$VERSION.json")
                
                if (( $(echo "$SCORE >= 95" | bc -l) )); then
                  STATUS="โœ… Compatible"
                elif (( $(echo "$SCORE >= 80" | bc -l) )); then
                  STATUS="๐ŸŸก Minor Issues"
                else
                  STATUS="โŒ Issues Found"
                fi
                
                echo "| $VERSION | $STATUS | ${SCORE}% | $ISSUES | TBD |" >> compatibility-dashboard.md
              else
                echo "| $VERSION | โŒ Test Failed | - | - | - |" >> compatibility-dashboard.md
              fi
            fi
          done
          
          echo "" >> compatibility-dashboard.md
          echo "## ๐Ÿ”— Detailed Reports" >> compatibility-dashboard.md
          echo "" >> compatibility-dashboard.md
          echo "- [Full Compatibility Matrix](./tests/compatibility/final-report/compatibility-matrix.md)" >> compatibility-dashboard.md
          echo "- [Performance Analysis](./tests/compatibility/final-report/performance-analysis.md)" >> compatibility-dashboard.md
          echo "- [Format Evolution](./tests/compatibility/final-report/format-evolution.md)" >> compatibility-dashboard.md
          
      - name: ๐Ÿ“„ Upload Final Report
        uses: actions/upload-artifact@v3
        with:
          name: compatibility-dashboard
          path: |
            compatibility-dashboard.md
            tests/compatibility/final-report/
          retention-days: 90
          
      - name: ๐Ÿ’ฌ Comment on PR
        if: github.event_name == 'pull_request'
        uses: actions/github-script@v6
        with:
          script: |
            const fs = require('fs');
            
            // Read the dashboard summary
            let dashboard = '';
            try {
              dashboard = fs.readFileSync('compatibility-dashboard.md', 'utf8');
            } catch (error) {
              dashboard = 'โŒ Failed to generate compatibility dashboard';
            }
            
            const comment = `## ๐Ÿ˜ Cassandra Compatibility Test Results
            
            ${dashboard}
            
            <details>
            <summary>๐Ÿ“Š Click to view detailed compatibility matrix</summary>
            
            \`\`\`
            Test completed for Cassandra versions: ${{ needs.detect-versions.outputs.versions }}
            Workflow: ${{ github.workflow }}
            Run: #${{ github.run_number }}
            \`\`\`
            
            </details>`;
            
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: comment
            });
            
      - name: ๐Ÿšจ Notify on Compatibility Issues
        if: failure()
        run: |
          echo "๐Ÿšจ Compatibility issues detected!"
          echo "This workflow will help identify what needs to be fixed in CQLite."
          
          # Create GitHub issue if critical compatibility problems found
          if [ "${{ github.event_name }}" = "schedule" ]; then
            echo "Creating GitHub issue for compatibility problems..."
            # TODO: Create issue using GitHub API
          fi

  update-docs:
    name: ๐Ÿ“š Update Compatibility Documentation
    runs-on: ubuntu-latest
    needs: [compatibility-report]
    if: github.ref == 'refs/heads/main' && success()
    
    steps:
      - name: ๐Ÿ“ฅ Checkout Code
        uses: actions/checkout@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          
      - name: ๐Ÿ“„ Download Dashboard
        uses: actions/download-artifact@v3
        with:
          name: compatibility-dashboard
          path: ./dashboard
          
      - name: ๐Ÿ“š Update Documentation
        run: |
          # Update compatibility status in docs
          mkdir -p docs/compatibility
          
          if [ -f "./dashboard/compatibility-dashboard.md" ]; then
            cp ./dashboard/compatibility-dashboard.md docs/compatibility/README.md
            
            # Update main README with compatibility badge
            OVERALL_SCORE=$(grep "Overall Compatibility" docs/compatibility/README.md | grep -o '[0-9.]*%' | head -1 | sed 's/%//')
            
            if (( $(echo "$OVERALL_SCORE >= 95" | bc -l) )); then
              BADGE_COLOR="brightgreen"
              BADGE_TEXT="$OVERALL_SCORE%25compatible"
            elif (( $(echo "$OVERALL_SCORE >= 80" | bc -l) )); then
              BADGE_COLOR="yellow"
              BADGE_TEXT="$OVERALL_SCORE%25compatible"
            else
              BADGE_COLOR="red"
              BADGE_TEXT="$OVERALL_SCORE%25compatible"
            fi
            
            # Update README.md with latest compatibility badge
            sed -i "s|!\[Cassandra Compatibility\].*|![Cassandra Compatibility](https://img.shields.io/badge/Cassandra-$BADGE_TEXT-$BADGE_COLOR)|" README.md
          fi
          
      - name: ๐Ÿ“ค Commit Documentation Updates
        run: |
          git config --local user.email "action@github.com"
          git config --local user.name "GitHub Action"
          
          git add docs/compatibility/README.md README.md
          
          if ! git diff --staged --quiet; then
            git commit -m "๐Ÿ“š Update Cassandra compatibility documentation
            
            - Updated compatibility matrix
            - Updated compatibility score badge
            - Generated from workflow run #${{ github.run_number }}"
            
            git push
          else
            echo "No documentation changes to commit"
          fi