devops-pipeline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDevOps Pipeline
DevOps 流水线
Implement comprehensive DevOps quality gates adapted to project type.
实现适配项目类型的全面DevOps质量门禁。
Workflow
工作流程
1. Analyze Project
1. 分析项目
Detect project characteristics:
bash
undefined检测项目特征:
bash
undefinedCheck 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 configuredls -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-commitCreate based on detected stack. See references/precommit-configs.md for language-specific configurations.
.pre-commit-config.yamlInstall 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根据检测到的技术栈创建。可参考references/precommit-configs.md获取各语言专属配置。
.pre-commit-config.yaml安装钩子:
bash
pre-commit install
pre-commit run --all-files # 在现有代码上测试3. Create GitHub Actions Workflows
3. 创建GitHub Actions工作流
Create mirroring pre-commit checks. See references/github-actions.md for workflow templates.
.github/workflows/ci.ymlKey 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检查一致的文件。可参考references/github-actions.md获取工作流模板。
.github/workflows/ci.yml核心原则:
- 与pre-commit检查保持一致,确保连贯性
- 对依赖项使用缓存
- 在代码推送和拉取请求时触发运行
- 如有需要,添加多版本矩阵测试
4. Verify Pipeline
4. 验证流水线
bash
undefinedbash
undefinedTest 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
按语言选择工具
| Language | Formatter | Linter | Security | Types |
|---|---|---|---|---|
| JS/TS | Prettier | ESLint | npm audit | TypeScript |
| Python | Black/Ruff | Ruff | Bandit | mypy |
| Go | gofmt | golangci-lint | gosec | built-in |
| Rust | rustfmt | Clippy | cargo-audit | built-in |
| Java | google-java-format | Checkstyle | SpotBugs | - |
| 编程语言 | 格式化工具 | 代码检查器 | 安全工具 | 类型检查 |
|---|---|---|---|---|
| JS/TS | Prettier | ESLint | npm audit | TypeScript |
| Python | Black/Ruff | Ruff | Bandit | mypy |
| Go | gofmt | golangci-lint | gosec | 内置 |
| Rust | rustfmt | Clippy | cargo-audit | 内置 |
| Java | google-java-format | Checkstyle | SpotBugs | - |
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工作流模板