Files
salman 882f594d5a Pass validated runtime artifacts between Gitea build workflows
Fetch an explicit musrfit revision, compile and validate the scientific runtime, and upload its descriptor, archive, and diagnostics. Require a selected runtime workflow run for Linux packaging, verify restoration through the existing offline installer, and upload a complete package set without implicit release publishing.

Fix clean-container ROOT discovery, allow scoped CI container cleanup, support both fpm cache layouts, and cover artifact restoration and build contracts with regression tests.
2026-10-29 16:42:30 +01:00

65 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (C) 2026 Zaher Salman
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Host wrapper: build the runtime image, run the build inside it, and drop the
# relocatable ROOT + musrfit tree into <repo>/runtime for electron-builder.
#
# Requires Docker or Podman. The musrfit checkout is mounted read-only from the
# sibling directory ../musrfit.psi by default; set MUSRFIT_REPO to override.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
MUSRFIT_REPO="${MUSRFIT_REPO:-$(cd "$REPO/.." && pwd)/musrfit.psi}"
ROOT_VERSION="${ROOT_VERSION:-6.38.00}"
ROOT_SOURCE="${ROOT_SOURCE:-build}"
BASE_IMAGE="${BASE_IMAGE:-quay.io/pypa/manylinux_2_28_x86_64}"
IMAGE="${IMAGE:-musrflow-runtime-builder}"
JOBS="${JOBS:-$(nproc)}"
# Honour an explicit ENGINE=docker|podman; otherwise pick the first engine that
# is both installed and usable (a rootless podman is preferred over a docker
# daemon the user cannot reach).
ENGINE="${ENGINE:-}"
if [ -z "$ENGINE" ]; then
if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then
ENGINE=docker
elif command -v podman >/dev/null 2>&1 && podman info >/dev/null 2>&1; then
ENGINE=podman
else
echo "ERROR: no usable docker or podman engine (set ENGINE to override)" >&2
exit 1
fi
fi
echo "Using container engine: $ENGINE"
if [ ! -d "$MUSRFIT_REPO" ]; then
echo "ERROR: musrfit checkout not found at $MUSRFIT_REPO (set MUSRFIT_REPO)" >&2
exit 1
fi
echo "Building image $IMAGE from $BASE_IMAGE"
"$ENGINE" build --build-arg "BASE_IMAGE=$BASE_IMAGE" -t "$IMAGE" "$HERE"
echo "Building runtime into $REPO/runtime"
run_options=(--rm)
if [ -n "${CONTAINER_NAME:-}" ]; then
run_options+=(--name "$CONTAINER_NAME")
fi
"$ENGINE" run "${run_options[@]}" \
-v "$REPO:/work" \
-v "$MUSRFIT_REPO:/src/musrfit:ro" \
-e "ROOT_VERSION=$ROOT_VERSION" \
-e "ROOT_SOURCE=$ROOT_SOURCE" \
-e "ROOT_BINARY_URL=${ROOT_BINARY_URL:-}" \
-e "BASE_IMAGE=$BASE_IMAGE" \
-e "MUSRFIT_REPO=/src/musrfit" \
-e "PREFIX=/work/runtime" \
-e "JOBS=$JOBS" \
"$IMAGE"
echo "Done. Runtime written to $REPO/runtime"