From d25009af4234497f836f29baf8467ae391044297 Mon Sep 17 00:00:00 2001 From: hustcer Date: Sat, 26 Jul 2025 09:28:44 +0800 Subject: [PATCH 1/2] Add winget machine scope install tests --- .github/workflows/test-winget.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/test-winget.yml b/.github/workflows/test-winget.yml index f3c5b71c4..a08a0e4ec 100644 --- a/.github/workflows/test-winget.yml +++ b/.github/workflows/test-winget.yml @@ -93,3 +93,33 @@ jobs: run: | winget install komac --accept-source-agreements --accept-package-agreements --disable-interactivity nu tests/winget-install.nu --scope user + + machine-scope: + name: Install with Machine Scope + + strategy: + fail-fast: false + matrix: + os: [windows-latest, windows-2025] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Install winget + if: ${{ matrix.os == 'windows-latest' }} + uses: Cyberboss/install-winget@v1 + + - name: Setup Nu + uses: hustcer/setup-nu@v3 + with: + version: 'nightly' + + - name: Test Winget Install with Machine Scope + shell: nu {0} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + winget install komac --accept-source-agreements --accept-package-agreements --disable-interactivity + nu tests/winget-install.nu --scope machine From 56a57cb66c52199b754d773f3d86f51062df1e60 Mon Sep 17 00:00:00 2001 From: hustcer Date: Sat, 26 Jul 2025 09:38:59 +0800 Subject: [PATCH 2/2] Add winget machine scope install tests --- tests/common.nu | 4 ++-- tests/winget-install.nu | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/common.nu b/tests/common.nu index e488ed3d4..864bf15c6 100644 --- a/tests/common.nu +++ b/tests/common.nu @@ -11,8 +11,8 @@ const BINS = [ nu_plugin_formats.exe, ] -const MACHINE_INSTALL_DIR = 'C:\Program Files\nu' -const USER_INSTALL_DIR = $'($nu.home-path)\AppData\Local\Programs\nu' +export const MACHINE_INSTALL_DIR = 'C:\Program Files\nu' +export const USER_INSTALL_DIR = $'($nu.home-path)\AppData\Local\Programs\nu' const ASSETS = [License.rtf README.txt nu.ico bin] diff --git a/tests/winget-install.nu b/tests/winget-install.nu index e58a5194d..c36f5650c 100644 --- a/tests/winget-install.nu +++ b/tests/winget-install.nu @@ -1,7 +1,9 @@ use std/assert use std/util ['path add'] -use common.nu [check-user-install, check-version-match, get-latest-tag] +use common.nu [MACHINE_INSTALL_DIR, USER_INSTALL_DIR] +use common.nu [check-user-install, check-local-machine-install, check-version-match, get-latest-tag] + const KOMAC_PATH = $'($nu.home-path)\AppData\Local\Programs\Komac\bin\' @@ -15,7 +17,6 @@ const WINGET_ARGS = [ def main [--scope: string] { prepare-manifest - let install_dir = $'($nu.home-path)\AppData\Local\Programs\nu' let scope_tip = if $scope in [user, machine] { $'($scope) scope' } else { $'default scope' } print $'Using winget to test MSI (ansi g)($scope_tip)(ansi reset) installation' let version = get-latest-tag | split row + | first @@ -23,8 +24,13 @@ def main [--scope: string] { winget settings --enable LocalManifestFiles winget settings --enable InstallerHashOverride winget install --manifest $'manifests\n\Nushell\Nushell\($version)\' ...$WINGET_ARGS ...$scope_arg - check-user-install $install_dir - check-version-match $version $install_dir + if $scope == 'machine' { + check-local-machine-install + check-version-match $version $MACHINE_INSTALL_DIR + return + } + check-user-install $USER_INSTALL_DIR + check-version-match $version $USER_INSTALL_DIR } def prepare-manifest [] {