ln-732-cicd-generator

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ln-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

输入参数

InputSourceDescription
Stack Typeln-730 coordinatorbackend-dotnet, backend-python
VersionsAuto-detectedNode.js, .NET or Python versions
Frontend PathAuto-detectedPath to frontend directory
Build CommandsAuto-detectednpm scripts, dotnet/pytest commands

输入项来源描述
技术栈类型ln-730 协调器backend-dotnet, backend-python
版本信息自动检测Node.js、.NET 或 Python 版本
前端路径自动检测前端目录的路径
构建命令自动检测npm 脚本、dotnet/pytest 命令

Outputs

输出结果

FilePurposeTemplate
.github/workflows/ci.yml
Main CI pipelinegithub_ci_dotnet.template.yml or github_ci_python.template.yml

文件用途模板
.github/workflows/ci.yml
主CI流水线github_ci_dotnet.template.ymlgithub_ci_python.template.yml

Workflow

工作流程

Phase 1: Stack Analysis

阶段1:技术栈分析

Determine which template to use:
DetectionBackend Template
.sln
or
.csproj
present
github_ci_dotnet.template.yml
requirements.txt
or
pyproject.toml
present
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
确定要使用的模板:
检测条件后端模板
存在
.sln
.csproj
文件
github_ci_dotnet.template.yml
存在
requirements.txt
pyproject.toml
文件
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:
VariableSourceDefault
{{NODE_VERSION}}
package.json engines22
{{DOTNET_VERSION}}
*.csproj TargetFramework9.0.x
{{PYTHON_VERSION}}
pyproject.toml3.12
{{FRONTEND_PATH}}
Directory detectionsrc/frontend
替换模板中的变量:
变量来源默认值
{{NODE_VERSION}}
package.json engines字段22
{{DOTNET_VERSION}}
*.csproj文件的TargetFramework9.0.x
{{PYTHON_VERSION}}
pyproject.toml文件3.12
{{FRONTEND_PATH}}
目录检测src/frontend

Phase 3: Directory Creation

阶段3:目录创建

Create
.github/workflows/
directory if not exists.
如果
.github/workflows/
目录不存在则创建它。

Phase 4: File Generation

阶段4:文件生成

Generate ci.yml from selected template:
  1. Check if workflow already exists (warn before overwrite)
  2. Apply variable substitution
  3. Write to
    .github/workflows/ci.yml
  4. Validate YAML syntax

从选中的模板生成ci.yml文件:
  1. 检查工作流文件是否已存在(覆盖前发出警告)
  2. 执行变量替换
  3. 写入到
    .github/workflows/ci.yml
  4. 验证YAML语法

Generated Pipeline Structure

生成的流水线结构

Jobs Overview

任务概述

JobPurposeDependencies
frontendLint, build, test React/ViteNone
backendBuild, test .NET or PythonNone
dockerBuild images, health checksfrontend, backend
任务用途依赖
frontend对React/Vite项目执行Lint、构建、测试
backend构建、测试.NET或Python项目
docker构建镜像、健康检查frontend、backend

Frontend Job Steps

前端任务步骤

  1. Checkout code
  2. Setup Node.js with caching
  3. Install dependencies (
    npm ci
    )
  4. Run linter (
    npm run lint
    )
  5. Build application (
    npm run build
    )
  6. Run tests (
    npm test
    )
  1. 拉取代码
  2. 配置Node.js并启用缓存
  3. 安装依赖(
    npm ci
  4. 运行Linter(
    npm run lint
  5. 构建应用(
    npm run build
  6. 运行测试(
    npm test

Backend Job Steps (.NET)

后端任务步骤(.NET)

  1. Checkout code
  2. Setup .NET SDK
  3. Restore dependencies (
    dotnet restore
    )
  4. Build (
    dotnet build
    )
  5. Run tests (
    dotnet test
    )
  1. 拉取代码
  2. 配置.NET SDK
  3. 还原依赖(
    dotnet restore
  4. 构建(
    dotnet build
  5. 运行测试(
    dotnet test

Backend Job Steps (Python)

后端任务步骤(Python)

  1. Checkout code
  2. Setup Python with pip caching
  3. Install dependencies (
    pip install -r requirements.txt
    )
  4. Run linter (
    ruff check
    )
  5. Run tests (
    pytest
    )
  1. 拉取代码
  2. 配置Python并启用pip缓存
  3. 安装依赖(
    pip install -r requirements.txt
  4. 运行Linter(
    ruff check
  5. 运行测试(
    pytest

Docker Job Steps

Docker任务步骤

  1. Checkout code
  2. Build images (
    docker compose build
    )
  3. Start containers (
    docker compose up -d
    )
  4. Wait for startup (30 seconds)
  5. Health check frontend (port 3000)
  6. Health check backend (port 5000/8000)
  7. Show logs on failure
  8. Stop containers (
    docker compose down
    )

  1. 拉取代码
  2. 构建镜像(
    docker compose build
  3. 启动容器(
    docker compose up -d
  4. 等待启动完成(30秒)
  5. 前端健康检查(端口3000)
  6. 后端健康检查(端口5000/8000)
  7. 失败时显示日志
  8. 停止容器(
    docker compose down

Triggers

触发条件

EventBranches
Pushmain, develop
Pull Requestmain

事件分支
推送(Push)main、develop
拉取请求(Pull Request)main

Best Practices Applied

应用的最佳实践

PracticeImplementation
Dependency cachingnpm cache, pip cache
Pinned versionsactions/checkout@v4, setup-node@v4
Parallel jobsfrontend and backend run in parallel
Fail fastdocker job waits for both to succeed
Clean updocker compose down runs always
Debug supportlogs 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

重要说明

  1. GitHub Actions Only: This skill generates only GitHub Actions workflows. No Azure/GitLab support.
  2. Template-based: Use templates from references/. Do NOT hardcode workflow contents.
  3. Idempotent: Check if .github/workflows/ exists. Warn before overwriting ci.yml.
  4. Version Detection: Use detected versions, not hardcoded defaults.

  1. 仅支持GitHub Actions:该技能仅生成GitHub Actions工作流,不支持Azure/GitLab
  2. 基于模板:使用references/目录下的模板,请勿硬编码工作流内容
  3. 幂等性:检查.github/workflows/目录是否存在,覆盖ci.yml前发出警告
  4. 版本检测:使用自动检测到的版本,而非硬编码的默认值

Reference Files

参考文件

FilePurpose
github_ci.template.ymlFull template with comments
github_ci_dotnet.template.ymlCompact .NET stack template
github_ci_python.template.ymlCompact 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