Skip to content

Commit

Permalink
Commit from GitHub Actions (test)
Browse files Browse the repository at this point in the history
  • Loading branch information
mise-en-dev authored and jdx committed Oct 13, 2024
1 parent 37fc5fa commit b63a528
Show file tree
Hide file tree
Showing 24 changed files with 48 additions and 67 deletions.
3 changes: 1 addition & 2 deletions src/backend/asdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::backend::external_plugin_cache::ExternalPluginCache;
use crate::backend::{ABackend, Backend, BackendList};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::default_shorthands::DEFAULT_SHORTHANDS;
use crate::env_diff::{EnvDiff, EnvDiffOperation};
use crate::git::Git;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::env::GITHUB_TOKEN;
use crate::file;
use crate::http::HTTP_FETCH;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Settings;
use crate::config::SETTINGS;
use crate::config::{Settings, SETTINGS};
use crate::install_context::InstallContext;
use crate::toolset::ToolRequest;

Expand Down
33 changes: 11 additions & 22 deletions src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ use versions::Versioning;
use self::backend_meta::BackendMeta;
use crate::cli::args::{BackendArg, ToolVersionType};
use crate::cmd::CmdLineRunner;
use crate::config::SETTINGS;
use crate::config::{Config, CONFIG};
use crate::config::{Config, CONFIG, SETTINGS};
use crate::file::{display_path, remove_all, remove_all_with_warning};
use crate::install_context::InstallContext;
use crate::plugins::core::{CorePlugin, CORE_PLUGINS};
Expand Down Expand Up @@ -86,42 +85,32 @@ fn load_tools() -> BackendMap {
.iter()
.map(|(_, p)| p.clone())
.collect::<Vec<ABackend>>();
let (tx, rx) = crossbeam_channel::unbounded();
let mut asdf_tools = Ok(vec![]);
let mut vfox_tools = Ok(vec![]);
let mut backend_tools = Ok(vec![]);
rayon::scope(|s| {
if !cfg!(windows) || SETTINGS.asdf {
let tx = tx.clone();
s.spawn(move |_| tx.send(asdf::AsdfBackend::list()).unwrap());
s.spawn(|_| asdf_tools = asdf::AsdfBackend::list());
}
if cfg!(windows) || SETTINGS.vfox {
let tx = tx.clone();
s.spawn(move |_| tx.send(vfox::VfoxBackend::list()).unwrap());
s.spawn(|_| vfox_tools = vfox::VfoxBackend::list());
}
s.spawn(move |_| tx.send(list_installed_backends()).unwrap());
backend_tools = list_installed_backends();
});
for backend in rx {
tools.extend(backend.expect("Error loading backends"));
}

tools.extend(asdf_tools.expect("asdf tools failed to load"));
tools.extend(vfox_tools.expect("vfox tools failed to load"));
tools.extend(backend_tools.expect("backend tools failed to load"));
tools.retain(|backend| !SETTINGS.disable_tools.contains(backend.id()));

let tools: BackendMap = tools
.into_iter()
.sorted_by_cached_key(rank_backend)
.map(|plugin| (plugin.id().to_string(), plugin))
.collect();
*TOOLS.lock().unwrap() = Some(tools.clone());
time!("load_tools", "done");
tools
}

fn rank_backend(backend: &ABackend) -> (usize, String) {
let rank = match backend.get_plugin_type() {
PluginType::Core => 0,
PluginType::Vfox => 1,
PluginType::Asdf => 2,
};
(rank, backend.id().to_string())
}

