Skip to content
Merged
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
30 changes: 30 additions & 0 deletions .github/workflows/test-winget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/common.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
14 changes: 10 additions & 4 deletions tests/winget-install.nu
Original file line number Diff line number Diff line change
@@ -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\'

Expand All @@ -15,16 +17,20 @@ 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
let scope_arg = if $scope in [user, machine] { [--scope $scope] } else { [] }
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 [] {
Expand Down