Files
BiLauncher/ci/setup-runner-linux.sh
T
galeon 41599fa82f
tests / linux (push) Failing after 2m18s
tests / windows (push) Skipped
tests / macos (push) Skipped
tests / package-smoke-linux (push) Skipped
tests / package-smoke-windows (push) Skipped
tests / package-smoke-macos (push) Skipped
new unit tests, hehe 67
Signed-off-by: galeon <dertiellis@gmail.com>
2026-10-12 13:14:08 +03:00

108 lines
4.7 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Подготовка Linux-раннера Gitea Actions для сборки BiLauncher (Ubuntu 22.04).
#
# Qt (~/Qt/6.11.1/gcc_64 с WebEngine), CMake и Ninja (~/Qt/Tools) ставятся заранее
# через Qt Online Installer — скрипт их не трогает, а докачивает только то, чего Qt
# не даёт: компилятор, системные библиотеки для сборки и деплоя, Node.js (для
# actions/checkout), appimagetool и сам gitea-runner. Повторный запуск безопасен.
#
# Запуск от пользователя, которому принадлежит Qt (нужен sudo без пароля):
# ./setup-runner-linux.sh [токен регистрации]
set -euo pipefail
TOKEN="${1:-}"
INSTANCE="${INSTANCE:-https://projects-live.galeonworx.com}"
RUNNER_NAME="${RUNNER_NAME:-linux-vm}"
RUNNER_VERSION="${RUNNER_VERSION:-4.1.0}"
QT_ROOT="${QT_ROOT:-$HOME/Qt/6.11.1/gcc_64}"
QT_TOOLS="${QT_TOOLS:-$HOME/Qt/Tools}"
RDIR="$HOME/act_runner"
[ -d "$QT_ROOT/lib/cmake/Qt6WebEngineQuick" ] || { echo "Нет Qt с WebEngine в $QT_ROOT" >&2; exit 1; }
# --- Компилятор и библиотеки ---------------------------------------------------
# libgl1-mesa-dev — заголовки OpenGL для Qt6::Gui; xcb-* и прочие — то, что
# Linux-деплой Qt и плагин xcb ищут при упаковке и запуске; libfuse2 — для
# запуска самого appimagetool (он тоже AppImage). ccache ускоряет прогоны
# автотестов (.gitea/workflows/tests.yml), xvfb нужен их дымовой проверке
# установленного дерева, если деплой Qt не положил плагин offscreen.
sudo apt-get update -q
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
build-essential patchelf file curl git xz-utils ccache xvfb python3 \
libgl1-mesa-dev libfuse2 libfontconfig1 libdbus-1-3 \
libxkbcommon-x11-0 libxcb-cursor0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 \
libxcb-render-util0 libxcb-shape0 libxcb-xinerama0 libxcb-xkb1 \
libnss3 libxcomposite1 libxdamage1 libxrandr2 libxtst6 libxkbfile1 libxshmfence1 libasound2
# --- Node.js LTS ---------------------------------------------------------------
if ! command -v node >/dev/null; then
NODE_VER=$(curl -fsSL https://nodejs.org/dist/index.json \
| python3 -c 'import json,sys; print(next(r["version"] for r in json.load(sys.stdin) if r["lts"]))')
curl -fsSL "https://nodejs.org/dist/$NODE_VER/node-$NODE_VER-linux-x64.tar.xz" -o /tmp/node.tar.xz
sudo rm -rf /opt/node && sudo mkdir -p /opt/node
sudo tar -xJf /tmp/node.tar.xz -C /opt/node --strip-components=1
sudo ln -sf /opt/node/bin/node /opt/node/bin/npm /opt/node/bin/npx /usr/local/bin/
fi
# --- appimagetool ----------------------------------------------------------------
if ! command -v appimagetool >/dev/null; then
sudo curl -fsSL -o /usr/local/bin/appimagetool \
https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
sudo chmod +x /usr/local/bin/appimagetool
fi
# --- gitea-runner ------------------------------------------------------------------
mkdir -p "$RDIR/work"
if [ ! -x "$RDIR/gitea-runner" ]; then
curl -fsSL -o "$RDIR/gitea-runner" \
"https://gitea.com/gitea/runner/releases/download/v$RUNNER_VERSION/gitea-runner-$RUNNER_VERSION-linux-amd64"
chmod +x "$RDIR/gitea-runner"
fi
cat > "$RDIR/config.yaml" <<EOF
log:
level: info
runner:
file: $RDIR/.runner
capacity: 1
timeout: 3h
fetch_timeout: 5s
fetch_interval: 2s
envs:
QT_ROOT: $QT_ROOT
QT_TOOLS: $QT_TOOLS
labels:
- "linux:host"
cache:
enabled: false
host:
workdir_parent: $RDIR/work
EOF
if [ -n "$TOKEN" ] && [ ! -f "$RDIR/.runner" ]; then
(cd "$RDIR" && ./gitea-runner register --no-interactive --instance "$INSTANCE" \
--token "$TOKEN" --name "$RUNNER_NAME" --labels "linux:host" --config config.yaml)
fi
# --- systemd: раннер работает от владельца Qt, а не от root ------------------------
sudo tee /etc/systemd/system/gitea-runner.service >/dev/null <<EOF
[Unit]
Description=Gitea Actions runner (BiLauncher)
After=network-online.target
Wants=network-online.target
[Service]
User=$USER
WorkingDirectory=$RDIR
Environment=PATH=/usr/local/bin:/usr/bin:/bin
ExecStart=$RDIR/gitea-runner daemon --config $RDIR/config.yaml
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable --now gitea-runner
echo "Готово: $(systemctl is-active gitea-runner)"