Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/hyperfine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ jobs:
env:
NUM_TOOLS: 200
NUM_TASKS: 2000
RUNS: 10
MISE_ALT: mise-${{ steps.versions.outputs.release }}
- uses: actions/upload-artifact@v4
with:
name: flamegraphs
path: flamegraphs
- run: |
set -x
failed=false
CMDS=(
"x -- echo"
"env"
Expand All @@ -83,9 +86,26 @@ jobs:
fi
echo "### \`mise $cmd\`" >> comment.md
cat out.md >> comment.md
cat out.md

# Extract relative performance from hyperfine output
variance=$(grep "mise $cmd" out.md | awk '{print $(NF-3)}' | sed 's/%//')
variance=$(echo "($variance * 100 - 100)/1" | bc)

# Add warning if variance exceeds 10%
if (( $(echo "$variance > 10" | bc -l) )); then
echo "⚠️ Warning: Performance variance for \`$cmd\` is ${variance}%" >> comment.md
failed=true
elif (( $(echo "$variance < -10" | bc -l) )); then
echo "✅ Performance improvement for \`$cmd\` is ${variance}%" >> comment.md
fi
done
if [ "$failed" = true ]; then
exit 1
fi
env:
SHELL: zsh
if: always()
- run: cat comment.md >> "$GITHUB_STEP_SUMMARY"
if: always() && github.event_name == 'pull_request'
- name: Comment on PR
Expand Down
12 changes: 1 addition & 11 deletions .github/workflows/registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- release
pull_request_target:
pull_request:
branches: [main]
paths:
- registry.toml
Expand All @@ -30,16 +30,6 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: thollander/actions-comment-pull-request@v3
if: github.event.pull_request.number != null
with:
comment-tag: "mise-registry-bot"
message: |
If you are adding a new tool to mise, note the following:

- New asdf plugins are not accepted
- Tools may be rejected if they are not notable
- A test is required in `registry.toml`
- uses: actions/checkout@v4
with:
submodules: true
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/registry_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: registry_comment
on:
pull_request_target:
branches: [main]
paths:
- registry.toml
- .github/workflows/registry.yml
- src/cli/test_tool.rs

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event.pull_request.number || github.event.pull_request.number || 'push' }}
cancel-in-progress: true

jobs:
build:
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: thollander/actions-comment-pull-request@v3
if: github.event.pull_request.number != null && github.actor != 'jdx'
with:
comment-tag: "mise-registry-bot"
message: |
If you are adding a new tool to mise, note the following:

- New asdf plugins are not accepted
- Tools may be rejected if they are not notable
- A test is required in `registry.toml`
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ megalinter-reports/
.vscode/
testResults.xml
.mise/
comment.md
4 changes: 4 additions & 0 deletions docs/cli/plugins/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ i.e.: they don't need the full git repo url

Show installation output

### `-j --jobs <JOBS>`

Number of jobs to run in parallel

Examples:

