Add ability to ignore certain failures (#461)
This commit is contained in:
committed by
GitHub
parent
3d4917fa88
commit
5c7f04c2cf
@@ -4,6 +4,9 @@
|
|||||||
# Disable specific steps - same options as the command line flag
|
# Disable specific steps - same options as the command line flag
|
||||||
#disable = ["system", "emacs"]
|
#disable = ["system", "emacs"]
|
||||||
|
|
||||||
|
# Ignore failures for these steps
|
||||||
|
#ignore_failures = ["powershell"]
|
||||||
|
|
||||||
# Run specific steps - same options as the command line flag
|
# Run specific steps - same options as the command line flag
|
||||||
#only = ["system", "emacs"]
|
#only = ["system", "emacs"]
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ macro_rules! get_deprecated {
|
|||||||
|
|
||||||
type Commands = BTreeMap<String, String>;
|
type Commands = BTreeMap<String, String>;
|
||||||
|
|
||||||
#[derive(EnumString, EnumVariantNames, Debug, Clone, PartialEq, Deserialize, EnumIter)]
|
#[derive(EnumString, EnumVariantNames, Debug, Clone, PartialEq, Deserialize, EnumIter, Copy)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
#[strum(serialize_all = "snake_case")]
|
#[strum(serialize_all = "snake_case")]
|
||||||
pub enum Step {
|
pub enum Step {
|
||||||
@@ -103,6 +103,8 @@ pub enum Step {
|
|||||||
Flatpak,
|
Flatpak,
|
||||||
Snap,
|
Snap,
|
||||||
Pkg,
|
Pkg,
|
||||||
|
Powershell,
|
||||||
|
CustomCommands,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
@@ -161,6 +163,7 @@ pub struct ConfigFile {
|
|||||||
git_repos: Option<Vec<String>>,
|
git_repos: Option<Vec<String>>,
|
||||||
predefined_git_repos: Option<bool>,
|
predefined_git_repos: Option<bool>,
|
||||||
disable: Option<Vec<Step>>,
|
disable: Option<Vec<Step>>,
|
||||||
|
ignore_failures: Option<Vec<Step>>,
|
||||||
remote_topgrades: Option<Vec<String>>,
|
remote_topgrades: Option<Vec<String>>,
|
||||||
ssh_arguments: Option<String>,
|
ssh_arguments: Option<String>,
|
||||||
git_arguments: Option<String>,
|
git_arguments: Option<String>,
|
||||||
@@ -605,6 +608,15 @@ impl Config {
|
|||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Should we ignore failures for this step
|
||||||
|
pub fn ignore_failure(&self, step: Step) -> bool {
|
||||||
|
self.config_file
|
||||||
|
.ignore_failures
|
||||||
|
.as_ref()
|
||||||
|
.map(|v| v.contains(&step))
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn use_predefined_git_repos(&self) -> bool {
|
pub fn use_predefined_git_repos(&self) -> bool {
|
||||||
!self.opt.disable_predefined_git_repos
|
!self.opt.disable_predefined_git_repos
|
||||||
&& get_deprecated!(&self.config_file, predefined_git_repos, git, pull_predefined).unwrap_or(true)
|
&& get_deprecated!(&self.config_file, predefined_git_repos, git, pull_predefined).unwrap_or(true)
|
||||||
|
|||||||
284
src/main.rs
284
src/main.rs
@@ -108,99 +108,70 @@ fn run() -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let powershell = powershell::Powershell::new();
|
let powershell = powershell::Powershell::new();
|
||||||
let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Shell);
|
let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Powershell);
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
runner.execute(Step::Wsl, "WSL", || windows::run_wsl_topgrade(run_type))?;
|
||||||
if config.should_run(Step::Wsl) {
|
|
||||||
runner.execute("WSL", || windows::run_wsl_topgrade(run_type))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(topgrades) = config.remote_topgrades() {
|
if let Some(topgrades) = config.remote_topgrades() {
|
||||||
if config.should_run(Step::Remotes) {
|
|
||||||
for remote_topgrade in topgrades {
|
for remote_topgrade in topgrades {
|
||||||
runner.execute(format!("Remote ({})", remote_topgrade), || {
|
runner.execute(Step::Remotes, format!("Remote ({})", remote_topgrade), || {
|
||||||
generic::run_remote_topgrade(&ctx, remote_topgrade)
|
generic::run_remote_topgrade(&ctx, remote_topgrade)
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let distribution = linux::Distribution::detect();
|
let distribution = linux::Distribution::detect();
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::System) {
|
|
||||||
match &distribution {
|
match &distribution {
|
||||||
Ok(distribution) => {
|
Ok(distribution) => {
|
||||||
runner.execute("System update", || distribution.upgrade(&ctx))?;
|
runner.execute(Step::System, "System update", || distribution.upgrade(&ctx))?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error detecting current distribution: {}", e);
|
println!("Error detecting current distribution: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runner.execute("etc-update", || linux::run_etc_update(sudo.as_ref(), run_type))?;
|
runner.execute(Step::System, "etc-update", || {
|
||||||
}
|
linux::run_etc_update(sudo.as_ref(), run_type)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::Chocolatey) {
|
runner.execute(Step::Chocolatey, "Chocolatey", || windows::run_chocolatey(&ctx))?;
|
||||||
runner.execute("Chocolatey", || windows::run_chocolatey(&ctx))?;
|
runner.execute(Step::Scoop, "Scoop", || windows::run_scoop(config.cleanup(), run_type))?;
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Scoop) {
|
|
||||||
runner.execute("Scoop", || windows::run_scoop(config.cleanup(), run_type))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::Brew) {
|
runner.execute(Step::Brew, "Brew", || unix::run_brew(&ctx))?;
|
||||||
runner.execute("Brew", || unix::run_brew(&ctx))?;
|
runner.execute(Step::Brew, "Brew Cask", || unix::run_brew_cask(&ctx))?;
|
||||||
runner.execute("Brew Cask", || unix::run_brew_cask(&ctx))?;
|
|
||||||
}
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::MacPorts) {
|
runner.execute(Step::MacPorts, "MacPorts", || macos::run_macports(&ctx))?;
|
||||||
runner.execute("MacPorts", || macos::run_macports(&ctx))?;
|
runner.execute(Step::MicrosoftAutoUpdate, "Microsoft AutoUpdate", || {
|
||||||
}
|
macos::run_msupdate(&ctx)
|
||||||
if config.should_run(Step::MicrosoftAutoUpdate) {
|
})?;
|
||||||
runner.execute("Microsoft AutoUpdate", || macos::run_msupdate(&ctx))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if config.should_run(Step::Nix) {
|
|
||||||
runner.execute("nix", || unix::run_nix(&ctx))?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.should_run(Step::HomeManager) {
|
runner.execute(Step::Nix, "nix", || unix::run_nix(&ctx))?;
|
||||||
runner.execute("home-manager", || unix::run_home_manager(run_type))?;
|
runner.execute(Step::HomeManager, "home-manager", || unix::run_home_manager(run_type))?;
|
||||||
}
|
runner.execute(Step::Asdf, "asdf", || unix::run_asdf(run_type))?;
|
||||||
|
|
||||||
if config.should_run(Step::Asdf) {
|
|
||||||
runner.execute("asdf", || unix::run_asdf(run_type))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "dragonfly")]
|
#[cfg(target_os = "dragonfly")]
|
||||||
{
|
runner.execute(Step::Pkg, "DragonFly BSD Packages", || {
|
||||||
if config.should_run(Step::Pkg) {
|
|
||||||
runner.execute("DragonFly BSD Packages", || {
|
|
||||||
dragonfly::upgrade_packages(sudo.as_ref(), run_type)
|
dragonfly::upgrade_packages(sudo.as_ref(), run_type)
|
||||||
})?;
|
})?;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
{
|
runner.execute(Step::Pkg, "FreeBSD Packages", || {
|
||||||
if config.should_run(Step::Pkg) {
|
|
||||||
runner.execute("FreeBSD Packages", || {
|
|
||||||
freebsd::upgrade_packages(sudo.as_ref(), run_type)
|
freebsd::upgrade_packages(sudo.as_ref(), run_type)
|
||||||
})?;
|
})?;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let emacs = emacs::Emacs::new(&base_dirs);
|
let emacs = emacs::Emacs::new(&base_dirs);
|
||||||
if config.use_predefined_git_repos() {
|
if config.use_predefined_git_repos() {
|
||||||
@@ -249,106 +220,32 @@ fn run() -> Result<()> {
|
|||||||
git_repos.glob_insert(git_repo);
|
git_repos.glob_insert(git_repo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runner.execute("Git repositories", || git.multi_pull_step(&git_repos, &ctx))?;
|
runner.execute(Step::GitRepos, "Git repositories", || {
|
||||||
|
git.multi_pull_step(&git_repos, &ctx)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if should_run_powershell {
|
if should_run_powershell {
|
||||||
runner.execute("Powershell Modules Update", || powershell.update_modules(run_type))?;
|
runner.execute(Step::Powershell, "Powershell Modules Update", || {
|
||||||
|
powershell.update_modules(run_type)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::Shell) {
|
runner.execute(Step::Shell, "zr", || zsh::run_zr(&base_dirs, run_type))?;
|
||||||
runner.execute("zr", || zsh::run_zr(&base_dirs, run_type))?;
|
runner.execute(Step::Shell, "antibody", || zsh::run_antibody(run_type))?;
|
||||||
runner.execute("antibody", || zsh::run_antibody(run_type))?;
|
runner.execute(Step::Shell, "antigen", || zsh::run_antigen(&base_dirs, run_type))?;
|
||||||
runner.execute("antigen", || zsh::run_antigen(&base_dirs, run_type))?;
|
runner.execute(Step::Shell, "zplug", || zsh::run_zplug(&base_dirs, run_type))?;
|
||||||
runner.execute("zplug", || zsh::run_zplug(&base_dirs, run_type))?;
|
runner.execute(Step::Shell, "zinit", || zsh::run_zinit(&base_dirs, run_type))?;
|
||||||
runner.execute("zinit", || zsh::run_zinit(&base_dirs, run_type))?;
|
runner.execute(Step::Shell, "oh-my-zsh", || zsh::run_oh_my_zsh(&ctx))?;
|
||||||
runner.execute("oh-my-zsh", || zsh::run_oh_my_zsh(&ctx))?;
|
runner.execute(Step::Shell, "fisher", || unix::run_fisher(&base_dirs, run_type))?;
|
||||||
runner.execute("fisher", || unix::run_fisher(&base_dirs, run_type))?;
|
runner.execute(Step::Tmux, "tmux", || tmux::run_tpm(&base_dirs, run_type))?;
|
||||||
}
|
runner.execute(Step::Tldr, "TLDR", || unix::run_tldr(run_type))?;
|
||||||
|
runner.execute(Step::Pearl, "pearl", || unix::run_pearl(run_type))?;
|
||||||
if config.should_run(Step::Tmux) {
|
runner.execute(Step::Sdkman, "SDKMAN!", || {
|
||||||
runner.execute("tmux", || tmux::run_tpm(&base_dirs, run_type))?;
|
unix::run_sdkman(&base_dirs, config.cleanup(), run_type)
|
||||||
}
|
})?;
|
||||||
|
|
||||||
if config.should_run(Step::Tldr) {
|
|
||||||
runner.execute("TLDR", || unix::run_tldr(run_type))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Rustup) {
|
|
||||||
runner.execute("rustup", || generic::run_rustup(&base_dirs, run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Cargo) {
|
|
||||||
runner.execute("cargo", || generic::run_cargo_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Flutter) {
|
|
||||||
runner.execute("Flutter", || generic::run_flutter_upgrade(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Go) {
|
|
||||||
runner.execute("Go", || generic::run_go(&base_dirs, run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Emacs) {
|
|
||||||
runner.execute("Emacs", || emacs.upgrade(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Opam) {
|
|
||||||
runner.execute("opam", || generic::run_opam_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Vcpkg) {
|
|
||||||
runner.execute("vcpkg", || generic::run_vcpkg_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Pipx) {
|
|
||||||
runner.execute("pipx", || generic::run_pipx_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Stack) {
|
|
||||||
runner.execute("stack", || generic::run_stack_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Tlmgr) {
|
|
||||||
runner.execute("tlmgr", || generic::run_tlmgr_update(&ctx))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Myrepos) {
|
|
||||||
runner.execute("myrepos", || generic::run_myrepos_update(&base_dirs, run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
if config.should_run(Step::Pearl) {
|
|
||||||
runner.execute("pearl", || unix::run_pearl(run_type))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Jetpack) {
|
|
||||||
runner.execute("jetpak", || generic::run_jetpack(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Vim) {
|
|
||||||
runner.execute("vim", || vim::upgrade_vim(&base_dirs, &ctx))?;
|
|
||||||
runner.execute("Neovim", || vim::upgrade_neovim(&base_dirs, &ctx))?;
|
|
||||||
runner.execute("voom", || vim::run_voom(&base_dirs, run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Node) {
|
|
||||||
runner.execute("npm", || node::run_npm_upgrade(&base_dirs, run_type))?;
|
|
||||||
runner.execute("yarn", || node::yarn_global_update(run_type))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Composer) {
|
|
||||||
runner.execute("composer", || generic::run_composer_update(&ctx))?;
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Krew) {
|
|
||||||
runner.execute("krew", || generic::run_krew_upgrade(run_type))?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
@@ -357,80 +254,73 @@ fn run() -> Result<()> {
|
|||||||
target_os = "netbsd",
|
target_os = "netbsd",
|
||||||
target_os = "dragonfly"
|
target_os = "dragonfly"
|
||||||
)))]
|
)))]
|
||||||
{
|
runner.execute(Step::Atom, "apm", || generic::run_apm(run_type))?;
|
||||||
if config.should_run(Step::Atom) {
|
runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&base_dirs, run_type))?;
|
||||||
runner.execute("apm", || generic::run_apm(run_type))?;
|
runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(run_type))?;
|
||||||
}
|
runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?;
|
||||||
}
|
runner.execute(Step::Go, "Go", || generic::run_go(&base_dirs, run_type))?;
|
||||||
|
runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(run_type))?;
|
||||||
if config.should_run(Step::Gem) {
|
runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?;
|
||||||
runner.execute("gem", || generic::run_gem(&base_dirs, run_type))?;
|
runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(run_type))?;
|
||||||
}
|
runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(run_type))?;
|
||||||
|
runner.execute(Step::Stack, "stack", || generic::run_stack_update(run_type))?;
|
||||||
|
runner.execute(Step::Tlmgr, "tlmgr", || generic::run_tlmgr_update(&ctx))?;
|
||||||
|
runner.execute(Step::Myrepos, "myrepos", || {
|
||||||
|
generic::run_myrepos_update(&base_dirs, run_type)
|
||||||
|
})?;
|
||||||
|
runner.execute(Step::Jetpack, "jetpak", || generic::run_jetpack(run_type))?;
|
||||||
|
runner.execute(Step::Vim, "vim", || vim::upgrade_vim(&base_dirs, &ctx))?;
|
||||||
|
runner.execute(Step::Vim, "Neovim", || vim::upgrade_neovim(&base_dirs, &ctx))?;
|
||||||
|
runner.execute(Step::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?;
|
||||||
|
runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&base_dirs, run_type))?;
|
||||||
|
runner.execute(Step::Node, "yarn", || node::yarn_global_update(run_type))?;
|
||||||
|
runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?;
|
||||||
|
runner.execute(Step::Krew, "krew", || generic::run_krew_upgrade(run_type))?;
|
||||||
|
runner.execute(Step::Gem, "gem", || generic::run_gem(&base_dirs, run_type))?;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::Flatpak) {
|
runner.execute(Step::Flatpak, "Flatpak", || linux::flatpak_update(run_type))?;
|
||||||
runner.execute("Flatpak", || linux::flatpak_update(run_type))?;
|
runner.execute(Step::Snap, "snap", || linux::run_snap(sudo.as_ref(), run_type))?;
|
||||||
}
|
|
||||||
if config.should_run(Step::Snap) {
|
|
||||||
runner.execute("snap", || linux::run_snap(sudo.as_ref(), run_type))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(commands) = config.commands() {
|
if let Some(commands) = config.commands() {
|
||||||
for (name, command) in commands {
|
for (name, command) in commands {
|
||||||
runner.execute(name, || generic::run_custom_command(&name, &command, &ctx))?;
|
runner.execute(Step::CustomCommands, name, || {
|
||||||
|
generic::run_custom_command(&name, &command, &ctx)
|
||||||
|
})?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::System) {
|
runner.execute(Step::System, "pihole", || {
|
||||||
runner.execute("pihole", || linux::run_pihole_update(sudo.as_ref(), run_type))?;
|
linux::run_pihole_update(sudo.as_ref(), run_type)
|
||||||
}
|
})?;
|
||||||
|
runner.execute(Step::Firmware, "Firmware upgrades", || linux::run_fwupdmgr(run_type))?;
|
||||||
if config.should_run(Step::Firmware) {
|
runner.execute(Step::Restarts, "Restarts", || {
|
||||||
runner.execute("Firmware upgrades", || linux::run_fwupdmgr(run_type))?;
|
linux::run_needrestart(sudo.as_ref(), run_type)
|
||||||
}
|
})?;
|
||||||
|
|
||||||
if config.should_run(Step::Restarts) {
|
|
||||||
runner.execute("Restarts", || linux::run_needrestart(sudo.as_ref(), run_type))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
{
|
{
|
||||||
if config.should_run(Step::System) {
|
runner.execute(Step::System, "App Store", || macos::run_mas(run_type))?;
|
||||||
runner.execute("App Store", || macos::run_mas(run_type))?;
|
runner.execute(Step::System, "System upgrade", || macos::upgrade_macos(&ctx))?;
|
||||||
runner.execute("System upgrade", || macos::upgrade_macos(&ctx))?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
{
|
runner.execute(Step::System, "FreeBSD Upgrade", || {
|
||||||
if config.should_run(Step::System) {
|
freebsd::upgrade_freebsd(sudo.as_ref(), run_type)
|
||||||
runner.execute("FreeBSD Upgrade", || freebsd::upgrade_freebsd(sudo.as_ref(), run_type))?;
|
})?;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
{
|
runner.execute(Step::System, "Windows update", || windows::windows_update(&ctx))?;
|
||||||
if config.should_run(Step::System) {
|
|
||||||
runner.execute("Windows update", || windows::windows_update(&ctx))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
if config.should_run(Step::Sdkman) {
|
|
||||||
runner.execute("SDKMAN!", || unix::run_sdkman(&base_dirs, config.cleanup(), run_type))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if config.should_run(Step::Vagrant) {
|
if config.should_run(Step::Vagrant) {
|
||||||
if let Ok(boxes) = vagrant::collect_boxes(&ctx) {
|
if let Ok(boxes) = vagrant::collect_boxes(&ctx) {
|
||||||
for vagrant_box in boxes {
|
for vagrant_box in boxes {
|
||||||
runner.execute(format!("Vagrant ({})", vagrant_box.smart_name()), || {
|
runner.execute(Step::Vagrant, format!("Vagrant ({})", vagrant_box.smart_name()), || {
|
||||||
vagrant::topgrade_vagrant_box(&ctx, &vagrant_box)
|
vagrant::topgrade_vagrant_box(&ctx, &vagrant_box)
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
@@ -440,8 +330,8 @@ fn run() -> Result<()> {
|
|||||||
if !runner.report().data().is_empty() {
|
if !runner.report().data().is_empty() {
|
||||||
print_separator("Summary");
|
print_separator("Summary");
|
||||||
|
|
||||||
for (key, succeeded) in runner.report().data() {
|
for (key, result) in runner.report().data() {
|
||||||
print_result(key, *succeeded);
|
print_result(key, *result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@@ -477,10 +367,10 @@ fn run() -> Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if runner.report().data().iter().all(|(_, succeeded)| *succeeded) {
|
if runner.report().data().iter().any(|(_, result)| result.failed()) {
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(StepFailed.into())
|
Err(StepFailed.into())
|
||||||
|
} else {
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,25 @@
|
|||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub enum StepResult {
|
||||||
|
Success,
|
||||||
|
Failure,
|
||||||
|
Ignored,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StepResult {
|
||||||
|
pub fn failed(self) -> bool {
|
||||||
|
match self {
|
||||||
|
StepResult::Success | StepResult::Ignored => false,
|
||||||
|
StepResult::Failure => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type CowString<'a> = Cow<'a, str>;
|
type CowString<'a> = Cow<'a, str>;
|
||||||
|
type ReportData<'a> = Vec<(CowString<'a>, StepResult)>;
|
||||||
pub struct Report<'a> {
|
pub struct Report<'a> {
|
||||||
data: Vec<(CowString<'a>, bool)>,
|
data: ReportData<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Report<'a> {
|
impl<'a> Report<'a> {
|
||||||
@@ -10,7 +27,7 @@ impl<'a> Report<'a> {
|
|||||||
Self { data: Vec::new() }
|
Self { data: Vec::new() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_result<M>(&mut self, result: Option<(M, bool)>)
|
pub fn push_result<M>(&mut self, result: Option<(M, StepResult)>)
|
||||||
where
|
where
|
||||||
M: Into<CowString<'a>>,
|
M: Into<CowString<'a>>,
|
||||||
{
|
{
|
||||||
@@ -22,7 +39,7 @@ impl<'a> Report<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn data(&self) -> &Vec<(CowString<'a>, bool)> {
|
pub fn data(&self) -> &ReportData<'a> {
|
||||||
&self.data
|
&self.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::ctrlc;
|
use crate::ctrlc;
|
||||||
use crate::error::SkipStep;
|
use crate::error::SkipStep;
|
||||||
use crate::execution_context::ExecutionContext;
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::report::Report;
|
use crate::report::{Report, StepResult};
|
||||||
use crate::terminal::should_retry;
|
use crate::{config::Step, terminal::should_retry};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
@@ -21,18 +21,22 @@ impl<'a> Runner<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute<F, M>(&mut self, key: M, func: F) -> Result<()>
|
pub fn execute<F, M>(&mut self, step: Step, key: M, func: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: Fn() -> Result<()>,
|
F: Fn() -> Result<()>,
|
||||||
M: Into<Cow<'a, str>> + Debug,
|
M: Into<Cow<'a, str>> + Debug,
|
||||||
{
|
{
|
||||||
|
if !self.ctx.config().should_run(step) {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let key = key.into();
|
let key = key.into();
|
||||||
debug!("Step {:?}", key);
|
debug!("Step {:?}", key);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match func() {
|
match func() {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
self.report.push_result(Some((key, true)));
|
self.report.push_result(Some((key, StepResult::Success)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Err(e) if e.downcast_ref::<SkipStep>().is_some() => {
|
Err(e) if e.downcast_ref::<SkipStep>().is_some() => {
|
||||||
@@ -44,11 +48,19 @@ impl<'a> Runner<'a> {
|
|||||||
ctrlc::unset_interrupted();
|
ctrlc::unset_interrupted();
|
||||||
}
|
}
|
||||||
|
|
||||||
let should_ask = interrupted || !self.ctx.config().no_retry();
|
let ignore_failure = self.ctx.config().ignore_failure(step);
|
||||||
|
let should_ask = interrupted || !(self.ctx.config().no_retry() || ignore_failure);
|
||||||
let should_retry = should_ask && should_retry(interrupted, key.as_ref())?;
|
let should_retry = should_ask && should_retry(interrupted, key.as_ref())?;
|
||||||
|
|
||||||
if !should_retry {
|
if !should_retry {
|
||||||
self.report.push_result(Some((key, false)));
|
self.report.push_result(Some((
|
||||||
|
key,
|
||||||
|
if ignore_failure {
|
||||||
|
StepResult::Ignored
|
||||||
|
} else {
|
||||||
|
StepResult::Failure
|
||||||
|
},
|
||||||
|
)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
use crate::report::StepResult;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use crate::utils::which;
|
use crate::utils::which;
|
||||||
use chrono::{Local, Timelike};
|
use chrono::{Local, Timelike};
|
||||||
@@ -160,17 +161,17 @@ impl Terminal {
|
|||||||
.ok();
|
.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_result<P: AsRef<str>>(&mut self, key: P, succeeded: bool) {
|
fn print_result<P: AsRef<str>>(&mut self, key: P, result: StepResult) {
|
||||||
let key = key.as_ref();
|
let key = key.as_ref();
|
||||||
|
|
||||||
self.term
|
self.term
|
||||||
.write_fmt(format_args!(
|
.write_fmt(format_args!(
|
||||||
"{}: {}\n",
|
"{}: {}\n",
|
||||||
key,
|
key,
|
||||||
if succeeded {
|
match result {
|
||||||
style("OK").bold().green()
|
StepResult::Success => style("OK").bold().green(),
|
||||||
} else {
|
StepResult::Failure => style("FAILED").bold().red(),
|
||||||
style("FAILED").bold().red()
|
StepResult::Ignored => style("IGNORED").bold().yellow(),
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
.ok();
|
.ok();
|
||||||
@@ -269,8 +270,8 @@ pub fn print_info<P: AsRef<str>>(message: P) {
|
|||||||
TERMINAL.lock().unwrap().print_info(message)
|
TERMINAL.lock().unwrap().print_info(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_result<P: AsRef<str>>(key: P, succeeded: bool) {
|
pub fn print_result<P: AsRef<str>>(key: P, result: StepResult) {
|
||||||
TERMINAL.lock().unwrap().print_result(key, succeeded)
|
TERMINAL.lock().unwrap().print_result(key, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tells whether the terminal is dumb.
|
/// Tells whether the terminal is dumb.
|
||||||
|
|||||||
Reference in New Issue
Block a user