ln-732-cicd-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseln-732-cicd-generator
ln-732-cicd-generator
Type: L3 Worker
Category: 7XX Project Bootstrap
Parent: ln-730-devops-setup
Generates GitHub Actions CI pipeline for automated testing and validation.
类型: L3 Worker
分类: 7XX 项目初始化
父模块: ln-730-devops-setup
为自动化测试与验证生成GitHub Actions CI流水线。
Purpose & Scope
用途与范围
Creates CI/CD workflow for GitHub:
- Does: Generate .github/workflows/ci.yml with lint, test, build, docker jobs
- Does NOT: Configure deployment, manage secrets, set up CD pipelines
为GitHub创建CI/CD工作流:
- 支持: 生成包含lint、测试、构建、Docker任务的.github/workflows/ci.yml文件
- 不支持: 配置部署、管理密钥、设置CD流水线
Inputs
输入参数
| Input | Source | Description |
|---|---|---|
| Stack Type | ln-730 coordinator | backend-dotnet, backend-python |
| Versions | Auto-detected | Node.js, .NET or Python versions |
| Frontend Path | Auto-detected | Path to frontend directory |
| Build Commands | Auto-detected | npm scripts, dotnet/pytest commands |
| 输入项 | 来源 | 描述 |
|---|---|---|
| 技术栈类型 | ln-730 协调器 | backend-dotnet, backend-python |
| 版本信息 | 自动检测 | Node.js、.NET 或 Python 版本 |
| 前端路径 | 自动检测 | 前端目录的路径 |
| 构建命令 | 自动检测 | npm 脚本、dotnet/pytest 命令 |
Outputs
输出结果
| File | Purpose | Template |
|---|---|---|
| Main CI pipeline | github_ci_dotnet.template.yml or github_ci_python.template.yml |
| 文件 | 用途 | 模板 |
|---|---|---|
| 主CI流水线 | github_ci_dotnet.template.yml 或 github_ci_python.template.yml |
Workflow
工作流程
Phase 1: Stack Analysis
阶段1:技术栈分析
Determine which template to use:
| Detection | Backend Template |
|---|---|
| github_ci_dotnet.template.yml |
| github_ci_python.template.yml |
Detect commands:
- Frontend: Read scripts from package.json (lint, build, test)
- .NET: Standard dotnet restore/build/test
- Python: pip install, ruff lint, pytest
确定要使用的模板:
| 检测条件 | 后端模板 |
|---|---|
存在 | github_ci_dotnet.template.yml |
存在 | github_ci_python.template.yml |
检测命令:
- 前端:从package.json读取脚本(lint、构建、测试)
- .NET:标准dotnet restore/build/test命令
- Python:pip install、ruff lint、pytest命令
Phase 2: Variable Substitution
阶段2:变量替换
Replace template variables:
| Variable | Source | Default |
|---|---|---|
| package.json engines | 22 |
| *.csproj TargetFramework | 9.0.x |
| pyproject.toml | 3.12 |
| Directory detection | src/frontend |
替换模板中的变量:
| 变量 | 来源 | 默认值 |
|---|---|---|
| package.json engines字段 | 22 |
| *.csproj文件的TargetFramework | 9.0.x |
| pyproject.toml文件 | 3.12 |
| 目录检测 | src/frontend |
Phase 3: Directory Creation
阶段3:目录创建
Create directory if not exists.
.github/workflows/如果目录不存在则创建它。
.github/workflows/Phase 4: File Generation
阶段4:文件生成
Generate ci.yml from selected template:
- Check if workflow already exists (warn before overwrite)
- Apply variable substitution
- Write to
.github/workflows/ci.yml - Validate YAML syntax
从选中的模板生成ci.yml文件:
- 检查工作流文件是否已存在(覆盖前发出警告)
- 执行变量替换
- 写入到
.github/workflows/ci.yml - 验证YAML语法
Generated Pipeline Structure
生成的流水线结构
Jobs Overview
任务概述
| Job | Purpose | Dependencies |
|---|---|---|
| frontend | Lint, build, test React/Vite | None |
| backend | Build, test .NET or Python | None |
| docker | Build images, health checks | frontend, backend |
| 任务 | 用途 | 依赖 |
|---|---|---|
| frontend | 对React/Vite项目执行Lint、构建、测试 | 无 |
| backend | 构建、测试.NET或Python项目 | 无 |
| docker | 构建镜像、健康检查 | frontend、backend |
Frontend Job Steps
前端任务步骤
- Checkout code
- Setup Node.js with caching
- Install dependencies ()
npm ci - Run linter ()
npm run lint - Build application ()
npm run build - Run tests ()
npm test
- 拉取代码
- 配置Node.js并启用缓存
- 安装依赖()
npm ci - 运行Linter()
npm run lint - 构建应用()
npm run build - 运行测试()
npm test
Backend Job Steps (.NET)
后端任务步骤(.NET)
- Checkout code
- Setup .NET SDK
- Restore dependencies ()
dotnet restore - Build ()
dotnet build - Run tests ()
dotnet test
- 拉取代码
- 配置.NET SDK
- 还原依赖()
dotnet restore - 构建()
dotnet build - 运行测试()
dotnet test
Backend Job Steps (Python)
后端任务步骤(Python)
- Checkout code
- Setup Python with pip caching
- Install dependencies ()
pip install -r requirements.txt - Run linter ()
ruff check - Run tests ()
pytest
- 拉取代码
- 配置Python并启用pip缓存
- 安装依赖()
pip install -r requirements.txt - 运行Linter()
ruff check - 运行测试()
pytest
Docker Job Steps
Docker任务步骤
- Checkout code
- Build images ()
docker compose build - Start containers ()
docker compose up -d - Wait for startup (30 seconds)
- Health check frontend (port 3000)
- Health check backend (port 5000/8000)
- Show logs on failure
- Stop containers ()
docker compose down
- 拉取代码
- 构建镜像()
docker compose build - 启动容器()
docker compose up -d - 等待启动完成(30秒)
- 前端健康检查(端口3000)
- 后端健康检查(端口5000/8000)
- 失败时显示日志
- 停止容器()
docker compose down
Triggers
触发条件
| Event | Branches |
|---|---|
| Push | main, develop |
| Pull Request | main |
| 事件 | 分支 |
|---|---|
| 推送(Push) | main、develop |
| 拉取请求(Pull Request) | main |
Best Practices Applied
应用的最佳实践
| Practice | Implementation |
|---|---|
| Dependency caching | npm cache, pip cache |
| Pinned versions | actions/checkout@v4, setup-node@v4 |
| Parallel jobs | frontend and backend run in parallel |
| Fail fast | docker job waits for both to succeed |
| Clean up | docker compose down runs always |
| Debug support | logs shown on failure |
| 实践 | 实现方式 |
|---|---|
| 依赖缓存 | npm缓存、pip缓存 |
| 固定版本 | 使用actions/checkout@v4、setup-node@v4等固定版本的Action |
| 并行任务 | 前端与后端任务并行执行 |
| 快速失败 | Docker任务需等待前两者执行成功后才运行 |
| 资源清理 | 始终执行docker compose down进行清理 |
| 调试支持 | 失败时显示日志 |
Quality Criteria
质量标准
Generated workflow must:
- Pass YAML syntax validation
- Use pinned action versions (not )
@latest - Include dependency caching
- Have health checks for docker job
- Clean up resources on completion
生成的工作流必须满足:
- 通过YAML语法验证
- 使用固定版本的Action(而非)
@latest - 包含依赖缓存
- Docker任务包含健康检查
- 完成后清理资源
Critical Notes
重要说明
- GitHub Actions Only: This skill generates only GitHub Actions workflows. No Azure/GitLab support.
- Template-based: Use templates from references/. Do NOT hardcode workflow contents.
- Idempotent: Check if .github/workflows/ exists. Warn before overwriting ci.yml.
- Version Detection: Use detected versions, not hardcoded defaults.
- 仅支持GitHub Actions:该技能仅生成GitHub Actions工作流,不支持Azure/GitLab
- 基于模板:使用references/目录下的模板,请勿硬编码工作流内容
- 幂等性:检查.github/workflows/目录是否存在,覆盖ci.yml前发出警告
- 版本检测:使用自动检测到的版本,而非硬编码的默认值
Reference Files
参考文件
| File | Purpose |
|---|---|
| github_ci.template.yml | Full template with comments |
| github_ci_dotnet.template.yml | Compact .NET stack template |
| github_ci_python.template.yml | Compact Python stack template |
Version: 1.1.0
Last Updated: 2026-01-10
| 文件 | 用途 |
|---|---|
| github_ci.template.yml | 带注释的完整模板 |
| github_ci_dotnet.template.yml | 精简的.NET栈模板 |
| github_ci_python.template.yml | 精简的Python栈模板 |
版本: 1.1.0
最后更新: 2026-01-10