ci: 共享 pnpm store 加速本地 runner

This commit is contained in:
que01 committed 2026-10-23 16:09:25 +08:00
1 parent b43b6f2785
commit b82aa12875
4 files changed
+24 -11

No files matched your search

+9 -4
View File
@@ -19,6 +19,7 @@ RUNNER_LABELS=ubuntu-latest,local-x64 \
RUNNER_CAPACITY=2 \
RUNNER_CONTAINER_OPTIONS='--cpus=4 --memory=8g' \
RUNNER_IMAGE=personal-brand-ci:node24 \
RUNNER_PNPM_STORE=$HOME/gitea-runner/pnpm-store \
SKIP_LINGER=1 \
./install-runner.sh
```
@@ -30,9 +31,10 @@ SKIP_LINGER=1 \
1. 按架构下载 `gitea-runner-<version>-linux-<arch>`,校验 `.sha256` 后解压到 `~/gitea-runner`。
2. 用 `--no-interactive` 注册,写出 `.runner`(已存在则跳过,可重复执行)。
3. 生成 `config.yaml`:按 `RUNNER_CAPACITY` 设置并发,使用 `RUNNER_IMAGE`(默认 `node:24-bookworm`)作为任务容器镜像,内置 cache server 监听 `172.17.0.1:8193`,并按 `RUNNER_CONTAINER_OPTIONS` 限制任务容器资源。
4. 为下载的 runner 二进制补上可执行权限,避免归档解压后出现 `Permission denied`。
5. 装 systemd user unit `gitea-runner.service`,执行 `loginctl enable-linger` 后 `enable --now`。
6. 放行任务容器到 cache 端口的 ufw 规则。
4. 把 `RUNNER_PNPM_STORE`(默认 `~/gitea-runner/pnpm-store`)bind mount 到任务容器的 `/workspace/.pnpm-store`;workflow 通过 `npm_config_store_dir` 指向同一路径,所有 job 复用这份 pnpm store,避免重复下载依赖。
5. 为下载的 runner 二进制补上可执行权限,避免归档解压后出现 `Permission denied`。
6. 装 systemd user unit `gitea-runner.service`,执行 `loginctl enable-linger` 后 `enable --now`。
7. 放行任务容器到 cache 端口的 ufw 规则。
## 专用 CI 镜像
@@ -62,9 +64,11 @@ systemctl --user restart gitea-runner.service
```bash
systemctl --user status gitea-runner.service
journalctl --user -u gitea-runner -n 100 --no-pager
du -sh ~/gitea-runner/cache-data
du -sh ~/gitea-runner/cache-data ~/gitea-runner/pnpm-store
```
`pnpm-store` 会持续增长。确认没有 job 运行时,可以执行 `pnpm store prune` 清理未被引用的包(在任意任务容器里对 `/workspace/.pnpm-store` 执行,或直接删除旧目录后让下一次 job 重新填充)。
仓库侧 `pnpm deploy:status` 也会打印 `ci-runner=` 一行。
## 排障
@@ -80,6 +84,7 @@ du -sh ~/gitea-runner/cache-data
## 约束
- 本地 runner 使用 `capacity: 2`,每个任务容器限制 `4 CPU / 8 GB`;按宿主资源调整,不要超过实际可用内存。
- `~/gitea-runner/pnpm-store` 是所有 job 共享的 pnpm store。不要删除正在被 job 使用的 store;换 runner 主机时整目录拷贝或重新预热即可。
- 本地 runner 关机或休眠时,required checks 会保持 queued。需要开机自启时执行 `sudo loginctl enable-linger "$USER"`,否则用户会话退出后服务会停止。
- 日志级别保持 `debug`:`info` 级别不记录各 step 的结果行,排障时等于没有日志。
- 完整浏览器回归不进入定时或 main 推送 CI;PR 只运行轻量 browser smoke(见 `docs/ci.md`),完整套件仍在发布前执行。