From 9c8f67a3101d67b5477c02a5776cb2c29f6daba1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 15 Feb 2021 10:41:50 +0100 Subject: Fix: Remove job input/output artifacts tables Signed-off-by: Matthias Beyer Fixes: b95c3f21a2a9406d45a0e421a11f6425291f1182 ("Remove job input/output artifacts tables") --- src/schema.rs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/schema.rs b/src/schema.rs index 2bcb927..2e2895b 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -43,22 +43,6 @@ table! { } } -table! { - job_input_artifacts (id) { - id -> Int4, - job_id -> Int4, - artifact_id -> Int4, - } -} - -table! { - job_output_artifacts (id) { - id -> Int4, - job_id -> Int4, - artifact_id -> Int4, - } -} - table! { jobs (id) { id -> Int4, @@ -119,10 +103,6 @@ table! { joinable!(artifacts -> jobs (job_id)); joinable!(job_envs -> envvars (env_id)); joinable!(job_envs -> jobs (job_id)); -joinable!(job_input_artifacts -> artifacts (artifact_id)); -joinable!(job_input_artifacts -> jobs (job_id)); -joinable!(job_output_artifacts -> artifacts (artifact_id)); -joinable!(job_output_artifacts -> jobs (job_id)); joinable!(jobs -> endpoints (endpoint_id)); joinable!(jobs -> images (image_id)); joinable!(jobs -> packages (package_id)); @@ -142,8 +122,6 @@ allow_tables_to_appear_in_same_query!( githashes, images, job_envs, - job_input_artifacts, - job_output_artifacts, jobs, packages, release_stores, -- cgit v1.2.3 From a282aa78f8ef025cc4d870788a5e7e8ae623f57a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:22:46 +0100 Subject: Add more error context Signed-off-by: Matthias Beyer --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 9cfdfe2..bb5dd88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,7 +87,9 @@ async fn main() -> Result<()> { let app = cli::cli(); let cli = app.get_matches(); - let repo = git2::Repository::discover(PathBuf::from("."))?; + let repo = git2::Repository::discover(PathBuf::from(".")) + .context("Loading the git repository") + .context("Butido must be executed within the package repository")?; let repo_path = repo .workdir() .ok_or_else(|| anyhow!("Not a repository with working directory. Cannot do my job!"))?; @@ -109,7 +111,8 @@ async fn main() -> Result<()> { let load_repo = || -> Result { let bar = progressbars.bar(); - let repo = Repository::load(&repo_path, &bar)?; + let repo = Repository::load(&repo_path, &bar) + .context("Loading the repository")?; bar.finish_with_message("Repository loading finished"); Ok(repo) }; -- cgit v1.2.3 From 04205d2b5201af21186cc257b4019752b1d1173d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:24:59 +0100 Subject: Add more error context if CLI command fails Signed-off-by: Matthias Beyer --- src/main.rs | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/src/main.rs b/src/main.rs index bb5dd88..b93df83 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,6 +51,7 @@ extern crate diesel; use std::path::PathBuf; use anyhow::anyhow; +use anyhow::Context; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; @@ -135,65 +136,92 @@ async fn main() -> Result<()> { repo, &repo_path, ) - .await? + .await + .context("build command failed")? } Some(("what-depends", matches)) => { let repo = load_repo()?; - crate::commands::what_depends(matches, &config, repo).await? + crate::commands::what_depends(matches, &config, repo) + .await + .context("what-depends command failed")? } Some(("dependencies-of", matches)) => { let repo = load_repo()?; - crate::commands::dependencies_of(matches, &config, repo).await? + crate::commands::dependencies_of(matches, &config, repo) + .await + .context("dependencies-of command failed")? } Some(("versions-of", matches)) => { let repo = load_repo()?; - crate::commands::versions_of(matches, repo).await? + crate::commands::versions_of(matches, repo) + .await + .context("versions-of command failed")? } Some(("env-of", matches)) => { let repo = load_repo()?; - crate::commands::env_of(matches, repo).await? + crate::commands::env_of(matches, repo) + .await + .context("env-of command failed")? } Some(("find-artifact", matches)) => { let repo = load_repo()?; let conn = crate::db::establish_connection(db_connection_config)?; - crate::commands::find_artifact(matches, &config, progressbars, repo, conn).await? + crate::commands::find_artifact(matches, &config, progressbars, repo, conn) + .await + .context("find-artifact command failed")? } Some(("find-pkg", matches)) => { let repo = load_repo()?; - crate::commands::find_pkg(matches, &config, repo).await? + crate::commands::find_pkg(matches, &config, repo) + .await + .context("find-pkg command failed")? } Some(("source", matches)) => { let repo = load_repo()?; - crate::commands::source(matches, &config, repo, progressbars).await? + crate::commands::source(matches, &config, repo, progressbars) + .await + .context("source command failed")? } Some(("release", matches)) => { - crate::commands::release(db_connection_config, &config, matches).await? + crate::commands::release(db_connection_config, &config, matches) + .await + .context("release command failed")? } Some(("lint", matches)) => { let repo = load_repo()?; - crate::commands::lint(&repo_path, matches, progressbars, &config, repo).await? + crate::commands::lint(&repo_path, matches, progressbars, &config, repo) + .await + .context("lint command failed")? } Some(("tree-of", matches)) => { let repo = load_repo()?; - crate::commands::tree_of(matches, repo, progressbars).await? + crate::commands::tree_of(matches, repo, progressbars) + .await + .context("tree-of command failed")? } Some(("metrics", _)) => { let repo = load_repo()?; let conn = crate::db::establish_connection(db_connection_config)?; - crate::commands::metrics(&repo_path, &config, repo, conn).await? + crate::commands::metrics(&repo_path, &config, repo, conn) + .await + .context("metrics command failed")? } - Some(("endpoint", matches)) => crate::commands::endpoint(matches, &config, progressbars).await?, + Some(("endpoint", matches)) => { + crate::commands::endpoint(matches, &config, progressbars) + .await + .context("endpoint command failed")? + }, Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), None => return Err(anyhow!("No subcommand")), } -- cgit v1.2.3 From 6a188e26815579a6de5ce4eee8271d3801e80f63 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:28:04 +0100 Subject: Add more verbose error output if no subcommand is given Signed-off-by: Matthias Beyer --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index b93df83..dc00524 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,7 @@ use anyhow::Context; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; +use logcrate::error; use rand as _; // Required to make lints happy use aquamarine as _; // doc-helper crate use funty as _; // doc-helper crate @@ -222,7 +223,11 @@ async fn main() -> Result<()> { .await .context("endpoint command failed")? }, - Some((other, _)) => return Err(anyhow!("Unknown subcommand: {}", other)), + Some((other, _)) => { + error!("Unknown subcommand: {}", other); + error!("Use --help to find available subcommands"); + return Err(anyhow!("Unknown subcommand: {}", other)) + }, None => return Err(anyhow!("No subcommand")), } -- cgit v1.2.3 From fb755aeeb60e5df4ba35671d593d602438a2ab3b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:31:51 +0100 Subject: Add more verbose error output if no subcommand is given Signed-off-by: Matthias Beyer --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index dc00524..bcd3631 100644 --- a/src/main.rs +++ b/src/main.rs @@ -228,7 +228,11 @@ async fn main() -> Result<()> { error!("Use --help to find available subcommands"); return Err(anyhow!("Unknown subcommand: {}", other)) }, - None => return Err(anyhow!("No subcommand")), + None => { + error!("No subcommand."); + error!("Use --help to find available subcommands"); + return Err(anyhow!("No subcommand")) + }, } Ok(()) -- cgit v1.2.3 From a6ca00f65d37d6a4326137ba675abb57eb854492 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:35:14 +0100 Subject: Add missing about message for release subcommand Signed-off-by: Matthias Beyer --- src/cli.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cli.rs b/src/cli.rs index 22aae6d..1473164 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -695,6 +695,7 @@ pub fn cli<'a>() -> App<'a> { .subcommand(App::new("release") .version(crate_version!()) + .about("Manage artifact releases") .subcommand(App::new("rm") .version(crate_version!()) .about("Remove release artifacts") -- cgit v1.2.3 From fce4f0ed532b8d2753199f88cdaaa41dcbbf80f4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:39:24 +0100 Subject: Fix: Make error message more readable for humans Signed-off-by: Matthias Beyer Tested-by: Matthias Beyer --- src/commands/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/build.rs b/src/commands/build.rs index 9880552..a7d4486 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -88,7 +88,7 @@ pub async fn build( return Err(anyhow!( "Requested build image {} is not in the configured images", image_name )) - .with_context(|| anyhow!("Available images: {:?}", config.docker().images())) + .with_context(|| anyhow!("Available images: {}", config.docker().images().iter().join(", "))) .with_context(|| anyhow!("Image present verification failed")) .map_err(Error::from); } -- cgit v1.2.3 From 7a77343ec3ddb99fbbc4b46d2dd6b0dce6c80d60 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 11 Mar 2021 08:53:04 +0100 Subject: Add more verbose error if ./. is not a git repository Signed-off-by: Matthias Beyer --- src/main.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.rs b/src/main.rs index bcd3631..4c7c630 100644 --- a/src/main.rs +++ b/src/main.rs @@ -52,6 +52,7 @@ use std::path::PathBuf; use anyhow::anyhow; use anyhow::Context; +use anyhow::Error; use anyhow::Result; use clap::ArgMatches; use logcrate::debug; @@ -90,6 +91,10 @@ async fn main() -> Result<()> { let cli = app.get_matches(); let repo = git2::Repository::discover(PathBuf::from(".")) + .map_err(|e| match e.code() { + git2::ErrorCode::NotFound => anyhow!("Failed to load the git repository from ./."), + _ => Error::from(e), + }) .context("Loading the git repository") .context("Butido must be executed within the package repository")?; let repo_path = repo -- cgit v1.2.3