Skip to content
Open
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
50 changes: 50 additions & 0 deletions .github/scripts/test-nushell-env.sh
Original file line number Diff line number Diff line change
@@ -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"
}
}
'
)
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading