Skip to content

Commit

Permalink
Merge branch 'main' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Nov 4, 2024
2 parents 5288683 + c1d4d57 commit 92748cd
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 86 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: autofix.ci

on:
workflow_call:
pull_request:
push:
branches: ["main"]

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
MISE_TRUSTED_CONFIG_PATHS: ${{ github.workspace }}
MISE_EXPERIMENTAL: 1
RUST_BACKTRACE: 1
NPM_CONFIG_FUND: false

jobs:
nightly:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
{ toolchain: nightly, components: "rustfmt, clippy", rustflags: "" }
- run: |
cargo build --all-features
echo "$PWD/target/debug" >> "$GITHUB_PATH"
- name: cache mise
uses: actions/cache@v4
with:
key: mise-tools-ubuntu-latest-${{ hashFiles('.mise.toml') }}
restore-keys: mise-tools-ubuntu-latest
path: |
~/.local/share/mise/installs
~/.local/share/mise/plugins
- run: mise install
- run: npm install
- run: "mise run snapshots ::: lint-fix ::: render && git diff HEAD"
- uses: autofix-ci/[email protected]
if: ${{ always() }}
22 changes: 1 addition & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
MISE_TRUSTED_CONFIG_PATHS: ${{ github.workspace }}
MISE_EXPERIMENTAL: 1
RUST_BACKTRACE: 1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RTX_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
NPM_CONFIG_FUND: false

permissions:
Expand Down Expand Up @@ -61,23 +61,8 @@ jobs:
- run: cargo msrv verify
- run: cargo machete --with-metadata
- run: ./scripts/test-standalone.sh
- run: mise settings set experimental true
if: ${{ always() }}
- run: mise run render
if: ${{ always() }}
- uses: actions-rust-lang/rustfmt@v1
if: ${{ always() }}
- run: mise run lint
if: ${{ always() }}
- run: mise run snapshots
if: ${{ always() }}
- run: mise run lint-fix && git diff HEAD
if: ${{ always() }}
- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ always() }}
with:
commit_author: mise[bot] <[email protected]>
commit_message: "chore: apply lint fixes"

nightly:
runs-on: ubuntu-latest
Expand All @@ -104,11 +89,6 @@ jobs:
~/.local/share/mise/plugins
- run: mise install
- run: mise run test:shuffle
- run: mise run lint-fix && git diff HEAD
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_author: mise[bot] <[email protected]>
commit_message: "chore: apply lint fixes"

coverage:
name: coverage-${{matrix.tranche}}
Expand Down
2 changes: 1 addition & 1 deletion e2e/backend/test_cargo_binstall_token
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ assert_contains "GITHUB_TOKEN=foobar mise install -f cargo:[email protected] 2>&1" "to
assert_contains "GITHUB_API_TOKEN=foobar mise install -f cargo:[email protected] 2>&1" "token=foobar"

# This should prefer GITHUB_API_TOKEN
assert_contains "GITHUB_TOKEN=foobar GITHUB_API_TOKEN=barquz mise install -f cargo:[email protected] 2>&1" "token=foobar"
assert_contains "GITHUB_API_TOKEN=foobar GITHUB_TOKEN=barquz mise install -f cargo:[email protected] 2>&1" "token=foobar"
8 changes: 8 additions & 0 deletions e2e/cli/test_current
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

mise i dummy@3 tiny@2
mise use dummy@3

assert "mise current" "dummy 3"
assert "mise current dummy" "3"
assert "mise current tiny" ""
6 changes: 6 additions & 0 deletions e2e/plugins/core/test_ruby_ls_remote
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
# Install and build ruby using ruby-build

assert_contains "mise ls-remote ruby@3" "3.0.0"
assert_contains "mise ls-remote ruby@truffleruby-24" "truffleruby-24.0.0"
assert_contains "mise ls-remote ruby@truffleruby+graalvm-24" "truffleruby+graalvm-24.0.0"
15 changes: 15 additions & 0 deletions e2e/tasks/test_task_run_file
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,18 @@ assert "mise run filetask --port=8081" "user=
port=8081"
assert_contains "mise run filetask --help 2>&1 || true" "-u --user <user>"
assert_contains "mise run filetask --help 2>&1 || true" "-p --port <port>"

