diff --git a/.github/scripts/test-nushell-env.sh b/.github/scripts/test-nushell-env.sh new file mode 100755 index 0000000000..dd46dd38c3 --- /dev/null +++ b/.github/scripts/test-nushell-env.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -euo pipefail + +: "${VP_BIN_UNDER_TEST:?Set VP_BIN_UNDER_TEST to the vp binary to test}" + +nu_bin="$(command -v "${NU_BIN:-nu}")" +test_root="$(mktemp -d)" +trap 'rm -rf -- "$test_root"' EXIT + +test_home="$test_root/vp home with spaces" + +VP_HOME="$test_home" "$VP_BIN_UNDER_TEST" env setup --refresh >/dev/null + +( + cd "$test_home" + env -u VP_HOME \ + EXPECTED_VP_HOME="$test_home" \ + PATH="/usr/bin:/bin" \ + "$nu_bin" --commands ' + source env.nu + + let expected_home = ($env.EXPECTED_VP_HOME | path expand --no-symlink) + if $env.VP_HOME != $expected_home { + error make { + msg: $"VP_HOME mismatch: expected ($expected_home), got ($env.VP_HOME)" + } + } + + let expected_bin = ($expected_home | path join "bin") + let actual_bin = ($env.PATH | first) + if $actual_bin != $expected_bin { + error make { + msg: $"PATH mismatch: expected first entry ($expected_bin), got ($actual_bin)" + } + } + + let vp_output = (vp --version) + if $env.LAST_EXIT_CODE != 0 { + error make { + msg: "vp --version failed through the Nushell wrapper" + } + } + if ($vp_output | is-empty) { + error make { + msg: "vp --version returned no output" + } + } + ' +) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13b3141593..68f9ea7e05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -943,6 +943,17 @@ jobs: - name: Install Global CLI vp run: pnpm bootstrap-cli:ci + # https://github.com/marketplace/actions/setup-nu + - name: Install Nushell + if: runner.os == 'Linux' + uses: hustcer/setup-nu@ccd5bb5426b05a32009c2ba967946231f3919c97 # v3.25 + with: + version: '*' + + - name: Test generated Nushell environment + if: runner.os == 'Linux' + run: VP_BIN_UNDER_TEST="$HOME/.vite-plus/bin/vp" .github/scripts/test-nushell-env.sh + # Provision the managed runtime once into the real home so cases can # seed from it (seed-runtime) instead of each downloading ~50MB. # Best-effort: without a seed, cases that need the runtime download it