From b8b1240a47b9022e3809943221f42307d07cb056 Mon Sep 17 00:00:00 2001 From: Gaurav Tiwari Date: Mon, 16 Nov 2026 19:44:57 +0000 Subject: [PATCH] =?UTF-8?q?Use=20each=20Nushell=20revision=E2=80=99s=20pin?= =?UTF-8?q?ned=20Rust=20toolchain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rolling source now requires Rust 1.98.1, but setup forced 1.97.1 on every platform. Resolve the exact upstream pin before installing tools, reject floating channels, and remove the environment override. Validation: 224 tests, 909 assertions, zero failures; catalog, 12-lane matrix, and cache interface checks pass. --- test/bench/nushell_preparation_test.rb | 53 ++++++++++++++++++++++++++ tools/README.md | 6 ++- tools/cargo/nushell/case.toml | 3 +- tools/cargo/nushell/mise.toml | 1 - tools/cargo/nushell/prepare.rb | 8 ++++ 5 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 test/bench/nushell_preparation_test.rb create mode 100644 tools/cargo/nushell/prepare.rb diff --git a/test/bench/nushell_preparation_test.rb b/test/bench/nushell_preparation_test.rb new file mode 100644 index 0000000000..d85dbf80d3 --- /dev/null +++ b/test/bench/nushell_preparation_test.rb @@ -0,0 +1,53 @@ +require_relative "test_helper" + +class NushellPreparationTest < Minitest::Test + def test_installs_the_exact_toolchain_of_each_source_revision + %w[1.97.1 1.98.1].each do |version| + output, status, config, calls = prepare(version) + + assert status.success?, output + assert_equal({ "version" => version, "profile" => "minimal" }, config.dig("tools", "rust")) + assert_equal "0.17.0", config.dig("tools", "sccache") + assert_equal ["trust #{version}", "install #{version}"], calls + end + kase = Bench::Catalog.new(Bench::ROOT).find_case("cargo/nushell") + refute kase.env({}).key?("RUSTUP_TOOLCHAIN") + end + + def test_rejects_floating_toolchains_before_installation + %w[stable nightly 1.98].each do |version| + output, status, config, calls = prepare(version) + + refute status.success? + assert_includes output, "requires one exact Rust version" + refute config.fetch("tools").key?("rust") + assert_empty calls + end + end + + private + def prepare(version) + Dir.mktmpdir("nushell-rust") do |dir| + FileUtils.mkdir_p([File.join(dir, "upstream"), File.join(dir, "bin")]) + FileUtils.cp(File.join(Bench::ROOT, "tools/cargo/nushell/mise.toml"), dir) + source = TomlRB.dump("toolchain" => { "channel" => version }) + toolchain = File.join(dir, "upstream/rust-toolchain.toml") + File.write(toolchain, source) + calls = File.join(dir, "calls") + mise = File.join(dir, "bin/mise") + File.write(mise, <<~SH) + #!/usr/bin/env bash + version=$(ruby -rtoml-rb -e 'puts TomlRB.load_file("mise.toml").dig("tools", "rust", "version")') + echo "$1 $version" >> "$CALLS" + SH + File.chmod(0o755, mise) + kase = Bench::Catalog.new(Bench::ROOT).find_case("cargo/nushell") + output, status = Open3.capture2e( + { "PATH" => "#{dir}/bin:#{File.dirname(RbConfig.ruby)}:#{ENV.fetch("PATH")}", "CALLS" => calls, "BENCH_ROOT" => Bench::ROOT }, + "bash", "-e", "-c", kase.prepare.first, chdir: dir + ) + assert_equal source, File.read(toolchain) + [output, status, TomlRB.load_file(File.join(dir, "mise.toml")), File.exist?(calls) ? File.readlines(calls, chomp: true) : []] + end + end +end diff --git a/tools/README.md b/tools/README.md index 382ebca0ad..4fa7974040 100644 --- a/tools/README.md +++ b/tools/README.md @@ -237,8 +237,10 @@ job into a parallel lint job. Rolling builds visit every commit. Fresh builds use that starting source for both cold and warm phases. Every lane runs the root job's Cargo build, tests and doctests, with its `ci` -profile and `.cargo/ci.toml`. Source files are unchanged. Rust is 1.97.1 and -sccache is 0.17.0. Incremental compilation is off in all lanes so sccache can +profile and `.cargo/ci.toml`. Source files are unchanged. Setup installs the exact +Rust version pinned by each source commit's `rust-toolchain.toml`; floating +channels fail preparation. All lanes use that version and sccache 0.17.0. +Incremental compilation is off in all lanes so sccache can cache compiler outputs. After the tests, every lane copies `nu` out of `target` and removes the workspace's test executables, binaries, examples and their debug files from `target/ci`. Libraries and dependency outputs stay, so diff --git a/tools/cargo/nushell/case.toml b/tools/cargo/nushell/case.toml index b1fca3f7a7..ec189cab19 100644 --- a/tools/cargo/nushell/case.toml +++ b/tools/cargo/nushell/case.toml @@ -5,7 +5,7 @@ rolling_series = 4 directory = "upstream" script = ["bash", "../overlay/ci.sh"] prepare = [ - "mise trust && mise install", + "ruby \"$BENCH_ROOT/tools/cargo/nushell/prepare.rb\" && mise trust && mise install", "cd upstream && rustup show active-toolchain && cargo metadata --no-deps --format-version 1 > /dev/null", ] check = "bash overlay/check.sh" @@ -13,7 +13,6 @@ check = "bash overlay/check.sh" [env] CARGO_TERM_COLOR = "always" CARGO_INCREMENTAL = "0" -RUSTUP_TOOLCHAIN = "1.97.1" NU_LOG_LEVEL = "DEBUG" NU_TEST_SKIP_DEPS_BUILD = "true" NUSHELL_CARGO_PROFILE = "ci" diff --git a/tools/cargo/nushell/mise.toml b/tools/cargo/nushell/mise.toml index dcbc091f2b..e579072595 100644 --- a/tools/cargo/nushell/mise.toml +++ b/tools/cargo/nushell/mise.toml @@ -1,3 +1,2 @@ [tools] -rust = { version = "1.97.1", profile = "minimal" } sccache = "0.17.0" diff --git a/tools/cargo/nushell/prepare.rb b/tools/cargo/nushell/prepare.rb new file mode 100644 index 0000000000..eca0eb6873 --- /dev/null +++ b/tools/cargo/nushell/prepare.rb @@ -0,0 +1,8 @@ +require "toml-rb" + +version = TomlRB.load_file("upstream/rust-toolchain.toml").fetch("toolchain").fetch("channel") +abort "nushell requires one exact Rust version in rust-toolchain.toml" unless version.match?(/\A\d+\.\d+\.\d+\z/) + +config = TomlRB.load_file("mise.toml") +config.fetch("tools")["rust"] = { "version" => version, "profile" => "minimal" } +File.write("mise.toml", TomlRB.dump(config))