Skip to content

Commit 71a4bf7

Browse files
authored
Merge pull request #32 from codesoda/worktree-ci-workflow
ci: add CI workflow for PRs and pushes to main
2 parents 3dc5670 + 87fc253 commit 71a4bf7

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
rust:
14+
name: Rust checks
15+
runs-on: ubuntu-latest
16+
env:
17+
CARGO_TERM_COLOR: always
18+
CARGO_INCREMENTAL: "0"
19+
RUSTFLAGS: "-D warnings"
20+
RUST_BACKTRACE: 1
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: dtolnay/rust-toolchain@stable
25+
with:
26+
components: rustfmt, clippy
27+
28+
- uses: Swatinem/rust-cache@v2
29+
with:
30+
cache-on-failure: true
31+
32+
- name: Check formatting
33+
run: cargo fmt --check
34+
35+
- name: Clippy
36+
run: cargo clippy --all-targets -- -D warnings
37+
38+
- name: Build
39+
run: cargo build --all-targets
40+
41+
- name: Test
42+
run: cargo test

src/claude_code.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -635,15 +635,15 @@ mod tests {
635635
#[test]
636636
fn stream_turn_iterator_with_mock_process() {
637637
// Simulate stdout with assistant + result events
638-
let child = Command::new("sh")
638+
let mut child = Command::new("sh")
639639
.arg("-c")
640640
.arg(r#"echo '{"type":"system","subtype":"init"}'; echo '{"type":"assistant","message":{"content":[{"type":"text","text":"Hello"}]}}'; echo '{"type":"result","result":"Hello","subtype":"success"}';"#)
641641
.stdout(Stdio::piped())
642642
.stderr(Stdio::piped())
643643
.spawn()
644644
.unwrap();
645645

646-
let stdout = child.stdout.unwrap();
646+
let stdout = child.stdout.take().unwrap();
647647
let mut reader = BufReader::new(stdout);
648648

649649
// Skip system init
@@ -666,19 +666,20 @@ mod tests {
666666
}
667667

668668
assert_eq!(collected, vec!["Hello"]);
669+
let _ = child.wait();
669670
}
670671

671672
#[test]
672673
fn stream_turn_iterator_reports_error_events() {
673-
let child = Command::new("sh")
674+
let mut child = Command::new("sh")
674675
.arg("-c")
675676
.arg(r#"echo '{"type":"error","error":"something went wrong"}'"#)
676677
.stdout(Stdio::piped())
677678
.stderr(Stdio::piped())
678679
.spawn()
679680
.unwrap();
680681

681-
let stdout = child.stdout.unwrap();
682+
let stdout = child.stdout.take().unwrap();
682683
let mut reader = BufReader::new(stdout);
683684

684685
let mut iter = StreamTurnIterator {
@@ -694,19 +695,20 @@ mod tests {
694695
matches!(item, Err(ProviderError::StreamError(ref msg)) if msg == "something went wrong"),
695696
"expected StreamError, got: {item:?}"
696697
);
698+
let _ = child.wait();
697699
}
698700

699701
#[test]
700702
fn stream_turn_iterator_skips_non_json_lines() {
701-
let child = Command::new("sh")
703+
let mut child = Command::new("sh")
702704
.arg("-c")
703705
.arg(r#"echo 'not json'; echo '{"type":"assistant","message":{"content":[{"type":"text","text":"text"}]}}'; echo '{"type":"result","result":"text","subtype":"success"}';"#)
704706
.stdout(Stdio::piped())
705707
.stderr(Stdio::piped())
706708
.spawn()
707709
.unwrap();
708710

709-
let stdout = child.stdout.unwrap();
711+
let stdout = child.stdout.take().unwrap();
710712
let mut reader = BufReader::new(stdout);
711713

712714
let mut iter = StreamTurnIterator {
@@ -725,6 +727,7 @@ mod tests {
725727
}
726728

727729
assert_eq!(texts, vec!["text"]);
730+
let _ = child.wait();
728731
}
729732

730733
#[test]

src/report.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ mod tests {
338338
instruction: instruction.to_string(),
339339
source_file: PathBuf::from("tests/login.test.toml"),
340340
result: StepResult::Verdict(StepVerdict::Ok),
341-
transcript: format!("Checked.\nRESULT OK"),
341+
transcript: "Checked.\nRESULT OK".to_string(),
342342
log_events: vec![],
343343
evidence_refs: vec![],
344344
duration: Duration::from_millis(1500),

0 commit comments

Comments
 (0)