Add CI workflow and tighten clippy/justfile
GitHub Actions workflow runs fmt check, clippy with -D warnings, and
tests on push to main and PRs. Justfile updated to match: added test
recipe, --workspace flags, and -D warnings to clippy. Fixed six
collapsible-if warnings clippy caught.

Assisted-by: Claude Opus 4.6 via pi
change wtsuroyutknuvwzkmvvormvqyrqxolvk
commit 1f92d40853d5f8722d9b75f8c35493c25019b4d7
author Alpha Chen <alpha@kejadlen.dev>
date
parent ztnwxork
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..d602983
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,16 @@
+name: CI
+
+on:
+  push:
+    branches: [main]
+  pull_request:
+
+jobs:
+  ci:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - run: rustup component add clippy rustfmt
+      - run: cargo fmt --all --check
+      - run: cargo clippy --workspace -- -D warnings
+      - run: cargo test --workspace
diff --git a/.ranger/ranger.db b/.ranger/ranger.db
new file mode 100644
index 0000000..509a99f
Binary files /dev/null and b/.ranger/ranger.db differ
diff --git a/justfile b/justfile
index 2a3ce58..d77df3d 100644
--- a/justfile
+++ b/justfile
@@ -1,13 +1,16 @@
-default: check fmt clippy
+default: check fmt clippy test
 
 check:
-    cargo check
+    cargo check --workspace
 
 fmt:
     cargo fmt --all
 
 clippy:
-    cargo clippy
+    cargo clippy --workspace -- -D warnings
+
+test:
+    cargo test --workspace
 
 install:
     cargo install --locked --path .
diff --git a/src/main.rs b/src/main.rs
index a4a8a26..fe45972 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -180,20 +180,20 @@ fn cmd_config(workspace: PathBuf) -> Result<()> {
     let jj_config = xdg::BaseDirectories::with_prefix("jj").get_config_home();
     let ranger_data = xdg::BaseDirectories::with_prefix("ranger").get_data_home();
 
-    if let Some(ref dir) = git_config {
-        if dir.is_dir() {
-            mounts.push((dir, "/root/.config/git (ro)"));
-        }
+    if let Some(ref dir) = git_config
+        && dir.is_dir()
+    {
+        mounts.push((dir, "/root/.config/git (ro)"));
     }
-    if let Some(ref dir) = jj_config {
-        if dir.is_dir() {
-            mounts.push((dir, "/root/.config/jj (ro)"));
-        }
+    if let Some(ref dir) = jj_config
+        && dir.is_dir()
+    {
+        mounts.push((dir, "/root/.config/jj (ro)"));
     }
-    if let Some(ref dir) = ranger_data {
-        if dir.is_dir() {
-            mounts.push((dir, "/root/.local/share/ranger"));
-        }
+    if let Some(ref dir) = ranger_data
+        && dir.is_dir()
+    {
+        mounts.push((dir, "/root/.local/share/ranger"));
     }
 
     for (source, target) in mounts {
@@ -206,10 +206,7 @@ fn cmd_config(workspace: PathBuf) -> Result<()> {
         println!("  ✓ {}", dirs.custom_dockerfile.display());
     } else {
         println!("  embedded (default)");
-        println!(
-            "  ✗ {} (not found)",
-            dirs.custom_dockerfile.display()
-        );
+        println!("  ✗ {} (not found)", dirs.custom_dockerfile.display());
     }
 
     Ok(())
@@ -375,20 +372,20 @@ fn generate_compose(
         format!("{}:/workspace", workspace.display()),
     ];
 
-    if let Some(dir) = xdg::BaseDirectories::with_prefix("git").get_config_home() {
-        if dir.is_dir() {
-            volumes.push(format!("{}:/root/.config/git:ro", dir.display()));
-        }
+    if let Some(dir) = xdg::BaseDirectories::with_prefix("git").get_config_home()
+        && dir.is_dir()
+    {
+        volumes.push(format!("{}:/root/.config/git:ro", dir.display()));
     }
-    if let Some(dir) = xdg::BaseDirectories::with_prefix("jj").get_config_home() {
-        if dir.is_dir() {
-            volumes.push(format!("{}:/root/.config/jj:ro", dir.display()));
-        }
+    if let Some(dir) = xdg::BaseDirectories::with_prefix("jj").get_config_home()
+        && dir.is_dir()
+    {
+        volumes.push(format!("{}:/root/.config/jj:ro", dir.display()));
     }
-    if let Some(dir) = xdg::BaseDirectories::with_prefix("ranger").get_data_home() {
-        if dir.is_dir() {
-            volumes.push(format!("{}:/root/.local/share/ranger", dir.display()));
-        }
+    if let Some(dir) = xdg::BaseDirectories::with_prefix("ranger").get_data_home()
+        && dir.is_dir()
+    {
+        volumes.push(format!("{}:/root/.local/share/ranger", dir.display()));
     }
 
     let config = ComposeConfig {