-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add installer.sh test automation #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3bd37b5
ci: add installer.sh test automation
pjcdawkins 86cbbf0
fix(scripts): show Docker output in installer test script
pjcdawkins 2899ea1
feat: add VERSION option to installer test script and workflow
pjcdawkins 537e76e
fix(ci): address review comments on installer test PR
pjcdawkins fb9b122
refactor(ci): test default installer flow per distro
pjcdawkins 863253a
ci: update actions/checkout to v6
pjcdawkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| name: Test installer.sh | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'CLI version to install for raw tests (leave empty for latest release)' | ||
| required: false | ||
| type: string | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - installer.sh | ||
| - .github/workflows/test-installer.yml | ||
| pull_request: | ||
| paths: | ||
| - installer.sh | ||
| - .github/workflows/test-installer.yml | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| # Default install flow: the installer auto-detects the package manager. | ||
| # CI is overridden to empty so that is_ci() returns false (otherwise | ||
| # the installer would always select the "raw" method on Linux). | ||
| linux: | ||
| runs-on: ubuntu-latest | ||
| container: ${{ matrix.image }} | ||
| defaults: | ||
| run: | ||
| shell: sh | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - image: debian:bookworm | ||
| prereqs: apt-get update && apt-get install -y curl ca-certificates | ||
| - image: ubuntu:24.04 | ||
| prereqs: apt-get update && apt-get install -y curl ca-certificates | ||
| - image: fedora:41 | ||
| prereqs: yum install -y curl | ||
| - image: alpine:3.21 | ||
| prereqs: apk add --no-cache curl ca-certificates | ||
|
|
||
| steps: | ||
| - name: Install prerequisites | ||
| run: ${{ matrix.prereqs }} | ||
|
|
||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Run installer | ||
| env: | ||
| CI: "" | ||
| run: sh installer.sh | ||
|
|
||
| - name: Verify installation | ||
| run: upsun --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. | ||
| linux-raw: | ||
| runs-on: ubuntu-latest | ||
| container: debian:bookworm | ||
| defaults: | ||
| run: | ||
| shell: sh | ||
| steps: | ||
| - name: Install prerequisites | ||
| run: apt-get update && apt-get install -y curl ca-certificates gzip | ||
|
|
||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Run installer | ||
| env: | ||
| VERSION: ${{ inputs.version }} | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: sh installer.sh | ||
|
|
||
| - name: Verify installation | ||
| run: upsun --version | ||
|
|
||
| # Default install flow on macOS (auto-detects homebrew). | ||
| macos: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Run installer | ||
| run: sh installer.sh | ||
|
|
||
| - name: Verify installation | ||
| run: upsun --version | ||
|
|
||
| # Raw install on macOS (INSTALL_METHOD is required because VERSION | ||
| # does not affect macOS method selection). | ||
| macos-raw: | ||
| runs-on: macos-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Run installer | ||
| env: | ||
| INSTALL_METHOD: raw | ||
| VERSION: ${{ inputs.version }} | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
| run: sh installer.sh | ||
|
|
||
pjcdawkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Verify installation | ||
| run: upsun --version | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #!/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 a test in a Docker container. | ||
| # Arguments: label, image, prereqs, [extra docker args...] | ||
| run_test() { | ||
| label="$1" | ||
| image="$2" | ||
| prereqs="$3" | ||
| shift 3 | ||
|
|
||
| echo "" | ||
| echo "=== ${label} ===" | ||
|
|
||
| if docker run --rm \ | ||
| -v "$(pwd)/installer.sh:/installer.sh:ro" \ | ||
| "$@" \ | ||
| "$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" | ||
| fi | ||
| } | ||
|
|
||
| echo "installer.sh test suite" | ||
| echo "=======================" | ||
|
|
||
| # Default flow tests: let the installer auto-detect the install method. | ||
|
|
||
| run_test "debian:bookworm (default)" "debian:bookworm" \ | ||
| "apt-get update -qq && apt-get install -y -qq curl ca-certificates && " | ||
|
|
||
| run_test "ubuntu:24.04 (default)" "ubuntu:24.04" \ | ||
| "apt-get update -qq && apt-get install -y -qq curl ca-certificates && " | ||
|
|
||
| run_test "fedora:41 (default)" "fedora:41" \ | ||
| "yum install -y -q curl && " | ||
|
|
||
| run_test "alpine:3.21 (default)" "alpine:3.21" \ | ||
| "apk add -q --no-cache curl ca-certificates && " | ||
|
|
||
| # Raw install test: setting VERSION triggers the raw method on Linux. | ||
| if [ -n "$VERSION" ]; then | ||
| run_test "debian:bookworm (raw, VERSION=$VERSION)" "debian:bookworm" \ | ||
| "apt-get update -qq && apt-get install -y -qq curl ca-certificates gzip && " \ | ||
| -e "VERSION=${VERSION}" | ||
| else | ||
| echo "" | ||
| echo "Skipping raw install test (set VERSION to enable)" | ||
| fi | ||
|
|
||
| echo "" | ||
| echo "=======================" | ||
| echo "Results: ${pass} passed, ${fail} failed" | ||
|
|
||
| if [ "$fail" -gt 0 ]; then | ||
| printf "\nFailed:\n%b" "$errors" | ||
| exit 1 | ||
| fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.