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
51 changes: 51 additions & 0 deletions .github/workflows/test-installer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,57 @@ jobs:
- name: Verify installation
run: upsun --version

# Upgrade flow: an older release's package is installed first, and the
# installer must upgrade it.
linux-upgrade:
runs-on: ubuntu-latest
container: ${{ matrix.image }}
defaults:
run:
shell: sh
env:
OLD_VERSION: 5.16.0
strategy:
fail-fast: false
matrix:
include:
- image: debian:bookworm
prereqs: apt-get update && apt-get install -y curl ca-certificates
ext: deb
install: apt-get install -y
- image: fedora:41
prereqs: yum install -y curl
ext: rpm
install: yum install -y
- image: alpine:3.21
prereqs: apk add --no-cache curl ca-certificates
ext: apk
install: apk add --allow-untrusted

steps:
- name: Install prerequisites
run: ${{ matrix.prereqs }}

- name: Install an older release
run: |
curl -fsSL -o "/tmp/old.${{ matrix.ext }}" "https://github.com/upsun/cli/releases/download/v${OLD_VERSION}/upsun-cli_${OLD_VERSION}_linux_amd64.${{ matrix.ext }}"
${{ matrix.install }} "/tmp/old.${{ matrix.ext }}"
upsun --version
test "$(upsun --version)" = "Upsun CLI ${OLD_VERSION}"

- name: Check out repository
uses: actions/checkout@v7

- name: Run installer
env:
CI: ""
run: sh installer.sh

- name: Verify upgrade
run: |
upsun --version
test "$(upsun --version)" != "Upsun CLI ${OLD_VERSION}"

# Raw install on Linux: setting VERSION triggers the raw method.
# Without a VERSION input the installer queries the GitHub API for the
# latest release.
Expand Down
6 changes: 4 additions & 2 deletions installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,9 @@ gpgkey=https://repositories.upsun.com/gpg.key"

output "\nInstalling the $vendor_name CLI" "heading"

if ! call_root "yum install -y $package"; then
# Refresh this repository's metadata only, and upgrade an installed package (dnf's install may not).
opts="-y --setopt=upsun.metadata_expire=0"
if ! call_root "yum install $opts $package" || ! call_root "yum upgrade $opts $package"; then
output " could not install the CLI" "error"
exit_with_error
fi
Expand Down Expand Up @@ -767,7 +769,7 @@ install_apk() {

output "\nInstalling the $vendor_name CLI" "heading"

if ! call_root "apk add $package --update-cache"; then
if ! call_root "apk add --upgrade --update-cache $package"; then
output " could not install the CLI" "error"
exit_with_error
fi
Expand Down
22 changes: 21 additions & 1 deletion scripts/test/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ run_test() {
-v "$(pwd)/installer.sh:/installer.sh:ro" \
"$@" \
"$image" \
sh -c "${prereqs}sh /installer.sh && upsun --version"; then
sh -c "${prereqs}sh /installer.sh && ${check:-upsun --version}"; then
echo "--- PASS: ${label} ---"
pass=$((pass + 1))
else
Expand All @@ -55,6 +55,26 @@ run_test "fedora:41 (default)" "fedora:41" \
run_test "alpine:3.21 (default)" "alpine:3.21" \
"apk add -q --no-cache curl ca-certificates && "

# Upgrade tests: install an older release's package first, then check that the installer upgrades it.
old_version="5.16.0"
old_url="https://github.com/upsun/cli/releases/download/v${old_version}/upsun-cli_${old_version}_linux_amd64"
old_check="test \"\$(upsun --version)\" = 'Upsun CLI ${old_version}'"
check="upsun --version && test \"\$(upsun --version)\" != 'Upsun CLI ${old_version}'"

run_test "debian:bookworm (upgrade)" "debian:bookworm" \
"apt-get update -qq && apt-get install -y -qq curl ca-certificates && curl -fsSL -o /tmp/old.deb ${old_url}.deb && apt-get install -y -qq /tmp/old.deb && ${old_check} && " \
--platform linux/amd64

run_test "fedora:41 (upgrade)" "fedora:41" \
"yum install -y -q curl && curl -fsSL -o /tmp/old.rpm ${old_url}.rpm && yum install -y -q /tmp/old.rpm && ${old_check} && " \
--platform linux/amd64

run_test "alpine:3.21 (upgrade)" "alpine:3.21" \
"apk add -q --no-cache curl ca-certificates && curl -fsSL -o /tmp/old.apk ${old_url}.apk && apk add -q --allow-untrusted /tmp/old.apk && ${old_check} && " \
--platform linux/amd64

check=""

# Raw install test: setting VERSION triggers the raw method on Linux.
if [ -n "$VERSION" ]; then
run_test "debian:bookworm (raw, VERSION=$VERSION)" "debian:bookworm" \
Expand Down
Loading