solstice-ci/.solstice/job.sh
Till Wegmueller 0b54881558
Add support for multi-OS VM builds with cross-built runners and improved local development tooling
This commit introduces:
- Flexible runner URL configuration via `SOLSTICE_RUNNER_URL(S)` for cloud-init.
- Automated detection of OS-specific runner binaries during VM boot.
- Tasks for cross-building, serving, and orchestrating Solstice runners.
- End-to-end VM build flows for Linux and Illumos environments.
- Enhanced orchestration with multi-runner HTTP serving and log streaming.
2025-11-01 14:31:48 +01:00

87 lines
3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Solstice CI VM job script: build this repository inside the guest.
# The runner clones the repo at the requested commit and executes this script.
# It attempts to ensure required tools (git, curl, protobuf compiler, Rust) exist.
log() { printf "[job] %s\n" "$*" >&2; }
detect_pm() {
if command -v apt-get >/dev/null 2>&1; then echo apt; return; fi
if command -v dnf >/dev/null 2>&1; then echo dnf; return; fi
if command -v yum >/dev/null 2>&1; then echo yum; return; fi
if command -v zypper >/dev/null 2>&1; then echo zypper; return; fi
if command -v apk >/dev/null 2>&1; then echo apk; return; fi
if command -v pacman >/dev/null 2>&1; then echo pacman; return; fi
if command -v pkg >/dev/null 2>&1; then echo pkg; return; fi
if command -v pkgin >/dev/null 2>&1; then echo pkgin; return; fi
echo none
}
install_linux() {
PM=$(detect_pm)
case "$PM" in
apt)
sudo -n true 2>/dev/null || true
sudo apt-get update -y || apt-get update -y || true
sudo apt-get install -y --no-install-recommends curl ca-certificates git build-essential pkg-config libssl-dev protobuf-compiler || true
;;
dnf)
sudo dnf install -y curl ca-certificates git gcc gcc-c++ make pkgconf-pkg-config openssl-devel protobuf-compiler || true
;;
yum)
sudo yum install -y curl ca-certificates git gcc gcc-c++ make pkgconfig openssl-devel protobuf-compiler || true
;;
zypper)
sudo zypper --non-interactive install curl ca-certificates git gcc gcc-c++ make pkg-config libopenssl-devel protobuf || true
;;
apk)
sudo apk add --no-cache curl ca-certificates git build-base pkgconfig openssl-dev protoc || true
;;
pacman)
sudo pacman -Sy --noconfirm curl ca-certificates git base-devel pkgconf openssl protobuf || true
;;
*)
log "unknown package manager ($PM); skipping linux deps install"
;;
esac
}
install_illumos() {
if command -v pkg >/dev/null 2>&1; then
# OpenIndiana IPS packages (best-effort)
sudo pkg refresh || true
sudo pkg install -v developer/build/gnu-make developer/gcc-13 git developer/protobuf || true
elif command -v pkgin >/dev/null 2>&1; then
sudo pkgin -y install git gcc gmake protobuf || true
else
log "no known package manager found on illumos"
fi
}
ensure_rust() {
if command -v cargo >/dev/null 2>&1; then return 0; fi
log "installing Rust toolchain with rustup"
curl -fsSL https://sh.rustup.rs | sh -s -- -y
# shellcheck disable=SC1091
source "$HOME/.cargo/env"
}
main() {
OS=$(uname -s 2>/dev/null || echo unknown)
case "$OS" in
Linux) install_linux ;;
SunOS) install_illumos ;;
esac
ensure_rust
# Ensure protoc available in PATH
if ! command -v protoc >/dev/null 2>&1; then
log "WARNING: protoc not found; prost/tonic build may fail"
fi
# Build a representative subset to avoid known sea-orm-cli issues in full workspace builds
log "building workflow-runner"
cargo build -p workflow-runner --release || cargo build -p workflow-runner
log "done"
}
main "$@"