Skip to content

Commit 98df994

Browse files
authored
Add winget machine scope install tests (#65)
Add winget machine scope install tests
1 parent 86afded commit 98df994

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

.github/workflows/test-winget.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,33 @@ jobs:
9393
run: |
9494
winget install komac --accept-source-agreements --accept-package-agreements --disable-interactivity
9595
nu tests/winget-install.nu --scope user
96+
97+
machine-scope:
98+
name: Install with Machine Scope
99+
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
os: [windows-latest, windows-2025]
104+
105+
runs-on: ${{ matrix.os }}
106+
107+
steps:
108+
- uses: actions/checkout@v4
109+
110+
- name: Install winget
111+
if: ${{ matrix.os == 'windows-latest' }}
112+
uses: Cyberboss/install-winget@v1
113+
114+
- name: Setup Nu
115+
uses: hustcer/setup-nu@v3
116+
with:
117+
version: 'nightly'
118+
119+
- name: Test Winget Install with Machine Scope
120+
shell: nu {0}
121+
env:
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
run: |
124+
winget install komac --accept-source-agreements --accept-package-agreements --disable-interactivity
125+
nu tests/winget-install.nu --scope machine

tests/common.nu

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const BINS = [
1111
nu_plugin_formats.exe,
1212
]
1313

14-
const MACHINE_INSTALL_DIR = 'C:\Program Files\nu'
15-
const USER_INSTALL_DIR = $'($nu.home-path)\AppData\Local\Programs\nu'
14+
export const MACHINE_INSTALL_DIR = 'C:\Program Files\nu'
15+
export const USER_INSTALL_DIR = $'($nu.home-path)\AppData\Local\Programs\nu'
1616

1717
const ASSETS = [License.rtf README.txt nu.ico bin]
1818

tests/winget-install.nu

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11

22
use std/assert
33
use std/util ['path add']
4-
use common.nu [check-user-install, check-version-match, get-latest-tag]
4+
use common.nu [MACHINE_INSTALL_DIR, USER_INSTALL_DIR]
5+
use common.nu [check-user-install, check-local-machine-install, check-version-match, get-latest-tag]
6+
57

68
const KOMAC_PATH = $'($nu.home-path)\AppData\Local\Programs\Komac\bin\'
79

@@ -15,16 +17,20 @@ const WINGET_ARGS = [
1517

1618
def main [--scope: string] {
1719
prepare-manifest
18-
let install_dir = $'($nu.home-path)\AppData\Local\Programs\nu'
1920
let scope_tip = if $scope in [user, machine] { $'($scope) scope' } else { $'default scope' }
2021
print $'Using winget to test MSI (ansi g)($scope_tip)(ansi reset) installation'
2122
let version = get-latest-tag | split row + | first
2223
let scope_arg = if $scope in [user, machine] { [--scope $scope] } else { [] }
2324
winget settings --enable LocalManifestFiles
2425
winget settings --enable InstallerHashOverride
2526
winget install --manifest $'manifests\n\Nushell\Nushell\($version)\' ...$WINGET_ARGS ...$scope_arg
26-
check-user-install $install_dir
27-
check-version-match $version $install_dir
27+
if $scope == 'machine' {
28+
check-local-machine-install
29+
check-version-match $version $MACHINE_INSTALL_DIR
30+
return
31+
}
32+
check-user-install $USER_INSTALL_DIR
33+
check-version-match $version $USER_INSTALL_DIR
2834
}
2935

3036
def prepare-manifest [] {

0 commit comments

Comments
 (0)