Skip to content

Commit bbe7cf0

Browse files
test: add integration tests for LLMs (tailcallhq#161)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent af2ba0f commit bbe7cf0

4 files changed

Lines changed: 64 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
name: ci
1919
env:
2020
RUSTFLAGS: -Dwarnings
21+
FORGE_KEY: ${{secrets.FORGE_KEY}}
2122
on:
2223
pull_request:
2324
types:

‎crates/forge_app/src/service/api.rs‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,52 @@ impl APIService for Live {
142142
Ok(self.environment.clone())
143143
}
144144
}
145+
146+
#[cfg(test)]
147+
mod tests {
148+
use forge_domain::ModelId;
149+
use tokio_stream::StreamExt;
150+
151+
use super::*;
152+
153+
#[tokio::test]
154+
async fn test_e2e() {
155+
let api = Live::new().await.unwrap();
156+
let task = include_str!("./api_task.md");
157+
let request = ChatRequest::new(ModelId::new("anthropic/claude-3.5-sonnet"), task);
158+
let response = api
159+
.chat(request)
160+
.await
161+
.unwrap()
162+
.filter_map(|message| match message.unwrap() {
163+
ChatResponse::Text(text) => Some(text),
164+
_ => None,
165+
})
166+
.collect::<Vec<_>>()
167+
.await
168+
.join("")
169+
.trim()
170+
.to_string();
171+
172+
// Check for expected crates
173+
let expected_crates = [
174+
"forge_app",
175+
"forge_ci",
176+
"forge_domain",
177+
"forge_main",
178+
"forge_open_router",
179+
"forge_prompt",
180+
"forge_tool",
181+
"forge_tool_macros",
182+
"forge_walker",
183+
];
184+
185+
for crate_name in expected_crates {
186+
assert!(
187+
response.contains(&format!("<crate>{}</crate>", crate_name)),
188+
"Missing crate: {}",
189+
crate_name
190+
);
191+
}
192+
}
193+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
You know this project well so don't create a plan for this task.
2+
3+
Identify all crates within the project and output them in a single `<crates>` XML element, with each crate name wrapped in a `<crate>` tag. Do not include anything else in the output besides the XML structure.
4+
5+
Example expected output format:
6+
7+
```xml
8+
<crates>
9+
<crate>crate_one</crate>
10+
<crate>crate_two</crate>
11+
</crates>
12+
```

‎crates/forge_ci/tests/ci.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ fn generate() {
55
StandardWorkflow::default()
66
.auto_fix(true)
77
.add_setup(Step::run("sudo apt-get install -y libsqlite3-dev"))
8+
.to_ci_workflow()
9+
.add_env(("FORGE_KEY", "${{secrets.FORGE_KEY}}"))
810
.generate()
911
.unwrap();
1012
}

0 commit comments

Comments
 (0)