```
Expand Down
8 changes: 5 additions & 3 deletions e2e/lockfile/test_lockfile_exec
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ export MISE_LOCKFILE=1
export MISE_EXPERIMENTAL=1

touch mise.lock
mise install tiny@1.0.0
mise use tiny@1
mise install tiny@1.0.1
assert "mise install tiny@1.0.0"
assert "mise use tiny@1"
assert "mise current tiny" "1.0.0"
assert "mise install tiny@1.0.1"
assert "mise current tiny" "1.0.0"
assert "mise x -- rtx-tiny" "rtx-tiny: v1.0.0 args:"
#TODO: assert "mise x tiny -- rtx-tiny" "rtx-tiny: v1.0.0 args:"
assert "mise x tiny@1.0.1 -- rtx-tiny" "rtx-tiny: v1.0.1 args:"
Expand Down
3 changes: 3 additions & 0 deletions mise.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"!**/vendor",
"!**/CHANGELOG.md"
],
"files.exclude": {
"aqua-registry/**": true
},
},
}
3 changes: 3 additions & 0 deletions mise.usage.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,9 @@ cmd plugins help="Manage plugins" {
flag "-f --force" help="Reinstall even if plugin exists"
flag "-a --all" help="Install all missing plugins\nThis will only install plugins that have matching shorthands.\ni.e.: they don't need the full git repo url"
flag "-v --verbose" help="Show installation output" var=#true count=#true
flag "-j --jobs" help="Number of jobs to run in parallel" {
arg <JOBS>
}
arg "[NEW_PLUGIN]" help="The name of the plugin to install\ne.g.: node, ruby\nCan specify multiple plugins: `mise plugins install node ruby python`" required=#false
arg "[GIT_URL]" help="The git url of the plugin" required=#false
arg "[REST]…" required=#false var=#true hide=#true
Expand Down
8 changes: 4 additions & 4 deletions src/aqua/aqua_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ mod tests {

#[tokio::test]
async fn test_render() {
let _config = Config::get().await;
let _config = Config::get().await.unwrap();
let tmpl = "Hello, {{.OS}}!";
let mut ctx = HashMap::new();
ctx.insert("OS".to_string(), "world".to_string());
Expand All @@ -192,7 +192,7 @@ mod tests {
$(
#[tokio::test]
async fn $name() {
let _config = Config::get().await;
let _config = Config::get().await.unwrap();
let (input, expected, ctx): (&str, &str, HashMap<&str, &str>) = $value;
let ctx = ctx.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
let parser = Parser { ctx: &ctx };
Expand All @@ -216,7 +216,7 @@ mod tests {

#[tokio::test]
async fn test_parse_err() {
let _config = Config::get().await;
let _config = Config::get().await.unwrap();
let parser = Parser {
ctx: &HashMap::new(),
};
Expand All @@ -226,7 +226,7 @@ mod tests {

#[tokio::test]
async fn test_lex() {
let _config = Config::get().await;
let _config = Config::get().await.unwrap();
assert_eq!(
lex(r#"trimPrefix "foo-" "foo-v1.0.0" | trimV"#).unwrap(),
vec![
Expand Down
6 changes: 5 additions & 1 deletion src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ impl Backend for AquaBackend {
Ok(tv)
}

async fn list_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
async fn list_bin_paths(
&self,
_config: &Arc<Config>,
tv: &ToolVersion,
) -> Result<Vec<PathBuf>> {
// TODO: instead of caching it would probably be better to create this as part of installation
let cache = self
.bin_path_caches
Expand Down
26 changes: 16 additions & 10 deletions src/backend/asdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ impl AsdfBackend {
Ok(())
}

async fn fetch_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<String>> {
async fn fetch_bin_paths(&self, config: &Arc<Config>, tv: &ToolVersion) -> Result<Vec<String>> {
let list_bin_paths = self.plugin_path.join("bin/list-bin-paths");
let bin_paths = if matches!(tv.request, ToolRequest::System { .. }) {
Vec::new()
} else if list_bin_paths.exists() {
let sm = self.script_man_for_tv(tv).await?;
let sm = self.script_man_for_tv(config, tv).await?;
// TODO: find a way to enable this without deadlocking
// for (t, tv) in ts.list_current_installed_versions(config) {
// if t.name == self.name {
Expand Down Expand Up @@ -143,7 +143,7 @@ impl AsdfBackend {
ts: &Toolset,
tv: &ToolVersion,
) -> Result<EnvMap> {
let mut sm = self.script_man_for_tv(tv).await?;
let mut sm = self.script_man_for_tv(config, tv).await?;
for p in ts.list_paths(config).await {
sm.prepend_path(p);
}
Expand All @@ -162,8 +162,11 @@ impl AsdfBackend {
Ok(env)
}

async fn script_man_for_tv(&self, tv: &ToolVersion) -> Result<ScriptManager> {
let config = Config::get().await;
async fn script_man_for_tv(
&self,
config: &Arc<Config>,
tv: &ToolVersion,
) -> Result<ScriptManager> {
let mut sm = self.plugin.script_man.clone();
for (key, value) in tv.request.options().opts {
let k = format!("RTX_TOOL_OPTS__{}", key.to_uppercase());
Expand Down Expand Up @@ -333,7 +336,7 @@ impl Backend for AsdfBackend {
}

async fn install_version_(&self, ctx: &InstallContext, tv: ToolVersion) -> Result<ToolVersion> {
let mut sm = self.script_man_for_tv(&tv).await?;
let mut sm = self.script_man_for_tv(&ctx.config, &tv).await?;

for p in ctx.ts.list_paths(&ctx.config).await {
sm.prepend_path(p);
Expand All @@ -354,21 +357,24 @@ impl Backend for AsdfBackend {

async fn uninstall_version_impl(
&self,
config: &Arc<Config>,
pr: &Box<dyn SingleReport>,
tv: &ToolVersion,
) -> Result<()> {
if self.plugin_path.join("bin/uninstall").exists() {
self.script_man_for_tv(tv)
self.script_man_for_tv(config, tv)
.await?
.run_by_line(&Script::Uninstall, pr)?;
}
Ok(())
}

async fn list_bin_paths(&self, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
async fn list_bin_paths(&self, config: &Arc<Config>, tv: &ToolVersion) -> Result<Vec<PathBuf>> {
Ok(self
.cache
.list_bin_paths(self, tv, async || self.fetch_bin_paths(tv).await)
.list_bin_paths(config, self, tv, async || {
self.fetch_bin_paths(config, tv).await
})
.await?
.into_iter()
.map(|path| tv.install_path().join(path))
Expand Down Expand Up @@ -417,7 +423,7 @@ mod tests {

#[tokio::test]
async fn test_debug() {
let _config = Config::get().await;
let _config = Config::get().await.unwrap();
let plugin = AsdfBackend::from_arg("dummy".into());
assert!(format!("{plugin:?}").starts_with("AsdfPlugin { name: \"dummy\""));
}
Expand Down
6 changes: 3 additions & 3 deletions src/backend/external_plugin_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::hash::hash_to_str;
use crate::tera::{BASE_CONTEXT, get_tera};
use crate::toolset::{ToolRequest, ToolVersion};
use eyre::{WrapErr, eyre};
use std::collections::HashMap;
use std::{collections::HashMap, sync::Arc};
use tokio::sync::RwLock;

#[derive(Debug, Default)]
Expand All @@ -20,6 +20,7 @@ pub struct ExternalPluginCache {
impl ExternalPluginCache {
pub async fn list_bin_paths<F, Fut>(
&self,
config: &Arc<Config>,
plugin: &AsdfBackend,
tv: &ToolVersion,
fetch: F,
Expand All @@ -28,12 +29,11 @@ impl ExternalPluginCache {
Fut: Future<Output = eyre::Result<Vec<String>>>,
F: FnOnce() -> Fut,
{
let config = Config::get().await;
let mut w = self.list_bin_paths.write().await;
let cm = w.entry(tv.request.clone()).or_insert_with(|| {
let list_bin_paths_filename = match &plugin.toml.list_bin_paths.cache_key {
Some(key) => {
let key = render_cache_key(&config, tv, key);
let key = render_cache_key(config, tv, key);
let filename = format!("{key}.msgpack.z");
tv.cache_path().join("list_bin_paths").join(filename)
}
Expand Down
Loading
Loading