Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ GH_PAT=
# 多组织共享同一块板时显式设相同 ID:
# RUNNER_RESOURCE_ID_PHYTIUMPI=board-phytiumpi
# RUNNER_RESOURCE_ID_ROC_RK3568_PC=board-roc-rk3568-pc
# RUNNER_RESOURCE_ID_X86_64=board-x86_64
# RUNNER_LOCK_DIR=/tmp/github-runner-locks
# RUNNER_LOCK_HOST_PATH=/tmp/github-runner-locks

Expand Down
29 changes: 28 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
cmake \
git \
ca-certificates \
binfmt-support \
Expand Down Expand Up @@ -55,8 +56,14 @@ RUN apt-get update \
python3-pip \
python3-tomli \
python3-sphinx \
clang \
libclang-dev \
llvm-dev \
ninja-build \
libslirp0 \
&& libclang_so="$(find /usr/lib -path '*/libclang.so' | head -n1)" \
&& test -n "$libclang_so" \
&& ln -sfn "$(dirname "$libclang_so")" /usr/lib/libclang-runtime \
&& rm -rf /var/lib/apt/lists/*

# Build and install QEMU 10.1.2 from source
Expand All @@ -80,6 +87,25 @@ RUN mkdir -p /tmp/qemu-build \
RUN usermod -aG dialout runner
RUN usermod -aG kvm runner

# Install prebuilt musl cross toolchains
RUN set -eux; \
mkdir -p /env; \
cd /env; \
wget https://musl.cc/aarch64-linux-musl-cross.tgz; \
wget https://musl.cc/riscv64-linux-musl-cross.tgz; \
wget https://musl.cc/x86_64-linux-musl-cross.tgz; \
wget https://github.com/arceos-org/setup-musl/releases/download/prebuilt/loongarch64-linux-musl-cross.tgz; \
tar zxf aarch64-linux-musl-cross.tgz -C /env; \
tar zxf riscv64-linux-musl-cross.tgz -C /env; \
tar zxf x86_64-linux-musl-cross.tgz -C /env; \
tar zxf loongarch64-linux-musl-cross.tgz -C /env; \
printf '%s\n' \
'' \
'# musl cross toolchains' \
'export PATH=/env/x86_64-linux-musl-cross/bin:/env/aarch64-linux-musl-cross/bin:/env/riscv64-linux-musl-cross/bin:/env/loongarch64-linux-musl-cross/bin:$PATH' \
>> /home/runner/.bashrc; \
chown runner:runner /home/runner/.bashrc

# 多组织共享硬件锁:runner-wrapper 用于多 org 共享同一硬件时的并发控制(Job 级别锁)
COPY runner-wrapper /home/runner/runner-wrapper
RUN chmod +x /home/runner/runner-wrapper/runner-wrapper.sh \
Expand All @@ -90,7 +116,8 @@ RUN chmod +x /home/runner/runner-wrapper/runner-wrapper.sh \
USER runner

# Rust development for runner user
ENV PATH=/home/runner/.cargo/bin:$PATH \
ENV PATH=/env/x86_64-linux-musl-cross/bin:/env/aarch64-linux-musl-cross/bin:/env/riscv64-linux-musl-cross/bin:/env/loongarch64-linux-musl-cross/bin:/home/runner/.cargo/bin:$PATH \
LIBCLANG_PATH=/usr/lib/libclang-runtime \
RUST_VERSION=nightly

RUN set -eux; \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cp .env.example .env
| `./runner.sh rm [runner-<id> ...] [-y]` | Unregister and remove containers; `-y` skips confirmation |
| `./runner.sh purge [-y]` | Remove containers and generated files (`docker-compose.yml`, caches, etc.) |

> **Note**: The `init` command creates two hardware-based runners (phytiumpi and roc-rk3568-pc) by default. This behavior is not controlled by the `-n` parameter.
> **Note**: The `init` command creates three hardware-based runners (phytiumpi, roc-rk3568-pc, and x86_64-pc) by default. This behavior is not controlled by the `-n` parameter.

## Configuration

Expand All @@ -68,7 +68,7 @@ The default prefix automatically includes `ORG` (and `REPO` if set), formatted a
name:label1[,label2];name2:label1
```

Example: `phytiumpi:arm64,phytiumpi;roc-rk3568-pc:arm64,roc-rk3568-pc`
Example: `phytiumpi:arm64,phytiumpi;roc-rk3568-pc:arm64,roc-rk3568-pc;x86_64-pc:x86_64`

Board instances will only use labels defined in `BOARD_RUNNERS` and will not append global `RUNNER_LABELS`.

Expand Down Expand Up @@ -98,7 +98,7 @@ When multiple containers need to access the same physical hardware, concurrent j

### Configuration

When using environments generated by **runner.sh**, board runners have the wrapper enabled by default with the shared lock directory `/tmp/github-runner-locks` mounted. Board-level environment variables (e.g., `RUNNER_RESOURCE_ID_PHYTIUMPI`) take priority; otherwise, default values are used (phytiumpi: `board-phytiumpi`, roc-rk3568-pc: `board-roc-rk3568-pc`).
When using environments generated by **runner.sh**, board runners have the wrapper enabled by default with the shared lock directory `/tmp/github-runner-locks` mounted. Board-level environment variables (e.g., `RUNNER_RESOURCE_ID_PHYTIUMPI`) take priority; otherwise, default values are used (phytiumpi: `board-phytiumpi`, roc-rk3568-pc: `board-roc-rk3568-pc`, x86_64-pc: `board-x86_64-pc`).

To **share the same board across multiple organizations**, simply set the same lock ID for that board in each `.env` file. This ensures that even if runner containers from both organizations receive jobs simultaneously, they will queue via file locks to avoid hardware conflicts.

Expand Down
6 changes: 3 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ cp .env.example .env
| `./runner.sh rm [runner-<id> ...] [-y]` | 取消注册并删除容器;`-y` 跳过确认 |
| `./runner.sh purge [-y]` | 删除容器并移除生成文件(`docker-compose.yml`、缓存等) |

> **注意**:`init` 命令默认会创建两个基于硬件的 Runner(phytiumpiroc-rk3568-pc),此行为不受 `-n` 参数控制。
> **注意**:`init` 命令默认会创建三个基于硬件的 Runner(phytiumpiroc-rk3568-pc 和 x86_64),此行为不受 `-n` 参数控制。

## 配置说明

Expand All @@ -68,7 +68,7 @@ cp .env.example .env
name:label1[,label2];name2:label1
```

示例:`phytiumpi:arm64,phytiumpi;roc-rk3568-pc:arm64,roc-rk3568-pc`
示例:`phytiumpi:arm64,phytiumpi;roc-rk3568-pc:arm64,roc-rk3568-pc;x86_64:x86_64`

开发板实例将仅使用 `BOARD_RUNNERS` 中定义的标签,不会追加全局 `RUNNER_LABELS`。

Expand Down Expand Up @@ -98,7 +98,7 @@ name:label1[,label2];name2:label1

### 配置方法

使用 **runner.sh** 生成的环境,板子 runner 默认启用 wrapper 并挂载共享锁目录 `/tmp/github-runner-locks`。优先使用板子级环境变量(如 `RUNNER_RESOURCE_ID_PHYTIUMPI`),否则使用默认值(phytiumpi: `board-phytiumpi`,roc-rk3568-pc: `board-roc-rk3568-pc`)。
使用 **runner.sh** 生成的环境,板子 runner 默认启用 wrapper 并挂载共享锁目录 `/tmp/github-runner-locks`。优先使用板子级环境变量(如 `RUNNER_RESOURCE_ID_PHYTIUMPI`),否则使用默认值(phytiumpi: `board-phytiumpi`,roc-rk3568-pc: `board-roc-rk3568-pc`,x86_64-pc: `board-x86_64-pc`)。

如果要在**多组织中共享同一块板时**,则只需要在各自的 `.env` 中为该板设置相同的锁 ID。这样,即使两个组织的 runner 容器同时收到 job,也会通过文件锁排队执行,避免硬件冲突。

Expand Down
Loading