cat <<'EOF' >.mise/tasks/jstask
#!/usr/bin/env node
//MISE description="This is a test build script"
//MISE env={MYVAR = "1"}
console.log(`MYVAR: ${process.env.MYVAR}`);
EOF
chmod +x .mise/tasks/jstask
assert "mise run jstask" "MYVAR: 1"
assert "mise tasks" "configtask ~/workdir/.mise.toml
filetask ~/workdir/.mise/tasks/filetask
jstask This is a test build script ~/workdir/.mise/tasks/jstask
lint ~/workdir/.mise.toml
test ~/workdir/.mise.toml"
37 changes: 0 additions & 37 deletions src/cli/current.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,40 +121,3 @@ static AFTER_LONG_HELP: &str = color_print::cstr!(
3.11.0 3.10.0
"#
);

#[cfg(test)]
mod tests {
use crate::test::reset;
use std::env;
use test_log::test;

#[test]
fn test_current() {
reset();
assert_cli_snapshot!("current", @r###"
tiny 3.1.0
dummy ref:master
"###);
}

#[test]
fn test_current_with_runtimes() {
reset();
assert_cli_snapshot!("current", "tiny", @"3.1.0");
}

#[test]
fn test_current_missing() {
reset();
assert_cli!("uninstall", "--all", "dummy");

env::set_var("MISE_DUMMY_VERSION", "1.1.0");
assert_cli_snapshot!("current", @r###"
dummy 1.1.0
tiny 3.1.0
mise [email protected] is specified in MISE_DUMMY_VERSION=1.1.0, but not installed
"###);

env::remove_var("MISE_DUMMY_VERSION");
}
}
4 changes: 3 additions & 1 deletion src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,11 @@ pub static PATH_NON_PRISTINE: Lazy<Vec<PathBuf>> = Lazy::new(|| match var(&*PATH
});
pub static DIRENV_DIFF: Lazy<Option<String>> = Lazy::new(|| var("DIRENV_DIFF").ok());
pub static GITHUB_TOKEN: Lazy<Option<String>> = Lazy::new(|| {
var("GITHUB_TOKEN")
var("MISE_GITHUB_TOKEN")
.or_else(|_| var("GITHUB_API_TOKEN"))
.or_else(|_| var("GITHUB_TOKEN"))
.ok()
.and_then(|v| if v.is_empty() { None } else { Some(v) })
});

pub static CLICOLOR: Lazy<Option<bool>> = Lazy::new(|| {
Expand Down
26 changes: 1 addition & 25 deletions src/plugins/core/ruby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl RubyPlugin {
}
fn update_ruby_build(&self) -> Result<()> {
let _lock = self.lock_build_tool();
if self.ruby_build_path().exists() {
if self.ruby_build_bin().exists() {
let cur = self.ruby_build_version()?;
let latest = self.latest_ruby_build_version();
match (cur, latest) {
Expand Down Expand Up @@ -435,30 +435,6 @@ mod tests {
use indoc::indoc;
use pretty_assertions::assert_eq;

#[test]
fn test_list_versions_matching() {
reset();
let plugin = RubyPlugin::new();
assert!(
!plugin.list_versions_matching("3").unwrap().is_empty(),
"versions for 3 should not be empty"
);
assert!(
!plugin
.list_versions_matching("truffleruby-24")
.unwrap()
.is_empty(),
"versions for truffleruby-24 should not be empty"
);
assert!(
!plugin
.list_versions_matching("truffleruby+graalvm-24")
.unwrap()
.is_empty(),
"versions for truffleruby+graalvm-24 should not be empty"
);
}

#[test]
fn test_parse_gemfile() {
reset();
Expand Down
5 changes: 4 additions & 1 deletion src/versions_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use crate::{backend, http, registry};
use url::Url;

pub fn list_versions(ba: &BackendArg) -> eyre::Result<Option<Vec<String>>> {
if !SETTINGS.use_versions_host || ba.short.contains(':') {
if !SETTINGS.use_versions_host
|| ba.short.contains(':')
|| !REGISTRY.contains_key(ba.short.as_str())
{
return Ok(None);
}
// ensure that we're using a default shorthand plugin
Expand Down

0 comments on commit 92748cd

Please sign in to comment.