b6fdee8bfc
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
163 lines
7.1 KiB
Bash
Executable File
163 lines
7.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# scripts/ci-local.sh
|
|
# Local Docker mirror of bitbucket-pipelines.yml — run the Linux CI steps on
|
|
# your own machine before pushing, so most breaks are caught without spending
|
|
# BitBucket build minutes. This is the fast half of the hybrid CI: local Docker
|
|
# for every push, BitBucket only at real gates (merge to develop/main, releases)
|
|
# for the authoritative x86_64 run + status check.
|
|
#
|
|
# Usage:
|
|
# scripts/ci-local.sh # native (host arch, e.g. arm64) — fast
|
|
# scripts/ci-local.sh --amd64 # emulate x86_64 (qemu) to match BitBucket
|
|
# scripts/ci-local.sh --livecompile # also build the LiveCompile sub-package
|
|
# scripts/ci-local.sh --clean # discard the cached build tree first
|
|
# scripts/ci-local.sh --amd64 --livecompile --clean # flags combine
|
|
#
|
|
# Why --amd64: your dev machine is arm64; BitBucket's runners are x86_64. arm64
|
|
# Docker misses x86-only breaks (flush-to-zero, alignment, codegen). The native
|
|
# run catches ~all logic breaks in a fraction of the time; do one --amd64 pass
|
|
# before a release/merge to catch the arch-specific ones without hosted minutes.
|
|
#
|
|
# --livecompile builds the LiveCompile sub-package + the Linux scratch demo
|
|
# against the local SwiftOpenUI fork (LYREBIRD_SWIFTOPENUI_LOCAL). This is NOT
|
|
# part of the hosted pipeline (the pipeline builds the main package only), so it
|
|
# is opt-in here — and it lets the whole run resolve against the fork checkout
|
|
# even before a fork release tag is pushed.
|
|
#
|
|
# Build cache: the Linux build tree lives in a per-arch NAMED DOCKER VOLUME
|
|
# (lyrebird-ci-build-<arch>, plus lyrebird-ci-live-<arch> for --livecompile),
|
|
# NOT in the repo's ./.build. That keeps Linux artifacts off your host (no macOS
|
|
# ./.build pollution, no "module cache compiled with path X" breakage from a
|
|
# changing mount point) while still persisting the cache between runs. --clean
|
|
# just deletes those volumes.
|
|
#
|
|
# Env overrides:
|
|
# LYREBIRD_CI_IMAGE Docker image (default lyrebird-linux-full:local)
|
|
# LYREBIRD_SWIFTOPENUI_LOCAL_HOST fork path for --livecompile
|
|
# (default ~/Documents/src/SwiftOpenUI)
|
|
#
|
|
# Network: a cold run clones the package dependencies (swift-docc-plugin, Nimble,
|
|
# …) from GitHub, exactly as the hosted pipeline does — so the first run needs
|
|
# internet. The per-arch build volume then caches them, so later runs (and
|
|
# --amd64 after its first) are offline-capable until you --clean.
|
|
#
|
|
# Requires: Docker, and the lyrebird-linux-full:local image. The image does not
|
|
# ship libgtksourceview-5-dev, so the run apt-installs the GTK dev packages
|
|
# (idempotent) exactly as the hosted pipeline does — bake them into a dedicated
|
|
# image later if the per-run apt cost becomes annoying.
|
|
set -euo pipefail
|
|
|
|
IMAGE="${LYREBIRD_CI_IMAGE:-lyrebird-linux-full:local}"
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
FORK_HOST="${LYREBIRD_SWIFTOPENUI_LOCAL_HOST:-$HOME/Documents/src/SwiftOpenUI}"
|
|
|
|
# The repo is always mounted at the SAME container path (/work) so SwiftPM's
|
|
# precompiled module cache — which bakes in the absolute path — stays valid.
|
|
MOUNT_PATH="/work"
|
|
|
|
PLATFORM_ARGS=()
|
|
ARCH_TAG="$(uname -m)" # arm64 / x86_64 for native
|
|
ARCH_LABEL="native ($ARCH_TAG)"
|
|
RUN_LIVECOMPILE=0
|
|
RUN_CLEAN=0
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--amd64) PLATFORM_ARGS=(--platform linux/amd64); ARCH_TAG="amd64"; ARCH_LABEL="emulated linux/amd64" ;;
|
|
--livecompile) RUN_LIVECOMPILE=1 ;;
|
|
--clean) RUN_CLEAN=1 ;;
|
|
-h|--help) sed -n '2,45p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
|
*) echo "unknown arg: $arg (try --help)" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
BUILD_VOL="lyrebird-ci-build-${ARCH_TAG}"
|
|
LIVE_VOL="lyrebird-ci-live-${ARCH_TAG}"
|
|
|
|
echo "== Lyrebird local CI =="
|
|
echo "image: $IMAGE"
|
|
echo "arch: $ARCH_LABEL"
|
|
echo "repo mount: $REPO_ROOT -> $MOUNT_PATH (source only; build tree in volume $BUILD_VOL)"
|
|
echo "livecompile: $RUN_LIVECOMPILE clean: $RUN_CLEAN"
|
|
echo
|
|
|
|
if [[ "$RUN_CLEAN" == 1 ]]; then
|
|
echo "== clean: removing build-cache volumes =="
|
|
docker volume rm -f "$BUILD_VOL" "$LIVE_VOL" >/dev/null 2>&1 || true
|
|
fi
|
|
|
|
# The main-package steps, verbatim from bitbucket-pipelines.yml (only the
|
|
# no-ALSA scratch path is redirected under the build volume so it doesn't land
|
|
# in the source tree).
|
|
read -r -d '' PIPELINE <<'EOF' || true
|
|
set -euo pipefail
|
|
mkdir -p "$HOME/.cache"
|
|
swift --version
|
|
apt-get update && apt-get install -y --no-install-recommends libgtk-4-dev libgtksourceview-5-dev libfontconfig-dev libasound2-dev pkg-config
|
|
echo "== core build gate =="
|
|
swift build --target LyrebirdSynth --target LyrebirdGraphDSL --target LyrebirdCLI
|
|
echo "== UI build gate (LyrebirdUILinuxDemo) =="
|
|
swift build --product LyrebirdUILinuxDemo
|
|
echo "== swift test =="
|
|
swift test
|
|
echo "== swift test (LYREBIRD_DISABLE_ALSA) =="
|
|
LYREBIRD_DISABLE_ALSA=1 swift test --scratch-path /work/.build/noalsa
|
|
EOF
|
|
|
|
if [[ "$RUN_LIVECOMPILE" == 1 ]]; then
|
|
PIPELINE="$PIPELINE"'
|
|
echo "== LiveCompile sub-package (against local fork /fork) =="
|
|
cd /work/LiveCompile
|
|
swift build
|
|
swift build --product LyrebirdScratchLinuxDemo
|
|
echo "== LiveCompile tests =="
|
|
# --no-parallel + a hard timeout: a snippet-compiling test that fails to build
|
|
# can otherwise hang forever awaiting a callback (see the LiveCompile notes).
|
|
timeout --signal=KILL 1200 swift test --no-parallel'
|
|
fi
|
|
|
|
# The repo is mounted writable because SwiftPM writes Package.resolved at the
|
|
# package root during resolution. The build trees live in the named volumes, so
|
|
# the only thing a run can touch in the working copy is Package.resolved — which
|
|
# a plain (non-livecompile) run's Linux resolve rewrites to add the by-URL
|
|
# SwiftOpenUI pin. Restore it after the run (below) so the working copy stays
|
|
# clean. (A --livecompile run resolves the fork as a path dependency, which
|
|
# doesn't appear in Package.resolved, so there is nothing to restore there.)
|
|
# HOME points at a fresh dir inside the build volume so SwiftPM's global package
|
|
# cache (~/.cache/org.swift.swiftpm) is clean and writable — the base image
|
|
# ships an inconsistent one that makes a cold `swift build` fail resolving
|
|
# swift-docc-plugin ("cannot change to .../repositories/...: No such file").
|
|
# Living in the volume, it also persists warm between runs.
|
|
DOCKER_ARGS=(--rm)
|
|
[[ ${#PLATFORM_ARGS[@]} -gt 0 ]] && DOCKER_ARGS+=("${PLATFORM_ARGS[@]}")
|
|
DOCKER_ARGS+=(
|
|
-v "$REPO_ROOT:$MOUNT_PATH"
|
|
-v "$BUILD_VOL:$MOUNT_PATH/.build"
|
|
-e "HOME=$MOUNT_PATH/.build/home"
|
|
)
|
|
|
|
if [[ "$RUN_LIVECOMPILE" == 1 ]]; then
|
|
if [[ ! -d "$FORK_HOST" ]]; then
|
|
echo "livecompile: fork not found at $FORK_HOST" >&2
|
|
echo " set LYREBIRD_SWIFTOPENUI_LOCAL_HOST to the SwiftOpenUI fork path." >&2
|
|
exit 3
|
|
fi
|
|
DOCKER_ARGS+=(
|
|
-v "$FORK_HOST:/fork:ro"
|
|
-v "$LIVE_VOL:$MOUNT_PATH/LiveCompile/.build"
|
|
-e LYREBIRD_SWIFTOPENUI_LOCAL=/fork
|
|
)
|
|
fi
|
|
|
|
# Keep the working copy clean regardless of how the run exits: a plain run's
|
|
# Linux resolve rewrites Package.resolved (adds the by-URL SwiftOpenUI pin).
|
|
restore_resolved() {
|
|
git -C "$REPO_ROOT" checkout -- Package.resolved 2>/dev/null || true
|
|
}
|
|
trap restore_resolved EXIT
|
|
|
|
docker run "${DOCKER_ARGS[@]}" -w "$MOUNT_PATH" "$IMAGE" bash -lc "$PIPELINE"
|
|
|
|
echo
|
|
echo "== local CI PASSED ($ARCH_LABEL) =="
|