Skip to content

ci(release): test installer in disposable environments - #762

Open
ajulaybeeb wants to merge 1 commit into
Nanle-code:masterfrom
ajulaybeeb:ci/656-installer-tests
Open

ci(release): test installer in disposable environments#762
ajulaybeeb wants to merge 1 commit into
Nanle-code:masterfrom
ajulaybeeb:ci/656-installer-tests

Conversation

@ajulaybeeb

@ajulaybeeb ajulaybeeb commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • Add tests/installer/test_install.sh — a self-contained shell test suite for install.sh with 10 scenarios covering clean install, upgrade, checksum failure, download failure, unsupported OS/arch, empty tag, temp-file cleanup, and success message
  • Add .github/workflows/installer-tests.yml — CI workflow that runs the suite on ubuntu-latest and macos-latest, plus a shellcheck lint job
  • Harden install.sh with set -euo pipefail, a WORK_DIR temp dir (auto-cleaned on exit), actionable error messages, an INSTALL_DIR override, and uninstall guidance
  • Update README.md with a platform compatibility table, security note, checksum verification instructions, custom INSTALL_DIR usage, and uninstall steps

Why

Issue #656 requires that install.sh and the release CI be tested in disposable environments. Previously, the installer had no automated tests: there was no way to catch regressions in checksum verification, error handling, or platform detection without running against a real release. The installer also had several gaps: set -e without pipefail, temp files written to the current directory (left behind on failure), no INSTALL_DIR override, and no uninstall guidance.

Implementation

tests/installer/test_install.sh (new, 10 tests)

The test harness builds a patched copy of install.sh in a mktemp directory where the three curl calls are replaced by configurable stub functions embedded directly in the patched script (no export -f required). Each test runs in an isolated sub-shell with its own fake_bin target and STUB_* environment variables:

Test Category
test_clean_install_succeeds Primary flow
test_upgrade_replaces_existing_binary Primary flow
test_checksum_mismatch_fails Failure path
test_download_failure_exits_nonzero Failure path
test_empty_tag_exits_nonzero Failure path
test_unsupported_os_exits_nonzero Failure path
test_unsupported_arch_exits_nonzero Failure path
test_no_temp_files_left_after_success Boundary
test_success_message_contains_version Boundary
test_checksum_download_failure_exits_nonzero Boundary

.github/workflows/installer-tests.yml (new)

  • installer-linuxubuntu-latest, runs bash tests/installer/test_install.sh
  • installer-macosmacos-latest, runs bash tests/installer/test_install.sh
  • installer-shellcheck — lints both install.sh and the test suite with shellcheck -S warning
  • Triggered on push/pull_request that touch install.sh or tests/installer/, plus workflow_call

install.sh

  • set -euo pipefail (was set -e)
  • Downloads archive and checksum to a WORK_DIR=$(mktemp -d) with an EXIT trap — no temp files left on failure
  • INSTALL_DIR env-var override (tests override to a local fake_bin)
  • Inline || { echo "..."; exit 1; } error handlers (enables line-level sed patching)
  • Expanded user-facing error messages for every failure mode
  • Prints uninstall command on success

README.md

  • Platform compatibility table (Linux x86_64/aarch64, macOS x86_64/aarch64, Windows note)
  • Security note with manual checksum verification instructions
  • INSTALL_DIR override example
  • Uninstall instructions

Testing

bash tests/installer/test_install.sh

StarForge installer tests ──────────────────────────────────────────────── [PASS] test_clean_install_succeeds [PASS] test_upgrade_replaces_existing_binary [PASS] test_checksum_mismatch_fails [PASS] test_download_failure_exits_nonzero [PASS] test_empty_tag_exits_nonzero [PASS] test_unsupported_os_exits_nonzero [PASS] test_unsupported_arch_exits_nonzero [PASS] test_no_temp_files_left_after_success [PASS] test_success_message_contains_version [PASS] test_checksum_download_failure_exits_nonzero ──────────────────────────────────────────────── Results: 10 tests, 0 failed

Not tested: Full macOS CI run — validated by installer-macos job in this PR once merged.

Scope / Risk

  • Risk: Low — no Rust code or business logic changed; changes are limited to the shell installer, its test suite, a new CI workflow, and README docs
  • Breaking change: None — install.sh remains backward compatible; the new INSTALL_DIR variable is opt-in
  • Affected area: install.sh, tests/installer/, .github/workflows/installer-tests.yml, README.md

Issue

Closes #656

Add a self-contained shell test suite and a dedicated GitHub Actions
workflow to exercise install.sh without network access, root, or real
release artifacts.

Tests (tests/installer/test_install.sh) — 10 scenarios:
  Primary flow
  - Clean install: downloads, verifies checksum, and installs the binary
  - Upgrade: a second install run replaces an already-present binary

  Boundary cases
  - Success message contains the resolved version tag
  - No temporary files (archive, checksums.txt) left behind after exit

  Failure paths
  - Checksum mismatch: installer aborts before moving the binary
  - Download failure: curl stub returns non-zero; installer exits non-zero
  - Empty release tag: installer prints an actionable error and exits
  - Unsupported OS (FreeBSD stub): installer exits 1 with a clear message
  - Unsupported architecture (mips stub): same
  - Checksum download failure: installer exits 1 before extraction

Test strategy:
  - make_patched_installer() produces a copy of install.sh where each of
    the three curl calls is replaced by an inline stub function.
  - Stubs are embedded via printf into the patched script so child bash
    processes inherit them without needing export -f.
  - Tests run in mktemp sub-directories; the suite EXIT trap cleans up.
  - INSTALL_DIR is overridden to a local fake_bin so no sudo is needed.

CI workflow (.github/workflows/installer-tests.yml):
  - installer-linux: ubuntu-latest, runs full test suite
  - installer-macos: macos-latest, runs full test suite
  - installer-shellcheck: lints install.sh and the test script with
    shellcheck -S warning
  - Workflow triggers on pushes/PRs that touch install.sh or the test
    directory, plus workflow_call for use as a dependency.

install.sh improvements:
  - set -euo pipefail (was set -e only)
  - INSTALL_DIR env-var override for tests and headless installs
  - Inline || { ...; exit 1; } error handlers (enables line-level patching)
  - Downloads archive and checksums into an auto-cleaned WORK_DIR temp dir
    instead of the current directory — eliminates temp-file leaks on failure
  - Expanded error messages with actionable guidance for unsupported OS,
    unsupported arch, missing curl, empty release tag, download failure,
    and checksum download failure
  - Uninstall instruction printed on success

README.md:
  - Documents checksum verification, security note, platform compatibility
    table, custom INSTALL_DIR, and uninstall instructions

Closes Nanle-code#656
@drips-wave

drips-wave Bot commented Aug 25, 2026

Copy link
Copy Markdown

@ajulaybeeb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Manuelshub

Copy link
Copy Markdown
Collaborator

@ajulaybeeb Please make sure to fix CI issues, very important!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2026 Release] Test the installer in disposable environments

2 participants