Skip to content

Commit

Permalink
Try a new way, with testing fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoverbear committed Feb 9, 2024
1 parent 8f02f1e commit 6b13c5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ impl FlakeHubPushCli {
skip_all,
)]
pub(crate) async fn execute(self) -> color_eyre::Result<std::process::ExitCode> {
return Err(Error::Unauthorized("Bean salad\nLook a newline".into()))?;

tracing::trace!(?self, "Executing");
let Self {
host,
Expand Down
8 changes: 8 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ impl Error {
Self::Unauthorized(_) | Self::Conflict { .. } => false,
}
}
pub(crate) fn maybe_github_actions_annotation(&self) {
if std::env::var("GITHUB_ACTIONS").is_ok() {
match self {
Error::Unauthorized(message) => println!("::error title=Unauthorized::<<EOF\n{message}\nEOF"),
Error::Conflict { .. } => println!("::error title=Conflict::<<EOF\n{self}\nEOF"),
}
}
}
}
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(unused_variables, dead_code, unreachable_code)]
use std::{fmt::Display, io::IsTerminal};

use clap::Parser;
Expand Down Expand Up @@ -34,7 +35,16 @@ async fn main() -> color_eyre::Result<std::process::ExitCode> {

let cli = cli::FlakeHubPushCli::parse();
cli.instrumentation.setup()?;
cli.execute().await

match cli.execute().await {
Ok(exit) => Ok(exit),
Err(error) => {
if let Some(known_error) = error.downcast_ref::<Error>() {
known_error.maybe_github_actions_annotation()
}
Err(error)
}
}
}

#[derive(Debug, Clone, Copy, clap::ValueEnum, serde::Serialize, serde::Deserialize)]
Expand Down

0 comments on commit 6b13c5f

Please sign in to comment.