fix: restore migration 014, bump version to 0.2.50, harden pr-review workflow
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m10s
Test / frontend-typecheck (pull_request) Successful in 1m13s
Test / rust-fmt-check (pull_request) Successful in 2m35s
PR Review Automation / review (pull_request) Successful in 3m40s
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
Some checks failed
Test / frontend-tests (pull_request) Successful in 1m10s
Test / frontend-typecheck (pull_request) Successful in 1m13s
Test / rust-fmt-check (pull_request) Successful in 2m35s
PR Review Automation / review (pull_request) Successful in 3m40s
Test / rust-clippy (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
- Restore 014_create_ai_providers migration and tests missing due to branch diverging from master before PR #34 merged - Bump version from 0.2.10 to 0.2.50 to match master and avoid regression - Trim diff input to 20 KB to prevent Ollama token overflow - Add --max-time 120 to curl to prevent workflow hanging indefinitely
This commit is contained in:
parent
2f7be85e64
commit
02b40bb12d
@ -35,7 +35,7 @@ jobs:
|
||||
env:
|
||||
OLLAMA_URL: http://172.0.1.42:11434
|
||||
run: |
|
||||
DIFF_CONTENT=$(cat /tmp/pr_diff.txt)
|
||||
DIFF_CONTENT=$(head -c 20000 /tmp/pr_diff.txt)
|
||||
PR_TITLE="${{ github.event.pull_request.title }}"
|
||||
PROMPT="Analyze the following code changes for correctness, security issues, and best practices. PR Title: ${PR_TITLE}\n\nDiff:\n${DIFF_CONTENT}\n\nProvide a review with: 1) Summary, 2) Bugs/errors, 3) Security issues, 4) Best practices. Give specific comments with suggested fixes."
|
||||
BODY=$(jq -n \
|
||||
@ -44,7 +44,7 @@ jobs:
|
||||
'{model: $model, messages: [{role: "user", content: $content}], stream: false}')
|
||||
echo "Request body length: ${#BODY} bytes"
|
||||
echo "Calling Ollama API..."
|
||||
HTTP_CODE=$(curl -s -o /tmp/ollama_response.json -w "%{http_code}" \
|
||||
HTTP_CODE=$(curl -s --max-time 120 -o /tmp/ollama_response.json -w "%{http_code}" \
|
||||
-X POST "$OLLAMA_URL/api/chat" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$BODY")
|
||||
|
||||
@ -170,6 +170,27 @@ pub fn run_migrations(conn: &Connection) -> anyhow::Result<()> {
|
||||
is_paste INTEGER NOT NULL DEFAULT 0
|
||||
);",
|
||||
),
|
||||
(
|
||||
"014_create_ai_providers",
|
||||
"CREATE TABLE IF NOT EXISTS ai_providers (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL UNIQUE,
|
||||
provider_type TEXT NOT NULL,
|
||||
api_url TEXT NOT NULL,
|
||||
encrypted_api_key TEXT NOT NULL,
|
||||
model TEXT NOT NULL,
|
||||
max_tokens INTEGER,
|
||||
temperature REAL,
|
||||
custom_endpoint_path TEXT,
|
||||
custom_auth_header TEXT,
|
||||
custom_auth_prefix TEXT,
|
||||
api_format TEXT,
|
||||
user_id TEXT,
|
||||
use_datastore_upload INTEGER,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);",
|
||||
),
|
||||
];
|
||||
|
||||
for (name, sql) in migrations {
|
||||
@ -468,4 +489,75 @@ mod tests {
|
||||
assert_eq!(mime_type, "image/png");
|
||||
assert_eq!(is_paste, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_create_ai_providers_table() {
|
||||
let conn = setup_test_db();
|
||||
|
||||
let count: i64 = conn
|
||||
.query_row(
|
||||
"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='ai_providers'",
|
||||
[],
|
||||
|r| r.get(0),
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(count, 1);
|
||||
|
||||
let mut stmt = conn.prepare("PRAGMA table_info(ai_providers)").unwrap();
|
||||
let columns: Vec<String> = stmt
|
||||
.query_map([], |row| row.get::<_, String>(1))
|
||||
.unwrap()
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.unwrap();
|
||||
|
||||
assert!(columns.contains(&"id".to_string()));
|
||||
assert!(columns.contains(&"name".to_string()));
|
||||
assert!(columns.contains(&"provider_type".to_string()));
|
||||
assert!(columns.contains(&"api_url".to_string()));
|
||||
assert!(columns.contains(&"encrypted_api_key".to_string()));
|
||||
assert!(columns.contains(&"model".to_string()));
|
||||
assert!(columns.contains(&"max_tokens".to_string()));
|
||||
assert!(columns.contains(&"temperature".to_string()));
|
||||
assert!(columns.contains(&"custom_endpoint_path".to_string()));
|
||||
assert!(columns.contains(&"custom_auth_header".to_string()));
|
||||
assert!(columns.contains(&"custom_auth_prefix".to_string()));
|
||||
assert!(columns.contains(&"api_format".to_string()));
|
||||
assert!(columns.contains(&"user_id".to_string()));
|
||||
assert!(columns.contains(&"use_datastore_upload".to_string()));
|
||||
assert!(columns.contains(&"created_at".to_string()));
|
||||
assert!(columns.contains(&"updated_at".to_string()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_store_and_retrieve_ai_provider() {
|
||||
let conn = setup_test_db();
|
||||
|
||||
conn.execute(
|
||||
"INSERT INTO ai_providers (id, name, provider_type, api_url, encrypted_api_key, model)
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6)",
|
||||
rusqlite::params![
|
||||
"test-provider-1",
|
||||
"My OpenAI",
|
||||
"openai",
|
||||
"https://api.openai.com/v1",
|
||||
"encrypted_key_123",
|
||||
"gpt-4o"
|
||||
],
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let (name, provider_type, api_url, encrypted_key, model): (String, String, String, String, String) = conn
|
||||
.query_row(
|
||||
"SELECT name, provider_type, api_url, encrypted_api_key, model FROM ai_providers WHERE name = ?1",
|
||||
["My OpenAI"],
|
||||
|r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?, r.get(4)?)),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(name, "My OpenAI");
|
||||
assert_eq!(provider_type, "openai");
|
||||
assert_eq!(api_url, "https://api.openai.com/v1");
|
||||
assert_eq!(encrypted_key, "encrypted_key_123");
|
||||
assert_eq!(model, "gpt-4o");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"productName": "Troubleshooting and RCA Assistant",
|
||||
"version": "0.2.10",
|
||||
"version": "0.2.50",
|
||||
"identifier": "com.trcaa.app",
|
||||
"build": {
|
||||
"frontendDist": "../dist",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user