Skip to content
Open
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
95 changes: 95 additions & 0 deletions .github/workflows/test-installer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Test installer.sh

on:
workflow_dispatch:
inputs:
version:
description: 'CLI version to install (leave empty for latest release)'
required: false
type: string
push:
branches:
- main
paths:
- installer.sh
pull_request:
paths:
- installer.sh

permissions:
contents: read

jobs:
linux:
runs-on: ubuntu-latest
container: ${{ matrix.image }}

strategy:
fail-fast: false
matrix:
include:
- image: debian:bookworm
method: apt
- image: ubuntu:24.04
method: apt
- image: fedora:41
method: yum
- image: alpine:3.21
method: apk
- image: debian:bookworm
method: raw

steps:
- name: Install prerequisites
run: |
case "${{ matrix.method }}" in
apt)
apt-get update && apt-get install -y curl ca-certificates
;;
yum)
yum install -y curl
;;
apk)
apk add --no-cache curl ca-certificates
;;
raw)
apt-get update && apt-get install -y curl ca-certificates gzip
;;
esac
Comment on lines +42 to +58

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

- name: Run installer
env:
INSTALL_METHOD: ${{ matrix.method }}
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: sh installer.sh
Comment on lines +63 to +68

- name: Verify installation
run: upsun --version

macos:
runs-on: macos-latest

strategy:
fail-fast: false
matrix:
method:
- homebrew
- raw

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Run installer
env:
INSTALL_METHOD: ${{ matrix.method }}
GITHUB_TOKEN: ${{ github.token }}
VERSION: ${{ inputs.version }}
run: sh installer.sh

Comment on lines +87 to +93
- name: Verify installation
run: upsun --version
70 changes: 70 additions & 0 deletions scripts/test/installer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/sh
# Test installer.sh across Linux distros using Docker.
# Requires Docker to be installed and running.
# macOS methods (homebrew, raw) are only tested in CI (GitHub Actions).

set -eu

cd "$(dirname "$0")/../.."

: "${VERSION:=}"

pass=0
fail=0
errors=""

run_test() {
image="$1"
method="$2"
prereqs="$3"

label="${image} (${method})"
echo ""
echo "=== ${label} ==="

version_flag=""
if [ -n "$VERSION" ]; then
version_flag="-e VERSION=$VERSION"
fi

if docker run --rm \
-v "$(pwd)/installer.sh:/installer.sh:ro" \
-e INSTALL_METHOD="$method" \
$version_flag \
"$image" \
sh -c "${prereqs}sh /installer.sh && upsun --version"; then
echo "--- PASS: ${label} ---"
pass=$((pass + 1))
else
echo "--- FAIL: ${label} ---"
fail=$((fail + 1))
errors="${errors} ${label}\n"
Comment on lines +25 to +41
fi
}

echo "installer.sh test suite"
echo "======================="

run_test "debian:bookworm" "apt" \
"apt-get update -qq && apt-get install -y -qq curl ca-certificates && "

run_test "ubuntu:24.04" "apt" \
"apt-get update -qq && apt-get install -y -qq curl ca-certificates && "

run_test "fedora:41" "yum" \
"yum install -y -q curl && "

run_test "alpine:3.21" "apk" \
"apk add -q --no-cache curl ca-certificates && "

run_test "debian:bookworm" "raw" \
"apt-get update -qq && apt-get install -y -qq curl ca-certificates gzip && "

echo ""
echo "======================="
echo "Results: ${pass} passed, ${fail} failed"

if [ "$fail" -gt 0 ]; then
printf "\nFailed:\n%b" "$errors"
exit 1
fi
Loading