Skip to content

Commit f9c12af

Browse files
committed
feat: add visionfive2 runner
1 parent cfdc506 commit f9c12af

1 file changed

Lines changed: 72 additions & 1 deletion

File tree

runner.sh

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ fi
3939
RUNNER_GROUP="${RUNNER_GROUP:-Default}"
4040
RUNNER_WORKDIR="${RUNNER_WORKDIR:-}"
4141
RUNNER_LABELS="${RUNNER_LABELS:-intel}"
42-
RUNNER_BOARD="3"
42+
RUNNER_BOARD="4"
4343
DISABLE_AUTO_UPDATE="${DISABLE_AUTO_UPDATE:-false}"
4444
# 板子级:未设置时用本板默认值(同类型板串行、不同类型板并行);多组织共享同一块板时显式设为相同 ID 即可
4545
RUNNER_RESOURCE_ID_PHYTIUMPI="${RUNNER_RESOURCE_ID_PHYTIUMPI:-}"
4646
RUNNER_RESOURCE_ID_ROC_RK3568_PC="${RUNNER_RESOURCE_ID_ROC_RK3568_PC:-}"
4747
RUNNER_RESOURCE_ID_X86_64_PC="${RUNNER_RESOURCE_ID_X86_64_PC:-}"
48+
RUNNER_RESOURCE_ID_VISIONFIVE2="${RUNNER_RESOURCE_ID_VISIONFIVE2:-}"
4849
RUNNER_LOCK_DIR="${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}"
4950
RUNNER_LOCK_HOST_PATH="${RUNNER_LOCK_HOST_PATH:-/tmp/github-runner-locks}"
5051
# Compose 文件名:未显式设置时自动拼入 ORG/REPO,避免同一主机多组织时文件冲突
@@ -147,6 +148,7 @@ shell_usage() {
147148
printf " %-${KEYW}s %s\n" "RUNNER_RESOURCE_ID_PHYTIUMPI" "Lock ID for phytiumpi board (default: board-phytiumpi); same ID = serial across runners"
148149
printf " %-${KEYW}s %s\n" "RUNNER_RESOURCE_ID_ROC_RK3568_PC" "Lock ID for roc-rk3568-pc board (default: board-roc-rk3568-pc); same ID = serial"
149150
printf " %-${KEYW}s %s\n" "RUNNER_RESOURCE_ID_X86_64_PC" "Lock ID for x86_64-pc board (default: board-x86_64-pc); same ID = serial"
151+
printf " %-${KEYW}s %s\n" "RUNNER_RESOURCE_ID_VISIONFIVE2" "Lock ID for visionfive2 board (default: board-visionfive2); same ID = serial"
150152
printf " %-${KEYW}s %s\n" "RUNNER_LOCK_DIR" "Lock dir in container (default /tmp/github-runner-locks)"
151153
printf " %-${KEYW}s %s\n" "RUNNER_LOCK_HOST_PATH" "Lock dir on host for bind mount (default /tmp/github-runner-locks)"
152154
echo
@@ -988,6 +990,8 @@ shell_generate_compose_file() {
988990
local res_roc="${RUNNER_RESOURCE_ID_ROC_RK3568_PC:-board-roc-rk3568-pc}"
989991
# 硬件板 x86_64 - 总是启用文件锁
990992
local res_x86_64="${RUNNER_RESOURCE_ID_X86_64_PC:-board-x86_64-pc}"
993+
# 硬件板 visionfive2 - 总是启用文件锁
994+
local res_visionfive2="${RUNNER_RESOURCE_ID_VISIONFIVE2:-board-visionfive2}"
991995

992996
# ════════════════════════════════════════════════════════════════
993997
# 第二步:两种板子 runner 类型的 entrypoint 配置
@@ -998,10 +1002,12 @@ shell_generate_compose_file() {
9981002
local runner_entrypoint_phytiumpi="/home/runner/run.sh"
9991003
local runner_entrypoint_roc="/home/runner/run.sh"
10001004
local runner_entrypoint_x86_64="/home/runner/run.sh"
1005+
local runner_entrypoint_visionfive2="/home/runner/run.sh"
10011006
# 若设置了资源 ID,则改用 runner-wrapper 来处理文件锁
10021007
[[ -n "$res_phytiumpi" ]] && runner_entrypoint_phytiumpi="/home/runner/runner-wrapper/runner-wrapper.sh"
10031008
[[ -n "$res_roc" ]] && runner_entrypoint_roc="/home/runner/runner-wrapper/runner-wrapper.sh"
10041009
[[ -n "$res_x86_64" ]] && runner_entrypoint_x86_64="/home/runner/runner-wrapper/runner-wrapper.sh"
1010+
[[ -n "$res_visionfive2" ]] && runner_entrypoint_visionfive2="/home/runner/runner-wrapper/runner-wrapper.sh"
10051011

10061012
# ════════════════════════════════════════════════════════════════
10071013
# 第三步:为两种板子 runner 类型准备额外的环境变量数组
@@ -1016,11 +1022,13 @@ shell_generate_compose_file() {
10161022
local extra_env_phytiumpi=()
10171023
local extra_env_roc=()
10181024
local extra_env_x86_64=()
1025+
local extra_env_visionfive2=()
10191026
local extra_proxy_env=()
10201027
# 只有设置了相应的资源 ID,才为该类型 runner 添加锁相关环境变量
10211028
[[ -n "$res_phytiumpi" ]] && extra_env_phytiumpi=(" RUNNER_RESOURCE_ID: \"$res_phytiumpi\"" " RUNNER_SCRIPT: \"/home/runner/run.sh\"" " RUNNER_LOCK_DIR: \"${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}\"")
10221029
[[ -n "$res_roc" ]] && extra_env_roc=(" RUNNER_RESOURCE_ID: \"$res_roc\"" " RUNNER_SCRIPT: \"/home/runner/run.sh\"" " RUNNER_LOCK_DIR: \"${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}\"")
10231030
[[ -n "$res_x86_64" ]] && extra_env_x86_64=(" RUNNER_RESOURCE_ID: \"$res_x86_64\"" " RUNNER_SCRIPT: \"/home/runner/run.sh\"" " RUNNER_LOCK_DIR: \"${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}\"")
1031+
[[ -n "$res_visionfive2" ]] && extra_env_visionfive2=(" RUNNER_RESOURCE_ID: \"$res_visionfive2\"" " RUNNER_SCRIPT: \"/home/runner/run.sh\"" " RUNNER_LOCK_DIR: \"${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}\"")
10241032
[[ -n "${HTTP_PROXY:-}" ]] && extra_proxy_env+=(" HTTP_PROXY: \"${HTTP_PROXY}\"")
10251033
[[ -n "${HTTPS_PROXY:-}" ]] && extra_proxy_env+=(" HTTPS_PROXY: \"${HTTPS_PROXY}\"")
10261034
[[ -n "${NO_PROXY:-}" ]] && extra_proxy_env+=(" NO_PROXY: \"${NO_PROXY}\"")
@@ -1034,10 +1042,12 @@ shell_generate_compose_file() {
10341042
local extra_vol_phytiumpi=""
10351043
local extra_vol_roc=""
10361044
local extra_vol_x86_64=""
1045+
local extra_vol_visionfive2=""
10371046
# 只有设置了相应的资源 ID,才为该类型 runner 挂载锁文件目录
10381047
[[ -n "$res_phytiumpi" ]] && extra_vol_phytiumpi=" - ${RUNNER_LOCK_HOST_PATH:-/tmp/github-runner-locks}:${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}"
10391048
[[ -n "$res_roc" ]] && extra_vol_roc=" - ${RUNNER_LOCK_HOST_PATH:-/tmp/github-runner-locks}:${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}"
10401049
[[ -n "$res_x86_64" ]] && extra_vol_x86_64=" - ${RUNNER_LOCK_HOST_PATH:-/tmp/github-runner-locks}:${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}"
1050+
[[ -n "$res_visionfive2" ]] && extra_vol_visionfive2=" - ${RUNNER_LOCK_HOST_PATH:-/tmp/github-runner-locks}:${RUNNER_LOCK_DIR:-/tmp/github-runner-locks}"
10411051

10421052
# 使用 printf 输出文件头
10431053
printf '%s\n' \
@@ -1239,6 +1249,60 @@ shell_generate_compose_file() {
12391249
" - ${RUNNER_NAME_PREFIX}runner-x86_64-pc-data:/home/runner" \
12401250
" - ${RUNNER_NAME_PREFIX}runner-x86_64-pc-udev-rules:/etc/udev/rules.d" \
12411251
"" >> "${COMPOSE_FILE}"
1252+
1253+
# visionfive2 板子配置
1254+
printf '%s\n' \
1255+
" ${RUNNER_NAME_PREFIX}runner-visionfive2:" \
1256+
" <<: *runner_base" \
1257+
" container_name: \"${RUNNER_NAME_PREFIX}runner-visionfive2\"" \
1258+
" command:" \
1259+
" - /bin/bash" \
1260+
" - -c" \
1261+
" - |" \
1262+
" set -e" \
1263+
" mkdir -p /home/runner/board" \
1264+
" cd /home/runner/board" \
1265+
" echo \"Attempting to download visionfive2 files...\"" \
1266+
" if curl -fsSL --connect-timeout 30 --max-time 300 https://github.com/user-attachments/files/26230373/visionfive2.tar.gz -o visionfive2.tar.gz; then" \
1267+
" echo \"Download successful, extracting...\"" \
1268+
" tar -xzf visionfive2.tar.gz" \
1269+
" echo \"Extraction completed\"" \
1270+
" else" \
1271+
" echo \"Download failed, continuing with existing files if any...\"" \
1272+
" fi" \
1273+
" ${runner_entrypoint_visionfive2}" \
1274+
" devices:" \
1275+
" - /dev/loop-control:/dev/loop-control" \
1276+
" - /dev/loop0:/dev/loop0" \
1277+
" - /dev/loop1:/dev/loop1" \
1278+
" - /dev/loop2:/dev/loop2" \
1279+
" - /dev/loop3:/dev/loop3" \
1280+
" - /dev/kvm:/dev/kvm" \
1281+
" - /dev/ttyUSB6:/dev/ttyUSB6" \
1282+
" - /dev/ttyUSB7:/dev/ttyUSB7" \
1283+
" group_add:" \
1284+
" - 993" \
1285+
" - dialout" \
1286+
" environment:" \
1287+
" <<: *runner_env" \
1288+
" RUNNER_NAME: \"${RUNNER_NAME_PREFIX}runner-visionfive2\"" \
1289+
" RUNNER_LABELS: \"visionfive2\"" \
1290+
" BOARD_POWER_ON: \"mbpoll -m rtu -a 1 -r 1 -t 0 -b 38400 -P none -v /dev/ttyUSB7 1\"" \
1291+
" BOARD_POWER_OFF: \"mbpoll -m rtu -a 1 -r 1 -t 0 -b 38400 -P none -v /dev/ttyUSB7 0\"" \
1292+
" BOARD_POWER_RESET: \"mbpoll -m rtu -a 1 -r 1 -t 0 -b 38400 -P none -v /dev/ttyUSB7 0 && sleep 2 && mbpoll -m rtu -a 1 -r 1 -t 0 -b 38400 -P none -v /dev/ttyUSB7 1\"" \
1293+
" BOARD_DTB: \"/home/runner/board/jh7110-visionfive-v2.dtb\"" \
1294+
" BOARD_COMM_UART_DEV: \"/dev/ttyUSB6\"" \
1295+
" BOARD_COMM_UART_BAUD: \"115200\"" \
1296+
" TFTP_DIR: \"visionfive2\"" \
1297+
" BIN_DIR: \"/home/runner/test/visionfive2\"" \
1298+
"${extra_env_visionfive2[@]}" \
1299+
" volumes:" \
1300+
" - /home/$(whoami)/test/visionfive2:/home/runner/tftp" \
1301+
"$extra_vol_visionfive2" \
1302+
" - ./runner-wrapper:/home/runner/runner-wrapper:ro" \
1303+
" - ${RUNNER_NAME_PREFIX}runner-visionfive2-data:/home/runner" \
1304+
" - ${RUNNER_NAME_PREFIX}runner-visionfive2-udev-rules:/etc/udev/rules.d" \
1305+
"" >> "${COMPOSE_FILE}"
12421306
fi
12431307

12441308
# 生成 volumes
@@ -1274,6 +1338,13 @@ shell_generate_compose_file() {
12741338
" name: ${RUNNER_NAME_PREFIX}runner-x86_64-pc-data" \
12751339
" ${RUNNER_NAME_PREFIX}runner-x86_64-pc-udev-rules:" \
12761340
" name: ${RUNNER_NAME_PREFIX}runner-x86_64-pc-udev-rules" >> "${COMPOSE_FILE}"
1341+
1342+
# 为 visionfive2 板子生成 volumes
1343+
printf '%s\n' \
1344+
" ${RUNNER_NAME_PREFIX}runner-visionfive2-data:" \
1345+
" name: ${RUNNER_NAME_PREFIX}runner-visionfive2-data" \
1346+
" ${RUNNER_NAME_PREFIX}runner-visionfive2-udev-rules:" \
1347+
" name: ${RUNNER_NAME_PREFIX}runner-visionfive2-udev-rules" >> "${COMPOSE_FILE}"
12771348
fi
12781349
}
12791350

0 commit comments

Comments
 (0)