105 lines
4.0 KiB
Bash
Executable File
105 lines
4.0 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
GITEA_URL='https://git.faumaray.com'
|
|
RUNNER_VERSION='5.0.0'
|
|
WORK_DIR="$HOME/gitea-runner"
|
|
TEMP_TOKEN="$(mktemp)"
|
|
trap 'rm -f "$TEMP_TOKEN"' EXIT
|
|
chmod 600 "$TEMP_TOKEN"
|
|
|
|
if [[ "$(uname -m)" != "x86_64" ]]; then
|
|
echo "Expected an x86_64 macOS guest; got $(uname -m)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if ! xcode-select -p >/dev/null 2>&1; then
|
|
echo 'Install Xcode Command Line Tools first: sudo xcode-select --install'
|
|
exit 1
|
|
fi
|
|
|
|
if ! command -v brew >/dev/null 2>&1; then
|
|
echo 'Installing Homebrew non-interactively; sudo may ask for the guest account password.'
|
|
NONINTERACTIVE=1 /bin/bash -c "$(curl --fail --location --silent --show-error https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
fi
|
|
if [[ -x /usr/local/bin/brew ]]; then
|
|
eval "$(/usr/local/bin/brew shellenv)"
|
|
elif [[ -x /opt/homebrew/bin/brew ]]; then
|
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
fi
|
|
if ! command -v brew >/dev/null 2>&1; then
|
|
echo 'Homebrew installation did not provide a brew executable on PATH.' >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Homebrew supplies GCC 16.x (contracts + P2996 reflection), build tools and MoltenVK.
|
|
brew update
|
|
brew install gcc cmake ninja rustup-init vulkan-headers vulkan-loader vulkan-tools molten-vk node git git-lfs
|
|
rustup-init -y --default-toolchain stable --no-modify-path
|
|
export PATH="$HOME/.cargo/bin:$(brew --prefix)/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
"$HOME/.cargo/bin/rustup" toolchain install stable
|
|
"$HOME/.cargo/bin/rustup" default stable
|
|
|
|
GXX="$(brew --prefix gcc)/bin/g++-16"
|
|
if [[ ! -x "$GXX" ]]; then
|
|
echo "GCC 16 was not found at $GXX; refusing to register a runner without the required toolchain." >&2
|
|
exit 1
|
|
fi
|
|
|
|
"$GXX" --version
|
|
"$GXX" -std=c++26 -fcontracts -freflection -fcontract-evaluation-semantic=enforce \
|
|
"$(dirname "$0")/cxx26-feature-probe.cpp" -o "$TMPDIR/cxx26-feature-probe"
|
|
"$TMPDIR/cxx26-feature-probe"
|
|
|
|
mkdir -p "$WORK_DIR" "$HOME/Library/Logs"
|
|
cd "$WORK_DIR"
|
|
curl --fail --location --silent --show-error \
|
|
"https://dl.gitea.com/gitea-runner/${RUNNER_VERSION}/gitea-runner-${RUNNER_VERSION}-darwin-amd64" \
|
|
-o "$WORK_DIR/gitea-runner"
|
|
chmod 0755 "$WORK_DIR/gitea-runner"
|
|
|
|
read -r -s -p 'Gitea runner registration token: ' GITEA_TOKEN
|
|
echo
|
|
printf '%s' "$GITEA_TOKEN" > "$TEMP_TOKEN"
|
|
unset GITEA_TOKEN
|
|
"$WORK_DIR/gitea-runner" register --no-interactive \
|
|
--instance "$GITEA_URL" --token-file "$TEMP_TOKEN" \
|
|
--name 'ci-macos-x64' --labels 'macos-x64:host'
|
|
|
|
# LaunchDaemon runs at guest boot; jobs are executed as the account used to run this script.
|
|
PLIST_TMP="$(mktemp)"
|
|
cat > "$PLIST_TMP" <<PLIST
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
<plist version="1.0">
|
|
<dict>
|
|
<key>Label</key><string>com.gitea.runner</string>
|
|
<key>ProgramArguments</key>
|
|
<array>
|
|
<string>${WORK_DIR}/gitea-runner</string>
|
|
<string>daemon</string>
|
|
</array>
|
|
<key>WorkingDirectory</key><string>${WORK_DIR}</string>
|
|
<key>RunAtLoad</key><true/>
|
|
<key>KeepAlive</key><true/>
|
|
<key>StandardOutPath</key><string>${HOME}/Library/Logs/gitea-runner.log</string>
|
|
<key>StandardErrorPath</key><string>${HOME}/Library/Logs/gitea-runner.err</string>
|
|
<key>EnvironmentVariables</key>
|
|
<dict><key>PATH</key><string>${HOME}/.cargo/bin:$(brew --prefix)/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
|
|
<key>HOME</key><string>${HOME}</string></dict>
|
|
<key>UserName</key><string>$(id -un)</string>
|
|
</dict>
|
|
</plist>
|
|
PLIST
|
|
sudo install -o root -g wheel -m 0644 "$PLIST_TMP" /Library/LaunchDaemons/com.gitea.runner.plist
|
|
rm -f "$PLIST_TMP"
|
|
sudo launchctl bootout system /Library/LaunchDaemons/com.gitea.runner.plist >/dev/null 2>&1 || true
|
|
sudo launchctl bootstrap system /Library/LaunchDaemons/com.gitea.runner.plist
|
|
|
|
cat <<'DONE'
|
|
macOS Gitea runner registered and LaunchDaemon installed.
|
|
Runner label: macos-x64
|
|
Compiler gate: GCC 16 C++26 contracts + reflection compile/run passed.
|
|
Vulkan: Vulkan tools + MoltenVK installed. A VM's virtual GPU is not a substitute for physical-GPU validation.
|
|
DONE
|