ci: 迁移本地 runner 并优化并行检查

This commit is contained in:
que01 committed 2026-10-23 15:40:50 +08:00
1 parent 371689484e
commit 965dd10219
6 files changed
+69 -35

No files matched your search

+16 -6
View File
@@ -10,22 +10,28 @@
# RUNNER_TOKEN 仓库 Settings → Actions → Runners 里生成的注册 token
# 可选:
# RUNNER_NAME runner 名称,默认取 hostname
# RUNNER_LABELS 默认 ubuntu-latest,oracle-arm
# RUNNER_LABELS 默认 ubuntu-latest
# RUNNER_VERSION 默认 5.2.0
# RUNNER_ROOT 默认 $HOME/gitea-runner
# RUNNER_CAPACITY 默认 1,按 runner 主机资源设置并发数
# RUNNER_CONTAINER_OPTIONS 默认 "--cpus=1.5 --memory=4g"
# CACHE_PORT 默认 8193
# RUNNER_CACHE_HOST 默认 172.17.0.1(Docker 默认 bridge 网关)
# SKIP_LINGER 默认 0;设为 1 时不尝试用 sudo 开启 linger
set -euo pipefail
GITEA_URL=${GITEA_URL:?需要设置 GITEA_URL}
RUNNER_TOKEN=${RUNNER_TOKEN:?需要设置 RUNNER_TOKEN}
RUNNER_NAME=${RUNNER_NAME:-$(hostname -s)}
RUNNER_LABELS=${RUNNER_LABELS:-ubuntu-latest,oracle-arm}
RUNNER_LABELS=${RUNNER_LABELS:-ubuntu-latest}
RUNNER_VERSION=${RUNNER_VERSION:-5.2.0}
RUNNER_ROOT=${RUNNER_ROOT:-$HOME/gitea-runner}
RUNNER_CAPACITY=${RUNNER_CAPACITY:-1}
RUNNER_CONTAINER_OPTIONS=${RUNNER_CONTAINER_OPTIONS:-"--cpus=1.5 --memory=4g"}
CACHE_PORT=${CACHE_PORT:-8193}
RUNNER_CACHE_HOST=${RUNNER_CACHE_HOST:-172.17.0.1}
CACHE_DIR=${CACHE_DIR:-$RUNNER_ROOT/cache-data}
SKIP_LINGER=${SKIP_LINGER:-0}
DRY_RUN=${DRY_RUN:-0}
if [ "$DRY_RUN" != "1" ]; then
@@ -57,6 +63,7 @@ if [ ! -x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" ]; then
run env -C "$RUNNER_ROOT" sha256sum -c "$archive.sha256"
run xz -d -f "$RUNNER_ROOT/$archive"
fi
run chmod +x "$RUNNER_ROOT/gitea-runner-${RUNNER_VERSION}-linux-${ARCH}"
run ln -sf "gitea-runner-${RUNNER_VERSION}-linux-${ARCH}" "$RUNNER_ROOT/gitea-runner"
if [ ! -f "$RUNNER_ROOT/.runner" ]; then
@@ -76,7 +83,7 @@ log:
level: debug
runner:
file: .runner
capacity: 1
capacity: ${RUNNER_CAPACITY}
timeout: 2h
fetch_timeout: 10s
fetch_interval: 2s
@@ -88,7 +95,7 @@ cache:
host: ${RUNNER_CACHE_HOST}
port: ${CACHE_PORT}
container:
options: "--cpus=1.5 --memory=4g"
options: "${RUNNER_CONTAINER_OPTIONS}"
valid_volumes: []
docker_host: "-"
CONFIG
@@ -111,8 +118,11 @@ WantedBy=default.target
UNIT
# 用户级 systemd 服务默认在最后一个会话退出后停止;开启 linger 才能在重启后自动拉起 runner。
if command -v loginctl >/dev/null 2>&1; then
run sudo loginctl enable-linger "$USER"
if [ "$SKIP_LINGER" != "1" ] && command -v loginctl >/dev/null 2>&1; then
linger=$(loginctl show-user "$USER" -p Linger --value 2>/dev/null || true)
if [ "$linger" != "yes" ]; then
run sudo loginctl enable-linger "$USER"
fi
fi
run systemctl --user daemon-reload
run systemctl --user enable --now gitea-runner.service