GitHub Actions 多服务 CI
Monorepo 多服务 CI 设计:并行 job、各服务独立 lint/build/test、并发取消、commitlint。
#type / howto
#status / growing
#tech / ops
#resource / github-actions
[!info] related notes
- 相关: Conventional Commits
- 发布: release-please
GitHub Actions 多服务 CI
设计要点
三个服务并行
jobs:
web: # pnpm lint + typecheck + build
api: # go vet + build + test
ai-service: # ruff check + pytest
互不依赖,GitHub Actions 自动并行。总耗时 = 最慢的那个。
并发取消
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
同一分支多次 push,取消之前的运行。
各服务的工具链
| 服务 | 包管理 | Lint | Test |
|---|---|---|---|
| web | pnpm | ESLint | Vitest |
| api | go mod | go vet | go test |
| ai-service | uv | ruff | pytest |
Commitlint
只在 PR 时运行,校验 commit message 是否符合 Conventional Commits。
缓存
各工具链的缓存:
- pnpm:
actions/cache或cache: pnpm - Go:
actions/setup-go内置 - uv:
astral-sh/setup-uv内置