Skip to content

Commit c491aee

Browse files
authored
Merge pull request #533 from danshapiro/chore/clippy-debt
chore: zero out workspace clippy debt + add clippy CI guard
2 parents 4835de6 + f44054f commit c491aee

11 files changed

Lines changed: 1001 additions & 82 deletions

File tree

.github/workflows/rust-clippy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Rust Clippy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read
11+
12+
concurrency:
13+
group: rust-clippy-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
clippy:
18+
runs-on: ubuntu-latest
19+
timeout-minutes: 30
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
# Pinned toolchain (NOT @stable): keeps green-local <=> green-CI deterministic.
24+
# Current stable (1.97.x) already adds default-warn lints this branch was not
25+
# validated against. Bump this pin deliberately: update the version, re-run the
26+
# gate locally on that toolchain, fix new lints in the same PR.
27+
- uses: dtolnay/rust-toolchain@master
28+
with:
29+
toolchain: 1.96.0
30+
components: clippy, rustfmt
31+
32+
- uses: Swatinem/rust-cache@v2
33+
34+
# freshell-tauri (Tauri v2 / WRY) needs GTK+WebKit system libs to compile
35+
# on ubuntu-latest; installing them keeps the gate truly --workspace.
36+
- name: Install Tauri system dependencies
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y --no-install-recommends \
40+
libwebkit2gtk-4.1-dev libgtk-3-dev libsoup-3.0-dev \
41+
libjavascriptcoregtk-4.1-dev librsvg2-dev \
42+
libayatana-appindicator3-dev pkg-config build-essential
43+
44+
- name: cargo fmt
45+
run: cargo fmt --all --check
46+
47+
- name: cargo clippy (workspace)
48+
run: cargo clippy --workspace --all-targets -- -D warnings
49+
50+
# --all-targets does not imply --all-features: the real-transport
51+
# backends are default-off and would otherwise go unlinted.
52+
- name: cargo clippy (feature-gated backends)
53+
run: |
54+
cargo clippy -p freshell-codex --features real-transport --all-targets -- -D warnings
55+
cargo clippy -p freshell-opencode --features real-transport --all-targets -- -D warnings

crates/freshell-freshagent/src/claude.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ mod tests {
973973
fn sidecar_entry_resolves_to_the_vendored_package() {
974974
// Guard against the dedup tests' concurrent FRESHELL_CLAUDE_SIDECAR mutation
975975
// (see CLAUDE_ENV_LOCK below) -- this test reads the SAME process-global env var.
976-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
976+
let _guard = CLAUDE_ENV_LOCK.blocking_lock();
977977
std::env::remove_var("FRESHELL_CLAUDE_SIDECAR");
978978
// The compile-time path points at the vendored Node package beside this crate.
979979
let entry = sidecar_entry_path();
@@ -994,7 +994,7 @@ mod tests {
994994
/// Serializes every test in this file that mutates process-global env vars
995995
/// (`FRESHELL_CLAUDE_SIDECAR` / `FRESHELL_CLAUDE_NODE`), mirroring codex's
996996
/// `ENV_LOCK` (`codex.rs`).
997-
static CLAUDE_ENV_LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
997+
static CLAUDE_ENV_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
998998

999999
/// A minimal scripted fake claude sidecar (no real `@anthropic-ai/claude-agent-sdk`,
10001000
/// no network, no cost): on `{"type":"create",...}` it appends a marker line to
@@ -1139,7 +1139,7 @@ rl.on('line', (line) => {
11391139
/// SAME session id on the second response.
11401140
#[tokio::test]
11411141
async fn handle_create_duplicate_request_id_reuses_the_session_and_spawns_once() {
1142-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
1142+
let _guard = CLAUDE_ENV_LOCK.lock().await;
11431143
let env = FakeClaudeSidecarEnv::install();
11441144
let (tx, mut rx) = tokio::sync::broadcast::channel::<String>(64);
11451145
let st = FreshClaudeState::new(Arc::new(tx));
@@ -1170,7 +1170,7 @@ rl.on('line', (line) => {
11701170
/// must still spawn at most one sidecar and both resolve to the SAME session.
11711171
#[tokio::test]
11721172
async fn handle_create_concurrent_duplicate_request_id_spawns_at_most_once() {
1173-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
1173+
let _guard = CLAUDE_ENV_LOCK.lock().await;
11741174
let env = FakeClaudeSidecarEnv::install();
11751175
let (tx, mut rx) = tokio::sync::broadcast::channel::<String>(64);
11761176
let st = FreshClaudeState::new(Arc::new(tx));
@@ -1200,7 +1200,7 @@ rl.on('line', (line) => {
12001200
/// Control: DISTINCT requestIds must never dedup against each other.
12011201
#[tokio::test]
12021202
async fn handle_create_distinct_request_ids_create_distinct_sessions() {
1203-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
1203+
let _guard = CLAUDE_ENV_LOCK.lock().await;
12041204
let env = FakeClaudeSidecarEnv::install();
12051205
let (tx, mut rx) = tokio::sync::broadcast::channel::<String>(64);
12061206
let st = FreshClaudeState::new(Arc::new(tx));
@@ -1237,7 +1237,7 @@ rl.on('line', (line) => {
12371237
/// it is dropped rather than mirrored redundantly -- 4 tests, not 5.
12381238
#[tokio::test]
12391239
async fn handle_create_duplicate_after_explicit_kill_creates_a_fresh_session() {
1240-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
1240+
let _guard = CLAUDE_ENV_LOCK.lock().await;
12411241
let env = FakeClaudeSidecarEnv::install();
12421242
let (tx, mut rx) = tokio::sync::broadcast::channel::<String>(64);
12431243
let st = FreshClaudeState::new(Arc::new(tx));
@@ -1330,7 +1330,7 @@ rl.on('line', (line) => {
13301330
/// assert on instead).
13311331
#[tokio::test]
13321332
async fn handle_interrupt_forwards_the_request_to_the_sidecar_for_a_known_session() {
1333-
let _guard = CLAUDE_ENV_LOCK.lock().unwrap_or_else(|e| e.into_inner());
1333+
let _guard = CLAUDE_ENV_LOCK.lock().await;
13341334
let env = FakeClaudeSidecarEnv::install();
13351335
let (tx, mut rx) = tokio::sync::broadcast::channel::<String>(64);
13361336
let st = FreshClaudeState::new(Arc::new(tx));

0 commit comments

Comments
 (0)