Skip to content

Commit ffb380d

Browse files
pjcdawkinsclaude
andauthored
ci: add installer.sh test automation (#30)
* ci: add installer.sh test automation Add a GitHub Actions workflow that tests installer.sh across distros: - Linux: Debian (apt), Ubuntu (apt), Fedora (yum), Alpine (apk), Debian (raw) - macOS: homebrew and raw methods Also add a local Docker-based test script (scripts/test/installer.sh) for quick iteration without pushing to CI. Tests run against published packages/releases. The installer script itself comes from the current commit so changes to it are tested even though the installed packages come from live repos. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(scripts): show Docker output in installer test script Show all Docker output (installer progress and errors) instead of suppressing it. Use -qq/-q flags on package managers to reduce noise from prerequisite installs while keeping installer output visible. Add a comment noting that macOS methods are CI-only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: add VERSION option to installer test script and workflow The raw install method needs /releases/latest on GitHub, which only returns non-prerelease versions. When only pre-releases exist, this fails. Allow passing a specific version to work around this. Local script: VERSION=5.0.4 scripts/test/installer.sh Workflow: workflow_dispatch input field Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(ci): address review comments on installer test PR - Set shell: sh for linux job (Alpine lacks bash) - Quote VERSION env var properly in Docker script - Only pass GITHUB_TOKEN for the raw install method Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * refactor(ci): test default installer flow per distro Restructure tests to focus on the default (auto-detected) install method for each distro, rather than forcing INSTALL_METHOD. This better reflects what users actually experience. - Linux default tests: override CI="" so the installer auto-detects the package manager (apt/yum/apk) instead of always selecting raw - Separate linux-raw and macos-raw jobs for the raw download path - Raw tests accept a VERSION input for testing prereleases - Local test script: default tests have no INSTALL_METHOD; raw test runs only when VERSION is set Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * ci: update actions/checkout to v6 Resolves Node.js 20 deprecation warnings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2201e83 commit ffb380d

2 files changed

Lines changed: 191 additions & 0 deletions

File tree

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Test installer.sh
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'CLI version to install for raw tests (leave empty for latest release)'
8+
required: false
9+
type: string
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- installer.sh
15+
- .github/workflows/test-installer.yml
16+
pull_request:
17+
paths:
18+
- installer.sh
19+
- .github/workflows/test-installer.yml
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
# Default install flow: the installer auto-detects the package manager.
26+
# CI is overridden to empty so that is_ci() returns false (otherwise
27+
# the installer would always select the "raw" method on Linux).
28+
linux:
29+
runs-on: ubuntu-latest
30+
container: ${{ matrix.image }}
31+
defaults:
32+
run:
33+
shell: sh
34+
strategy:
35+
fail-fast: false
36+
matrix:
37+
include:
38+
- image: debian:bookworm
39+
prereqs: apt-get update && apt-get install -y curl ca-certificates
40+
- image: ubuntu:24.04
41+
prereqs: apt-get update && apt-get install -y curl ca-certificates
42+
- image: fedora:41
43+
prereqs: yum install -y curl
44+
- image: alpine:3.21
45+
prereqs: apk add --no-cache curl ca-certificates
46+
47+
steps:
48+
- name: Install prerequisites
49+
run: ${{ matrix.prereqs }}
50+
51+
- name: Check out repository
52+
uses: actions/checkout@v6
53+
54+
- name: Run installer
55+
env:
56+
CI: ""
57+
run: sh installer.sh
58+
59+
- name: Verify installation
60+
run: upsun --version
61+
62+
# Raw install on Linux: setting VERSION triggers the raw method.
63+
# Without a VERSION input the installer queries the GitHub API for the
64+
# latest release.
65+
linux-raw:
66+
runs-on: ubuntu-latest
67+
container: debian:bookworm
68+
defaults:
69+
run:
70+
shell: sh
71+
steps:
72+
- name: Install prerequisites
73+
run: apt-get update && apt-get install -y curl ca-certificates gzip
74+
75+
- name: Check out repository
76+
uses: actions/checkout@v6
77+
78+
- name: Run installer
79+
env:
80+
VERSION: ${{ inputs.version }}
81+
GITHUB_TOKEN: ${{ github.token }}
82+
run: sh installer.sh
83+
84+
- name: Verify installation
85+
run: upsun --version
86+
87+
# Default install flow on macOS (auto-detects homebrew).
88+
macos:
89+
runs-on: macos-latest
90+
steps:
91+
- name: Check out repository
92+
uses: actions/checkout@v6
93+
94+
- name: Run installer
95+
run: sh installer.sh
96+
97+
- name: Verify installation
98+
run: upsun --version
99+
100+
# Raw install on macOS (INSTALL_METHOD is required because VERSION
101+
# does not affect macOS method selection).
102+
macos-raw:
103+
runs-on: macos-latest
104+
steps:
105+
- name: Check out repository
106+
uses: actions/checkout@v6
107+
108+
- name: Run installer
109+
env:
110+
INSTALL_METHOD: raw
111+
VERSION: ${{ inputs.version }}
112+
GITHUB_TOKEN: ${{ github.token }}
113+
run: sh installer.sh
114+
115+
- name: Verify installation
116+
run: upsun --version

‎scripts/test/installer.sh‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/sh
2+
# Test installer.sh across Linux distros using Docker.
3+
# Requires Docker to be installed and running.
4+
# macOS methods (homebrew, raw) are only tested in CI (GitHub Actions).
5+
6+
set -eu
7+
8+
cd "$(dirname "$0")/../.."
9+
10+
: "${VERSION:=}"
11+
12+
pass=0
13+
fail=0
14+
errors=""
15+
16+
# Run a test in a Docker container.
17+
# Arguments: label, image, prereqs, [extra docker args...]
18+
run_test() {
19+
label="$1"
20+
image="$2"
21+
prereqs="$3"
22+
shift 3
23+
24+
echo ""
25+
echo "=== ${label} ==="
26+
27+
if docker run --rm \
28+
-v "$(pwd)/installer.sh:/installer.sh:ro" \
29+
"$@" \
30+
"$image" \
31+
sh -c "${prereqs}sh /installer.sh && upsun --version"; then
32+
echo "--- PASS: ${label} ---"
33+
pass=$((pass + 1))
34+
else
35+
echo "--- FAIL: ${label} ---"
36+
fail=$((fail + 1))
37+
errors="${errors} ${label}\n"
38+
fi
39+
}
40+
41+
echo "installer.sh test suite"
42+
echo "======================="
43+
44+
# Default flow tests: let the installer auto-detect the install method.
45+
46+
run_test "debian:bookworm (default)" "debian:bookworm" \
47+
"apt-get update -qq && apt-get install -y -qq curl ca-certificates && "
48+
49+
run_test "ubuntu:24.04 (default)" "ubuntu:24.04" \
50+
"apt-get update -qq && apt-get install -y -qq curl ca-certificates && "
51+
52+
run_test "fedora:41 (default)" "fedora:41" \
53+
"yum install -y -q curl && "
54+
55+
run_test "alpine:3.21 (default)" "alpine:3.21" \
56+
"apk add -q --no-cache curl ca-certificates && "
57+
58+
# Raw install test: setting VERSION triggers the raw method on Linux.
59+
if [ -n "$VERSION" ]; then
60+
run_test "debian:bookworm (raw, VERSION=$VERSION)" "debian:bookworm" \
61+
"apt-get update -qq && apt-get install -y -qq curl ca-certificates gzip && " \
62+
-e "VERSION=${VERSION}"
63+
else
64+
echo ""
65+
echo "Skipping raw install test (set VERSION to enable)"
66+
fi
67+
68+
echo ""
69+
echo "======================="
70+
echo "Results: ${pass} passed, ${fail} failed"
71+
72+
if [ "$fail" -gt 0 ]; then
73+
printf "\nFailed:\n%b" "$errors"
74+
exit 1
75+
fi

0 commit comments

Comments
 (0)