Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Run Tests

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
clear_cache:
description: 'Clear model cache and re-download'
required: false
type: boolean
default: false

env:
MODEL_NAME: Llama-3.2-3B-Instruct-Q4_K_M.gguf
MODEL_PATH: models/Llama-3.2-3B-Instruct-Q4_K_M.gguf
MODEL_URL: https://huggingface.co/hugging-quants/Llama-3.2-3B-Instruct-Q4_K_M-GGUF/resolve/main/llama-3.2-3b-instruct-q4_k_m.gguf
CACHE_VERSION: v1

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 60

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js 22+
uses: actions/setup-node@v4
with:
node-version: '22'
check-latest: true
cache: 'npm'

- name: Create models directory
run: mkdir -p models

# Restore cache (90-day retention with stable key)
- name: Restore model from cache
if: github.event.inputs.clear_cache != 'true'
id: cache-model-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.MODEL_PATH }}
key: llama-model-${{ runner.os }}-${{ env.CACHE_VERSION }}
restore-keys: |
llama-model-${{ runner.os }}-

- name: Cache status
run: |
if [ "${{ steps.cache-model-restore.outputs.cache-hit }}" == "true" ]; then
echo "✅ Model loaded from cache"
else
echo "⚠️ Model not in cache, will download"
fi

- name: Download model
if: steps.cache-model-restore.outputs.cache-hit != 'true' || github.event.inputs.clear_cache == 'true'
run: |
# Remove existing file if forcing re-download
[ -f "${{ env.MODEL_PATH }}" ] && rm "${{ env.MODEL_PATH }}"

# Download with comprehensive retry logic
MAX_RETRIES=5
RETRY_COUNT=0

while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
echo "Attempt $((RETRY_COUNT + 1))/$MAX_RETRIES..."

if curl -L \
--fail \
--retry 3 \
--retry-delay 5 \
--connect-timeout 30 \
--max-time 3600 \
-o "${{ env.MODEL_PATH }}" \
-# \
"${{ env.MODEL_URL }}"; then
break
else
RETRY_COUNT=$((RETRY_COUNT + 1))
if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
echo "⚠️ Download failed, retrying in 10 seconds..."
sleep 10
else
echo "❌ Download failed after $MAX_RETRIES attempts"
exit 1
fi
fi
done

- name: Save model to cache
if: steps.cache-model-restore.outputs.cache-hit != 'true' || github.event.inputs.clear_cache == 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.MODEL_PATH }}
key: llama-model-${{ runner.os }}-${{ env.CACHE_VERSION }}

- name: Install dependencies
run: npm ci

- name: Install Chroma
run: pip install chromadb

- name: Start Chroma DB
run: |
chroma-server --host 0.0.0.0 --port 8000 &
for i in {1..30}; do
if nc -z localhost 8000; then
echo "✅ Chroma is ready"
break
fi
echo "Waiting for Chroma to start..."
sleep 2
done

- name: Run tests
run: npm test
env:
NODE_ENV: test
timeout-minutes: 30

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
coverage/
test-results/
retention-days: 7
if-no-files-found: ignore

- name: Setup Python 3.12.8
uses: actions/setup-python@v4
with:
python-version: '3.12.8'

- name: Create virtual environment and install dependencies
run: |
python -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r python/requirements.txt

- name: Run Python unit tests
run: |
.venv/bin/python -m unittest discover python/tests
timeout-minutes: 15
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ output-videos
__pycache__
.chroma_db
.locations.json
.venv
.venv
models/
3 changes: 1 addition & 2 deletions lib/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const CHROMA_PORT = process.env.CHROMA_PORT || '8000';
export const COLLECTION_NAME = 'video_content';

// AI Models
export const EMBEDDING_MODEL = 'text-embedding-004';
export const GEMINI_API_KEY = process.env.GEMINI_API_KEY;
export const SEARCH_AI_MODEL = 'Llama-3.2-3B-Instruct-Q4_K_M.gguf'


// Files
Expand Down
2 changes: 1 addition & 1 deletion lib/conveyor/handlers/app-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
queryCollection,
updateMetadata,
} from '@/lib/services/vectorDb'
import { generateActionFromPrompt } from '@/lib/services/gemini'
import { generateActionFromPrompt } from '@/lib/services/llm'
import { stitchVideos } from '@/lib/utils/sticher'
import { exportToFcpXml } from '@/lib/utils/fcpxml'
import { convertTimeToWords } from '@/lib/utils/time'
Expand Down
120 changes: 0 additions & 120 deletions lib/services/gemini.ts

This file was deleted.

Loading