ci

CI for all possible combinations of features in Cargo.toml.
git clone https://git.philomathiclife.com/repos/ci
Log | Files | Refs | README

commit 67653c1f63ee2c358ff79a420d2bdab07ea6027c
parent 4a84e6ec6a9e6a008977fa48c761d479285c495c
Author: Zack Newman <zack@philomathiclife.com>
Date:   Sun, 10 Nov 2024 16:23:39 -0700

no longer call cargo upgrade

Diffstat:
MCargo.toml | 4++--
Msrc/main.rs | 107++++++++++++++++++++++++++++++++-----------------------------------------------
2 files changed, 45 insertions(+), 66 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -10,13 +10,13 @@ name = "ci" readme = "README.md" repository = "https://git.philomathiclife.com/repos/ci/" rust-version = "1.81.0" -version = "0.1.1" +version = "0.2.0" [badges] maintenance = { status = "actively-developed" } [dependencies] -serde = { version = "1.0.210", default-features = false } +serde = { version = "1.0.214", default-features = false } toml = { version = "0.8.19", default-features = false, features = ["parse"] } [profile.release] diff --git a/src/main.rs b/src/main.rs @@ -88,7 +88,6 @@ use std::{ collections::HashSet, env, fs, io::{self, Write}, - process::{Command, Stdio}, }; use toml::de::Error as TomlErr; /// Application error. @@ -133,70 +132,50 @@ impl Error for E {} fn main() -> Result<(), E> { Opts::from_args().and_then(|(mut opt, path)| { path.map_or(Ok(()), |p| env::set_current_dir(p).map_err(E::Io)).and_then(|()| { - Command::new("cargo").stderr(Stdio::piped()).stdin(Stdio::null()).stdout(Stdio::piped()).args(["upgrade", "-i", "allow"]).output().map_err(E::Io).and_then(|output| { - if output.status.success() { - if output.stdout.is_empty() { - Ok(()) - } else { - String::from_utf8(output.stdout).map_err(E::Utf8).and_then(|out| { - io::stderr() - .lock() - .write_all(out.as_bytes()) - .map_err(E::Io) + fs::read_to_string("Cargo.toml") + .map_err(E::Io) + .and_then(|toml| manifest::from_toml(toml.as_str()).map_err(E::Toml)) + .and_then(|features_powerset| { + features_powerset + .into_iter() + .try_fold(HashSet::new(), |mut msgs, features| { + opt.run_cmd(features.as_str(), &mut msgs) + .and_then(|success| { + if matches!(success, Success::NoLibraryTargets) { + // We don't want to bother continuing to call `cargo t -q --doc` once we + // know there is no library target. + assert!(matches!(opt, Opts::DocTests(_)), "Opts::DocTests should be the only variant that can return Success::NoLibraryTargets when Opts::run_cmd is called"); + Err(E::NoLibraryTargets) + } else { + Ok(msgs) + } + }) + }) + .or_else(|e| { + if matches!(e, E::NoLibraryTargets) { + Ok(HashSet::new()) + } else { + Err(e) + } + }) + .and_then(|msgs| { + if msgs.is_empty() { + Ok(()) + } else { + io::stderr() + .lock() + .write_all( + msgs.into_iter() + .fold(String::new(), |mut buffer, msg| { + buffer.push_str(msg.as_str()); + buffer + }) + .as_bytes(), + ) + .map_err(E::Io) + } }) - } - } else { - String::from_utf8(output.stderr).map_err(E::Utf8).and_then(|mut err| { - err.push_str("\ncargo upgrade -i allow"); - Err(E::Cmd(err)) - }) - } - }).and_then(|()| { - fs::read_to_string("Cargo.toml") - .map_err(E::Io) - .and_then(|toml| manifest::from_toml(toml.as_str()).map_err(E::Toml)) - .and_then(|features_powerset| { - features_powerset - .into_iter() - .try_fold(HashSet::new(), |mut msgs, features| { - opt.run_cmd(features.as_str(), &mut msgs) - .and_then(|success| { - if matches!(success, Success::NoLibraryTargets) { - // We don't want to bother continuing to call `cargo t -q --doc` once we - // know there is no library target. - assert!(matches!(opt, Opts::DocTests(_)), "Opts::DocTests should be the only variant that can return Success::NoLibraryTargets when Opts::run_cmd is called"); - Err(E::NoLibraryTargets) - } else { - Ok(msgs) - } - }) - }) - .or_else(|e| { - if matches!(e, E::NoLibraryTargets) { - Ok(HashSet::new()) - } else { - Err(e) - } - }) - .and_then(|msgs| { - if msgs.is_empty() { - Ok(()) - } else { - io::stderr() - .lock() - .write_all( - msgs.into_iter() - .fold(String::new(), |mut buffer, msg| { - buffer.push_str(msg.as_str()); - buffer - }) - .as_bytes(), - ) - .map_err(E::Io) - } - }) - }) }) - }) + }) }) }