Skip to content

add experimental self-update functionality#62

Merged
Panaetius merged 1 commit into
mainfrom
self-update
Feb 19, 2026
Merged

add experimental self-update functionality#62
Panaetius merged 1 commit into
mainfrom
self-update

Conversation

@Panaetius
Copy link
Copy Markdown
Member

@Panaetius Panaetius commented Feb 19, 2026

User description

I had to change the release artifact names to match what the self-updating library expects.
Command is currently hidden for testing


PR Type

Enhancement


Description

  • Adds experimental self-update functionality

  • Updates release artifact naming for compatibility

  • Integrates self-update crate with GitHub backend

  • Hides update command for testing purposes


Diagram Walkthrough

flowchart LR
  A["CLI Command: Update"] -- "Spawns background task" --> B["Self-update Logic"]
  B -- "Uses GitHub backend" --> C["Fetches latest release"]
  C -- "Updates binary" --> D["Prints status"]
Loading

File Walkthrough

Relevant files
Enhancement
app.rs
CLI Update Command Addition                                                           

coman/src/cli/app.rs

  • Added Update command to CLI enum
  • Set command as hidden for testing purposes
  • Maintained existing command structure
+2/-0     
main.rs
Self-update Implementation                                                             

coman/src/main.rs

  • Imported self_update crate
  • Implemented update() function using GitHub backend
  • Integrated update logic into CLI command handling
  • Spawned update task in async context
+20/-0   
Configuration changes
release.yaml
Release Artifact Naming Update                                                     

.github/workflows/release.yaml

  • Updated release artifact naming convention
  • Standardized naming across platforms
  • Ensured compatibility with self-update library
  • Maintained existing workflow structure
+4/-4     
Dependencies
Cargo.toml
Add Self-Update Dependency                                                             

coman/Cargo.toml

  • Added self_update dependency with archive support
  • Included necessary features for tar and zip archives
  • Maintained existing dependencies
+1/-0     

@Panaetius Panaetius requested a review from a team as a code owner February 19, 2026 10:16
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Update Function Error Handling

The update() function uses unwrap() which can cause a panic if the self-update process fails. It should handle errors more gracefully to prevent unexpected crashes.

fn update() -> Result<()> {
    let status = self_update::backends::github::Update::configure()
        .repo_owner("SwissDataScienceCenter")
        .repo_name("coman")
        .bin_name("coman")
        .show_download_progress(true)
        .current_version(cargo_crate_version!())
        .build()?
        .update()?;
    println!("Update status: `{}`", status.version());
    Ok(())
}
Async Task Spawning

The update command spawns a blocking task but doesn't handle potential panics or errors from the spawned task properly. Consider using handle.await or similar mechanisms to catch and report errors.

CliCommands::Update => {
    tokio::task::spawn_blocking(move || {
        update().unwrap();
    })
    .await?
}

@github-actions
Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle update errors gracefully

The update() function call in the Update command handler uses unwrap() which can
cause a panic if the update fails. This should be handled more gracefully to prevent
unexpected crashes and provide better error reporting to the user.

coman/src/main.rs [71-76]

 CliCommands::Version => println!("{}", version()),
 CliCommands::Update => {
     tokio::task::spawn_blocking(move || {
-        update().unwrap();
+        if let Err(e) = update() {
+            eprintln!("Failed to update: {}", e);
+        }
     })
     .await?
 }
Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies a potential crash risk due to unwrap() in the update() call, which could lead to an ungraceful application termination. Handling the error with eprintln! provides better user feedback and prevents panics.

Medium
General
Improve update status messaging

The update function does not provide feedback to the user about the success or
failure of the update process beyond printing the version. Consider adding more
informative messages to indicate whether the update was successful, skipped, or
failed.

