Skip to content

Commit 4e38844

Browse files
authored
Test winget upgrade for the latest nightly builds (#67)
Test winget upgrade for the latest nightly builds
1 parent 9113bb8 commit 4e38844

File tree

3 files changed

+45
-20
lines changed

3 files changed

+45
-20
lines changed

.github/workflows/test-upgrade.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ jobs:
6363
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6464
run: |
6565
use ${{ github.workspace }}/tests/test-all.nu *
66+
use ${{ github.workspace }}/tests/winget-install.nu [prepare-manifest]
67+
winget install komac --accept-source-agreements --accept-package-agreements --disable-interactivity
68+
prepare-manifest
6669
test-winget-per-user-install
6770
test-winget-per-user-upgrade
6871
test-winget-per-machine-install

tests/test-all.nu

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# winget settings --enable LocalManifestFiles
44
# winget settings --enable InstallerHashOverride
55

6-
use common.nu [check-user-install, check-version-match, check-local-machine-install]
6+
use winget-install.nu [prepare-manifest]
7+
use common.nu [check-user-install, check-version-match, check-local-machine-install, get-latest-tag]
78

89
const VERSION = '0.105.1'
910
const PREV_VERSION = '0.105.0'
@@ -19,15 +20,16 @@ const WINGET_ARGS = [
1920
--accept-package-agreements
2021
]
2122

22-
def main [--msi(-m)] {
23-
if $msi {
23+
def main [--msi(-m), --local] {
24+
if $msi and $local {
2425
test-msi-per-user-install
2526
test-msi-per-machine-install
2627
}
27-
test-winget-per-user-install
28-
test-winget-per-user-upgrade
29-
test-winget-per-machine-install
30-
test-winget-per-machine-upgrade
28+
if not $local { prepare-manifest }
29+
test-winget-per-user-install --local=$local
30+
test-winget-per-user-upgrade --local=$local
31+
test-winget-per-machine-install --local=$local
32+
test-winget-per-machine-upgrade --local=$local
3133
}
3234

3335
export def test-msi-per-user-install [] {
@@ -50,41 +52,61 @@ export def test-msi-per-machine-install [] {
5052
winget list nushell --accept-source-agreements
5153
}
5254

53-
export def test-winget-per-user-install [] {
55+
export def test-winget-per-user-install [--local] {
5456
winget uninstall nushell | complete
5557
print $'(char nl)Using winget to test MSI (ansi g)user scope(ansi reset) installation'
5658
print '-------------------------------------------------------------------'
57-
winget install --manifest $'manifests\n\Nushell\Nushell\($PREV_VERSION)\' ...$WINGET_ARGS --scope user
59+
if $local {
60+
winget install --manifest $'manifests\n\Nushell\Nushell\($PREV_VERSION)\' ...$WINGET_ARGS --scope user
61+
check-version-match $PREV_VERSION $PER_USER_INSTALL_DIR
62+
} else {
63+
winget install --id Nushell.Nushell ...$WINGET_ARGS --scope user
64+
}
5865
check-user-install $PER_USER_INSTALL_DIR
59-
check-version-match $PREV_VERSION $PER_USER_INSTALL_DIR
6066
winget list nushell --accept-source-agreements
6167
}
6268

63-
export def test-winget-per-user-upgrade [] {
69+
export def test-winget-per-user-upgrade [--local] {
6470
print $'(char nl)Using winget to test MSI (ansi g)user scope(ansi reset) upgrade'
6571
print '-------------------------------------------------------------------'
6672
# winget upgrade does not work for user scope due to https://github.com/microsoft/winget-cli/issues/3011
67-
winget install --manifest $'manifests\n\Nushell\Nushell\($LAST_VERSION)\' ...$WINGET_ARGS --scope user
73+
if $local {
74+
winget install --manifest $'manifests\n\Nushell\Nushell\($LAST_VERSION)\' ...$WINGET_ARGS --scope user
75+
check-version-match $LAST_VERSION $PER_USER_INSTALL_DIR
76+
} else {
77+
let version = get-latest-tag | split row + | first
78+
winget install --manifest $'manifests\n\Nushell\Nushell\($version)\' ...$WINGET_ARGS --scope user
79+
check-version-match $version $PER_USER_INSTALL_DIR
80+
}
6881
check-user-install $PER_USER_INSTALL_DIR
69-
check-version-match $LAST_VERSION $PER_USER_INSTALL_DIR
7082
winget list nushell --accept-source-agreements
7183
}
7284

73-
export def test-winget-per-machine-install [] {
85+
export def test-winget-per-machine-install [--local] {
7486
winget uninstall nushell | complete
7587
print $'(char nl)Using winget to test MSI (ansi g)machine scope(ansi reset) installation'
7688
print '-------------------------------------------------------------------'
77-
winget install --manifest $'manifests\n\Nushell\Nushell\($PREV_VERSION)\' ...$WINGET_ARGS --scope machine
89+
if $local {
90+
winget install --manifest $'manifests\n\Nushell\Nushell\($PREV_VERSION)\' ...$WINGET_ARGS --scope machine
91+
check-version-match $PREV_VERSION $PER_MACHINE_INSTALL_DIR
92+
} else {
93+
winget install --id Nushell.Nushell ...$WINGET_ARGS --scope machine
94+
}
7895
check-local-machine-install
79-
check-version-match $PREV_VERSION $PER_MACHINE_INSTALL_DIR
8096
winget list nushell --accept-source-agreements
8197
}
8298

83-
export def test-winget-per-machine-upgrade [] {
99+
export def test-winget-per-machine-upgrade [--local] {
84100
print $'(char nl)Using winget to test MSI (ansi g)machine scope(ansi reset) upgrade'
85101
print '-------------------------------------------------------------------'
86-
winget upgrade --manifest $'manifests\n\Nushell\Nushell\($LAST_VERSION)\' ...$WINGET_ARGS
102+
if $local {
103+
winget upgrade --manifest $'manifests\n\Nushell\Nushell\($LAST_VERSION)\' ...$WINGET_ARGS
104+
check-version-match $LAST_VERSION $PER_MACHINE_INSTALL_DIR
105+
} else {
106+
let version = get-latest-tag | split row + | first
107+
winget upgrade --manifest $'manifests\n\Nushell\Nushell\($version)\' ...$WINGET_ARGS
108+
check-version-match $version $PER_MACHINE_INSTALL_DIR
109+
}
87110
check-local-machine-install
88-
check-version-match $LAST_VERSION $PER_MACHINE_INSTALL_DIR
89111
winget list nushell --accept-source-agreements
90112
}

tests/winget-install.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def main [--scope: string] {
3333
check-version-match $version $USER_INSTALL_DIR
3434
}
3535

36-
def prepare-manifest [] {
36+
export def prepare-manifest [] {
3737
let version = get-latest-tag | split row + | first
3838
let urls = get-download-url
3939
path add $KOMAC_PATH

0 commit comments

Comments
 (0)