fn list_installed_backends() -> eyre::Result<BackendList> {
Ok(file::dir_subdirs(&dirs::INSTALLS)?
.into_par_iter()
Expand Down
3 changes: 1 addition & 2 deletions src/backend/npm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Config;
use crate::config::SETTINGS;
use crate::config::{Config, SETTINGS};
use crate::install_context::InstallContext;
use crate::toolset::ToolRequest;

Expand Down
3 changes: 1 addition & 2 deletions src/backend/pipx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::github;
use crate::http::HTTP_FETCH;
use crate::install_context::InstallContext;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/spm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Settings;
use crate::config::SETTINGS;
use crate::config::{Settings, SETTINGS};
use crate::install_context::InstallContext;
use crate::{file, github};
use eyre::WrapErr;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::env::GITHUB_TOKEN;
use crate::github;
use crate::install_context::InstallContext;
Expand Down
3 changes: 1 addition & 2 deletions src/backend/vfox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use url::Url;
use crate::backend::{ABackend, Backend, BackendList, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::git::Git;
use crate::install_context::InstallContext;
use crate::plugins::PluginType;
Expand Down
3 changes: 1 addition & 2 deletions src/cli/generate/task_docs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::config::CONFIG;
use crate::config::SETTINGS;
use crate::config::{CONFIG, SETTINGS};
use crate::{dirs, file};
use std::path::PathBuf;

Expand Down
4 changes: 4 additions & 0 deletions src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use either::Either;
use eyre::{bail, ensure, eyre, Result};
use glob::glob;
use itertools::Itertools;
#[cfg(unix)]
use nix::sys::signal::SIGTERM;

/// [experimental] Run task(s)
Expand Down Expand Up @@ -222,7 +223,10 @@ impl Run {
recv(rx_err) -> task => { // a task errored
let (task, status) = task.unwrap();
self.add_failed_task(task, status);
#[cfg(unix)]
CmdLineRunner::kill_all(SIGTERM); // start killing other running tasks
#[cfg(windows)]
CmdLineRunner::kill_all();
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/cli/tasks/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use itertools::Itertools;
use petgraph::dot::Dot;

use crate::config::{CONFIG, SETTINGS};
use crate::task::Deps;
use crate::task::Task;
use crate::task::{Deps, Task};
use crate::ui::style::{self};
use crate::ui::tree::print_tree;

Expand Down
3 changes: 1 addition & 2 deletions src/cli/tasks/info.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use eyre::{bail, Result};
use serde_json::json;

use crate::config::CONFIG;
use crate::config::SETTINGS;
use crate::config::{CONFIG, SETTINGS};
use crate::file::display_path;
use crate::task::Task;
use crate::ui::info;
Expand Down
3 changes: 1 addition & 2 deletions src/cli/use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use itertools::Itertools;

use crate::cli::args::{BackendArg, ToolArg};
use crate::config::config_file::ConfigFile;
use crate::config::SETTINGS;
use crate::config::{config_file, is_global_config, Config, LOCAL_CONFIG_FILENAMES};
use crate::config::{config_file, is_global_config, Config, LOCAL_CONFIG_FILENAMES, SETTINGS};
use crate::env::{
MISE_DEFAULT_CONFIG_FILENAME, MISE_DEFAULT_TOOL_VERSIONS_FILENAME, MISE_GLOBAL_CONFIG_FILE,
};
Expand Down
8 changes: 6 additions & 2 deletions src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,21 @@ impl<'a> CmdLineRunner<'a> {
}
}

#[cfg(unix)]
pub fn kill_all(signal: nix::sys::signal::Signal) {
let pids = RUNNING_PIDS.lock().unwrap();
#[cfg(unix)]
for pid in pids.iter() {
let pid = *pid as i32;
trace!("{signal}: {pid}");
if let Err(e) = nix::sys::signal::kill(nix::unistd::Pid::from_raw(pid), signal) {
debug!("Failed to kill cmd {pid}: {e}");
}
}
#[cfg(windows)]
}

#[cfg(windows)]
pub fn kill_all() {
let pids = RUNNING_PIDS.lock().unwrap();
for pid in pids.iter() {
if let Err(e) = Command::new("taskkill")
.arg("/F")
Expand Down
3 changes: 1 addition & 2 deletions src/config/env_directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use serde::{Deserialize, Deserializer};

use crate::cmd::CmdLineRunner;
use crate::config::config_file::trust_check;
use crate::config::Config;
use crate::config::SETTINGS;
use crate::config::{Config, SETTINGS};
use crate::env::PATH_KEY;
use crate::env_diff::{EnvDiff, EnvDiffOperation};
use crate::file::{display_path, which_non_pristine};
Expand Down
6 changes: 6 additions & 0 deletions src/exit.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use crate::cmd::CmdLineRunner;
#[cfg(unix)]
use nix::sys::signal::SIGTERM;

pub fn exit(code: i32) -> ! {
#[cfg(unix)]
CmdLineRunner::kill_all(SIGTERM);

#[cfg(windows)]
CmdLineRunner::kill_all();

debug!("exiting with code: {code}");
std::process::exit(code)
}
6 changes: 2 additions & 4 deletions src/plugins/asdf_plugin.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::config::SETTINGS;
use crate::config::{Config, Settings};
use crate::config::{Config, Settings, SETTINGS};
use crate::default_shorthands::{DEFAULT_SHORTHANDS, TRUSTED_SHORTHANDS};
use crate::errors::Error::PluginNotInstalled;
use crate::exit;
use crate::file::{display_path, remove_all};
use crate::git::Git;
use crate::plugins::{Plugin, PluginList, PluginType, Script, ScriptManager};
Expand All @@ -11,7 +9,7 @@ use crate::timeout::run_with_timeout;
use crate::ui::multi_progress_report::MultiProgressReport;
use crate::ui::progress_report::SingleReport;
use crate::ui::prompt;
use crate::{dirs, lock_file};
use crate::{dirs, exit, lock_file};
use clap::Command;
use console::style;
use contracts::requires;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/core/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cli::version::{ARCH, OS};
use crate::cmd::CmdLineRunner;
use crate::config::Config;
use crate::config::SETTINGS;
use crate::config::{Config, SETTINGS};
use crate::http::{HTTP, HTTP_FETCH};
use crate::install_context::InstallContext;
use crate::plugins::core::CorePlugin;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ pub use python::PythonPlugin;
use crate::backend::{Backend, BackendMap};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::config::Settings;
use crate::config::SETTINGS;
use crate::config::{Settings, SETTINGS};
use crate::env;
use crate::env::PATH_KEY;
use crate::http::HTTP_FETCH;
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/core/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use crate::build_time::built_info;
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
use crate::cmd::CmdLineRunner;
use crate::config::Config;
use crate::config::SETTINGS;
use crate::config::{Config, SETTINGS};
use crate::file::display_path;
use crate::git::Git;
use crate::http::{HTTP, HTTP_FETCH};
Expand Down
1 change: 1 addition & 0 deletions src/plugins/core/ruby_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use contracts::requires;
use eyre::Result;
use itertools::Itertools;
use versions::Versioning;
use xx::regex;

#[derive(Debug)]
pub struct RubyPlugin {
Expand Down
3 changes: 1 addition & 2 deletions src/shims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::sync::Arc;

use crate::backend::Backend;
use crate::cli::exec::Exec;
use crate::config::CONFIG;
use crate::config::SETTINGS;
use crate::config::{CONFIG, SETTINGS};
use crate::file::display_path;
use crate::lock_file::LockFile;
use crate::toolset::{ToolVersion, Toolset, ToolsetBuilder};
Expand Down
6 changes: 1 addition & 5 deletions src/ui/ctrlc_stub.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#[must_use]
#[derive(Debug)]
pub struct HandleGuard();

pub fn init() -> eyre::Result<()> {
Ok(())
}

pub fn add_handler(_func: impl Fn() + Send + Sync + 'static) {}
// pub fn add_handler(_func: impl Fn() + Send + Sync + 'static) {}

pub fn exit_on_ctrl_c(_do_exit: bool) {}

Expand Down

0 comments on commit b63a528

Please sign in to comment.