coman/src/main.rs [383-394]

 fn update() -> Result<()> {
     let status = self_update::backends::github::Update::configure()
         .repo_owner("SwissDataScienceCenter")
         .repo_name("coman")
         .bin_name("coman")
         .show_download_progress(true)
         .current_version(cargo_crate_version!())
         .build()?
         .update()?;
-    println!("Update status: `{}`", status.version());
+    if status.updated() {
+        println!("Successfully updated to version: `{}`", status.version());
+    } else {
+        println!("Already up-to-date at version: `{}`", status.version());
+    }
     Ok(())
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion enhances user experience by providing clearer feedback on whether the update succeeded or was skipped. While useful, it's a moderate improvement that doesn't address critical functionality or safety concerns.

Medium
Make update command visible

The Update command is marked as hidden, which prevents users from discovering it
easily. Since this is an experimental feature, consider making it visible with
appropriate documentation or warnings to inform users about its experimental nature.

coman/src/cli/app.rs [35-40]

 #[derive(Subcommand, Debug)]
 #[allow(clippy::large_enum_variant)]
 pub enum CliCommands {
     #[clap(about = "Show version and config file locations")]
     Version,
-    #[clap(about = "Self-update coman. Experimental", hide = true)]
+    #[clap(about = "Self-update coman. Experimental")]
     Update,
     #[clap(about = "Subcommands related to CSCS")]
     Cscs {
Suggestion importance[1-10]: 5

__

Why: Making the Update command visible improves discoverability of the feature. However, since it's marked as experimental, hiding it might be intentional for user experience reasons. This change has a limited impact on core functionality.

Low

Comment thread coman/src/cli/app.rs
#[clap(about = "Show version and config file locations")]
Version,
#[clap(about = "Self-update coman. Experimental", hide = true)]
Update,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Update command is marked as experimental and hidden, which might cause confusion for users expecting it to be available.

#ai-review-inline

Comment thread coman/Cargo.toml
tokio-duplex = "1.0.1"
sysinfo = "0.38.0"
bytesize = "2.3.1"
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added self_update crate with archive features, ensure these features are necessary for the intended use case.

Suggested change
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }
self_update = { version = "0.42.0", features = ["archive-tar", "archive-zip"] }

#ai-review-inline

Comment thread coman/src/main.rs
match args.command {
Some(command) => match command {
CliCommands::Version => println!("{}", version()),
CliCommands::Update => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the update task instead of using unwrap().

Suggested change
CliCommands::Update => {
tokio::task::spawn_blocking(move || {
if let Err(e) = update() {
eprintln!("Update failed: {}", e);
}
}).await?

#ai-review-inline

Comment thread coman/src/main.rs
])))
}

fn update() -> Result<()> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update function should handle errors more gracefully instead of panicking with unwrap().

Suggested change
fn update() -> Result<()> {
fn update() -> Result<()> {
let status = self_update::backends::github::Update::configure()
.repo_owner("SwissDataScienceCenter")
.repo_name("coman")
.bin_name("coman")
.show_download_progress(true)
.current_version(cargo_crate_version!())
.build()?;
let status = status.update()?;
println!("Update status: `{}`", status.version());
Ok(())
}

#ai-review-inline

target: aarch64-pc-windows-msvc
bin: coman.exe
name: coman-Windows-aarch64.zip
name: coman-aarch64-pc-windows-msvc.zip
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Windows aarch64 artifact has been updated for consistency.

Suggested change
name: coman-aarch64-pc-windows-msvc.zip
name: coman-aarch64-pc-windows-msvc.zip

#ai-review-inline

target: x86_64-apple-darwin
bin: coman
name: coman-Darwin-x86_64.tar.gz
name: coman-x86_64-apple-darwin.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the macOS x86_64 artifact has been updated for consistency.

Suggested change
name: coman-x86_64-apple-darwin.tar.gz
name: coman-x86_64-apple-darwin.tar.gz

#ai-review-inline

target: x86_64-unknown-linux-musl
bin: coman
name: coman-Linux-x86_64-musl.tar.gz
name: coman-x86_64-unknown-linux-musl.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Linux x86_64 artifact has been updated for consistency.

Suggested change
name: coman-x86_64-unknown-linux-musl.tar.gz
name: coman-x86_64-unknown-linux-musl.tar.gz

#ai-review-inline

target: aarch64-unknown-linux-musl
bin: coman
name: coman-Linux-aarch64-musl.tar.gz
name: coman-aarch64-unknown-linux-musl.tar.gz
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The naming convention for the Linux aarch64 artifact has been updated for consistency.

Suggested change
name: coman-aarch64-unknown-linux-musl.tar.gz
name: coman-aarch64-unknown-linux-musl.tar.gz

#ai-review-inline

@Panaetius Panaetius merged commit 8f63671 into main Feb 19, 2026
2 checks passed
@Panaetius Panaetius deleted the self-update branch February 19, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant