Skip to content
Merged
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
31 changes: 22 additions & 9 deletions .conform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@
structure:
directories:
required:
- cmd/worker
- internal/platform
- internal/parser
- internal/agent
- internal/pipeline
- internal/config
- pkg/version
- backend
- backend/cmd/worker
- backend/internal/agent
- backend/internal/config
- backend/internal/editor
- backend/internal/parser
- backend/internal/pipeline
- backend/internal/platform
- backend/internal/runtime
- backend/internal/schema
- backend/pkg/version
- frontend
- deploy
- docs
- .skills

files:
required:
- README.md
- Makefile
- go.mod
- cmd/worker/main.go
- .golangci.yml
- .conform.yaml
- backend/go.mod
- backend/go.sum
- backend/cmd/worker/main.go
- frontend/README.md
- deploy/README.md
151 changes: 137 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# code-bee · 持续集成工作流
#
# 核心功能:
# 1. 在代码推送或 PR 提交时自动运行编译、测试与静态分析
# 2. 复用 Makefile 中已有的 build / test / lint 目标,保持本地与 CI 行为一致
# 1. 对提交信息、目录结构、后端静态分析、单元测试、race 检测和构建进行分阶段门禁
# 2. 复用 Makefile 中的统一命令入口,保证本地、CI、发布前校验使用完全一致的执行口径
#
# 触发时机:
# - push 到 main / master 分支
# - 针对 main / master 的 Pull Request
#
# 维护: AI Assistant
# 创建时间: 2026-07-04
# 更新时间: 2026-07-06
name: CI

on:
Expand All @@ -28,10 +29,55 @@ concurrency:
cancel-in-progress: true

jobs:
check:
name: Build & Test & Lint
commits:
name: Check Commits
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 5

steps:
- name: Checkout 代码
uses: actions/checkout@v5
with:
fetch-depth: 2

- name: 校验 PR 标题
if: github.event_name == 'pull_request'
run: ./scripts/check_commit_message.sh --message "${{ github.event.pull_request.title }}"

- name: 校验最新提交信息
if: github.event_name == 'push'
run: ./scripts/check_commit_message.sh --head

structure:
name: Check Structure
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout 代码
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false

- name: 安装 conform
run: |
go install github.com/siderolabs/conform/cmd/conform@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"

- name: 校验项目目录结构
run: make check-structure

backend-lint:
name: Backend Lint
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- commits
- structure

steps:
- name: Checkout 代码
Expand All @@ -42,27 +88,104 @@ jobs:
with:
go-version: '1.23'
cache: true
cache-dependency-path: backend/go.sum

- name: 下载依赖
run: go mod download
run: cd backend && go mod download

- name: 安装 golangci-lint
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"

- name: 校验 go.mod 同步
run: |
cd backend
go mod tidy
if [ -n "$(git status --porcelain go.mod go.sum)" ]; then
echo "::error::go.mod 或 go.sum 不同步,请在本地运行 go mod tidy 后提交"
git --no-pager diff -- go.mod go.sum
exit 1
fi

- name: 编译
run: make build
- name: 静态分析
run: make lint-backend

- name: 单元测试
run: make test
backend-unit:
name: Backend Unit Test
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- commits
- structure

- name: 静态分析
uses: golangci/golangci-lint-action@v6
steps:
- name: Checkout 代码
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: backend/go.sum

- name: 运行后端单元测试
run: make test-backend-unit

backend-race:
name: Backend Race Test
runs-on: ubuntu-latest
timeout-minutes: 20
needs:
- commits
- structure

steps:
- name: Checkout 代码
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: backend/go.sum

- name: 安装 conform
run: |
go install github.com/siderolabs/conform/cmd/conform@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"

- name: 运行后端 race 测试
run: make test-backend-race

backend-build:
name: Backend Build
runs-on: ubuntu-latest
timeout-minutes: 10
needs:
- backend-lint
- backend-unit
- backend-race

steps:
- name: Checkout 代码
uses: actions/checkout@v5

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: backend/go.sum

- name: 编译后端
run: make build-backend

- name: 上传二进制产物
uses: actions/upload-artifact@v4
with:
version: latest
args: --config .golangci.yml
name: code-bee-backend-binary
path: bin/code-bee
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# code-bee · 发布流水线
#
# 核心功能:
# 1. 在 tag 发布或手动触发时执行发布前总校验与最小冒烟校验,防止未通过门禁的代码进入发布阶段
# 2. 构建后端二进制并在 tag 场景下创建 GitHub Release,确保发布动作与主干质量门禁绑定
#
# 维护: AI Assistant
# 创建时间: 2026-07-06
name: Release

permissions:
contents: write

on:
push:
tags:
- 'v*'
workflow_dispatch:

jobs:
release:
name: Release Check
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout 代码
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: true
cache-dependency-path: backend/go.sum

- name: 安装发布校验工具
run: |
go install github.com/siderolabs/conform/cmd/conform@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"

- name: 校验 tag 格式
if: startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME="${GITHUB_REF#refs/tags/}"
if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Tag 格式不符合 Semantic Versioning: $TAG_NAME"
exit 1
fi

- name: 发布前总校验
run: make release-check

- name: 发布前最小冒烟校验
run: make release-smoke

- name: 上传发布二进制
uses: actions/upload-artifact@v4
with:
name: code-bee-release-binary
path: bin/code-bee

- name: 创建 GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: bin/code-bee
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ bin/

# Build output
/worker

frontend/node_modules/
frontend/dist/
.trae/
Loading
Loading