Skip to content

Commit f77b2c5

Browse files
committed
Test winget install for default scope and user scope
1 parent eeda6f5 commit f77b2c5

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

.github/workflows/test-winget.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ permissions:
2727
contents: read
2828

2929
jobs:
30-
run-tests:
31-
name: Winget Install Tests
30+
default-scope:
31+
name: Winget Install with Default Scope
3232

3333
strategy:
3434
fail-fast: false
@@ -56,9 +56,38 @@ jobs:
5656
with:
5757
version: 'nightly'
5858

59-
- name: Test Winget Install
59+
- name: Test Winget Install with Default Scope
6060
shell: nu {0}
6161
env:
6262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6363
run: |
6464
nu tests/winget-install.nu
65+
66+
user-scope:
67+
name: Winget Install with User Scope
68+
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
os: [windows-latest, windows-2025]
73+
74+
runs-on: ${{ matrix.os }}
75+
76+
steps:
77+
- uses: actions/checkout@v4
78+
79+
- name: Install winget
80+
if: ${{ matrix.os == 'windows-latest' }}
81+
uses: Cyberboss/install-winget@v1
82+
83+
- name: Setup Nu
84+
uses: hustcer/setup-nu@v3
85+
with:
86+
version: 'nightly'
87+
88+
- name: Test Winget Install with User Scope
89+
shell: nu {0}
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
run: |
93+
nu tests/winget-install.nu --scope user

tests/winget-install.nu

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
use std/assert
33

4-
def main [] {
4+
def main [--scope: string] {
55
let install_dir = $'($nu.home-path)\AppData\Local\Programs\nu'
66
let profile = $'($nu.home-path)\AppData\Local\Microsoft\Windows Terminal\Fragments\nu\nu.json'
77
const BINS = [
@@ -13,10 +13,12 @@ def main [] {
1313
nu_plugin_formats.exe,
1414
]
1515

16-
print 'Using winget to test MSI installation'
16+
let scope_tip = if $scope in [user, machine] { $'($scope) scope' } else { $'default scope' }
17+
print $'Using winget to test MSI (ansi g)($scope_tip)(ansi reset) installation'
1718
let args = [--accept-source-agreements --accept-package-agreements --silent]
19+
let scope_arg = if $scope in [user, machine] { [--scope $scope] } else { [] }
1820
winget settings --enable LocalManifestFiles
19-
winget install --manifest manifests\n\Nushell\Nushell\0.104.1 ...$args
21+
winget install --manifest manifests\n\Nushell\Nushell\0.104.1 ...$args ...$scope_arg
2022
let environment = registry query --hkcu environment
2123
| where name == Path | get 0.value
2224
print $"Path Environment: \n($environment)"
@@ -31,4 +33,5 @@ def main [] {
3133
assert equal ($BINS | all {|it| $it in ($bins | get name) }) true
3234
assert equal ([License.rtf README.txt nu.ico bin] | all {|it| $it in ($contents | get name) }) true
3335
print $'(ansi g)Nu binaries installed sucessfully...(ansi reset)'
36+
^$'($install_dir)\bin\nu.exe' -c 'version'
3437
}

0 commit comments

Comments
 (0)