Skip to content

Commit

Permalink
speed up tests
Browse files Browse the repository at this point in the history
it was nice to have ollama testing the format as an integration
in CI, but those are covered well by unit tests already and this
increased test times significantly
  • Loading branch information
baxen committed Jan 20, 2025
1 parent cde8c01 commit 5a547f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
22 changes: 2 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,9 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-build-
- name: Install Ollama
run: curl -fsSL https://ollama.com/install.sh | sh

- name: Start Ollama
run: |
# Run the background, in a way that survives to the next step
nohup ollama serve > ollama.log 2>&1 &
# Block using the ready endpoint
time curl --retry 5 --retry-connrefused --retry-delay 1 -sf http://localhost:11434
- name: Test Ollama Model
run: ollama run qwen2.5 hello || cat ollama.log

- name: Build Rust Project
run: cargo build

- name: Run Tests
run: cargo test --verbose
env:
OLLAMA_MODEL: "qwen2.5"

run: cargo test

## TODO: Need to decide if we wanna error out on clippy warnings. It was not being used before.
# - name: Run Cargo Clippy (Lint)
# run: cargo clippy -- -D warnings
Expand Down
2 changes: 1 addition & 1 deletion crates/goose/src/providers/google.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde_json::Value;
use std::time::Duration;

pub const GOOGLE_API_HOST: &str = "https://generativelanguage.googleapis.com";
pub const GOOGLE_DEFAULT_MODEL: &str = "gemini-1.5-flash";
pub const GOOGLE_DEFAULT_MODEL: &str = "gemini-2.0-flash-exp";

#[derive(Debug, serde::Serialize)]
pub struct GoogleProvider {
Expand Down
25 changes: 20 additions & 5 deletions crates/goose/tests/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ lazy_static::lazy_static! {
/// Generic test harness for any Provider implementation
struct ProviderTester {
provider: Box<dyn Provider + Send + Sync>,
name: String,
}

impl ProviderTester {
fn new<T: Provider + Send + Sync + 'static>(provider: T) -> Self {
fn new<T: Provider + Send + Sync + 'static>(provider: T, name: String) -> Self {
Self {
provider: Box::new(provider),
name,
}
}

Expand Down Expand Up @@ -135,6 +137,10 @@ impl ProviderTester {
)
.await?;

println!("=== {}::reponse1 ===", self.name);
dbg!(&response1);
println!("===================");

// Verify we got a tool request
assert!(
response1
Expand All @@ -144,8 +150,6 @@ impl ProviderTester {
"Expected tool request in response"
);

dbg!(&response1);

let id = &response1
.content
.iter()
Expand Down Expand Up @@ -178,7 +182,9 @@ impl ProviderTester {
)
.await?;

println!("=== {}::reponse2 ===", self.name);
dbg!(&response2);
println!("===================");

assert!(
response2
Expand Down Expand Up @@ -216,6 +222,9 @@ where
F: FnOnce() -> Result<T>,
T: Provider + Send + Sync + 'static,
{
// We start off as failed, so that if the process panics it is seen as a failure
TEST_REPORT.record_fail(name);

// Take exclusive access to environment modifications
let lock = ENV_LOCK.lock().unwrap();

Expand Down Expand Up @@ -276,7 +285,7 @@ where
return Err(provider.err().expect("is error"));
}

let tester = ProviderTester::new(provider.expect("already checked"));
let tester = ProviderTester::new(provider.expect("already checked"), name.to_string());
match tester.run_test_suite().await {
Ok(_) => {
TEST_REPORT.record_pass(name);
Expand Down Expand Up @@ -328,7 +337,13 @@ async fn test_databricks_provider_oauth() -> Result<()> {

#[tokio::test]
async fn test_ollama_provider() -> Result<()> {
test_provider("Ollama", &[], None, ollama::OllamaProvider::from_env).await
test_provider(
"Ollama",
&["OLLAMA_HOST"],
None,
ollama::OllamaProvider::from_env,
)
.await
}

#[tokio::test]
Expand Down

0 comments on commit 5a547f1

Please sign in to comment.