#!/usr/bin/env bash # provision-mac.sh — idempotent provisioning for the macOS host runner. # # Pre-warms everything the build jobs (compile.sh / compile-macos.sh) would # otherwise download at runtime: Flutter macOS+web engine artifacts, pub # packages, Go modules, npm deps. Safe to run on every pipeline run — it # short-circuits via a stamp file keyed to the installed Flutter version, so # once provisioned it returns in milliseconds and downloads nothing. set -euo pipefail SCRIPT_DIR="$(dirname "$0")" # shellcheck source=scripts/ci/_env.sh . "${SCRIPT_DIR}/_env.sh" STAMP_DIR="${HOME}/.cache/jiu-ci" STAMP="${STAMP_DIR}/provisioned-mac" CUR="${STAMP_DIR}/.flutter-version-mac.cur" mkdir -p "$STAMP_DIR" # --- detection: skip if already provisioned for this Flutter version --- if ! command -v flutter >/dev/null 2>&1; then echo "ERROR: flutter not found on PATH. Install Flutter on this runner first." >&2 exit 1 fi flutter --version --machine > "$CUR" 2>/dev/null || flutter --version > "$CUR" 2>&1 || true if [ -s "$STAMP" ] && cmp -s "$STAMP" "$CUR"; then echo "==> provision-mac: already provisioned (Flutter unchanged), skipping." exit 0 fi echo "==> provision-mac: not provisioned (or Flutter changed) — running." # --- toolchain presence (do not auto-install system-level tools) --- for tool in go node npm; do if ! command -v "$tool" >/dev/null 2>&1; then echo "ERROR: '$tool' not found on PATH. Install it on this runner first." >&2 exit 1 fi done # --- warm Flutter platform engines (the macOS SDK download seen in CI) --- echo "==> precache Flutter engines (macos, web)" flutter precache --macos --web --universal # --- warm dependency caches --- echo "==> flutter pub get (client)" (cd "${SCRIPT_DIR}/../../client" && flutter pub get) echo "==> go mod download (backend)" (cd "${SCRIPT_DIR}/../../backend" && go mod download) echo "==> npm ci (web)" (cd "${SCRIPT_DIR}/../../web" && npm ci --prefer-offline) # --- mark provisioned --- cp "$CUR" "$STAMP" echo "==> provision-mac: done." echo "--- versions ---" flutter --version | head -1 go version node --version