devops-pipeline

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DevOps Pipeline

DevOps 流水线

Implement comprehensive DevOps quality gates adapted to project type.
实现适配项目类型的全面DevOps质量门禁。

Workflow

工作流程

1. Analyze Project

1. 分析项目

Detect project characteristics:
bash
undefined
检测项目特征:
bash
undefined

Check for package files and configs

检查包文件和配置文件

ls -la package.json pyproject.toml Cargo.toml go.mod pom.xml build.gradle .csproj 2>/dev/null ls -la .eslintrc .prettierrc* tsconfig.json mypy.ini setup.cfg ruff.toml 2>/dev/null ls -la .pre-commit-config.yaml .github/workflows/*.yml 2>/dev/null

Identify:
- **Languages**: JS/TS, Python, Go, Rust, Java, C#, etc.
- **Frameworks**: React, Next.js, Django, FastAPI, etc.
- **Build system**: npm, yarn, pnpm, pip, poetry, cargo, go, maven, gradle
- **Existing tooling**: Linters, formatters, type checkers already configured
ls -la package.json pyproject.toml Cargo.toml go.mod pom.xml build.gradle .csproj 2>/dev/null ls -la .eslintrc .prettierrc* tsconfig.json mypy.ini setup.cfg ruff.toml 2>/dev/null ls -la .pre-commit-config.yaml .github/workflows/*.yml 2>/dev/null

识别以下信息:
- **编程语言**:JS/TS、Python、Go、Rust、Java、C#等
- **框架**:React、Next.js、Django、FastAPI等
- **构建系统**:npm、yarn、pnpm、pip、poetry、cargo、go、maven、gradle
- **现有工具**:已配置的代码检查器、格式化工具、类型检查器

2. Configure Pre-commit Hooks

2. 配置Pre-commit钩子

Install pre-commit framework:
bash
pip install pre-commit  # or brew install pre-commit
Create
.pre-commit-config.yaml
based on detected stack. See references/precommit-configs.md for language-specific configurations.
Install hooks:
bash
pre-commit install
pre-commit run --all-files  # Test on existing code
安装pre-commit框架:
bash
pip install pre-commit  # 或使用 brew install pre-commit
根据检测到的技术栈创建
.pre-commit-config.yaml
。可参考references/precommit-configs.md获取各语言专属配置。
安装钩子:
bash
pre-commit install
pre-commit run --all-files  # 在现有代码上测试

3. Create GitHub Actions Workflows

3. 创建GitHub Actions工作流

Create
.github/workflows/ci.yml
mirroring pre-commit checks. See references/github-actions.md for workflow templates.
Key principles:
  • Mirror pre-commit checks for consistency
  • Use caching for dependencies
  • Run on push and pull_request
  • Add matrix testing for multiple versions if needed
创建与pre-commit检查一致的
.github/workflows/ci.yml
文件。可参考references/github-actions.md获取工作流模板。
核心原则:
  • 与pre-commit检查保持一致,确保连贯性
  • 对依赖项使用缓存
  • 在代码推送和拉取请求时触发运行
  • 如有需要,添加多版本矩阵测试

4. Verify Pipeline

4. 验证流水线

bash
undefined
bash
undefined

Test pre-commit locally

本地测试pre-commit

pre-commit run --all-files
pre-commit run --all-files

Commit and push to trigger CI

提交并推送以触发CI

git add .pre-commit-config.yaml .github/ git commit -m "ci: add pre-commit hooks and GitHub Actions" git push

Check GitHub Actions tab for workflow status.
git add .pre-commit-config.yaml .github/ git commit -m "ci: add pre-commit hooks and GitHub Actions" git push

查看GitHub Actions标签页确认工作流状态。

Tool Selection by Language

按语言选择工具

LanguageFormatterLinterSecurityTypes
JS/TSPrettierESLintnpm auditTypeScript
PythonBlack/RuffRuffBanditmypy
Gogofmtgolangci-lintgosecbuilt-in
RustrustfmtClippycargo-auditbuilt-in
Javagoogle-java-formatCheckstyleSpotBugs-
编程语言格式化工具代码检查器安全工具类型检查
JS/TSPrettierESLintnpm auditTypeScript
PythonBlack/RuffRuffBanditmypy
Gogofmtgolangci-lintgosec内置
RustrustfmtClippycargo-audit内置
Javagoogle-java-formatCheckstyleSpotBugs-

Resources

资源

  • references/precommit-configs.md - Pre-commit configurations by language
  • references/github-actions.md - GitHub Actions workflow templates
  • references/precommit-configs.md - 各语言的Pre-commit配置
  • references/github-actions.md - GitHub Actions工作流模板