github-workflows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Workflows
GitHub工作流
Diagnose, fix, and optimize GitHub Actions workflows for Rust projects.
为Rust项目诊断、修复和优化GitHub Actions工作流。
Quick Reference
快速参考
- Caching Strategies - Manual cache, rust-cache, sccache
- Troubleshooting - Common issues, debugging, fixes
- Advanced Features - Coverage, security, benchmarking
- Release Management - Automated releases, versioning
- 缓存策略 - 手动缓存、rust-cache、sccache
- 故障排查 - 常见问题、调试、修复方案
- 高级功能 - 覆盖率、安全、基准测试
- 版本发布管理 - 自动化发布、版本控制
When to Use
适用场景
- Setting up CI/CD for Rust projects
- Troubleshooting workflow failures
- Optimizing build times with caching
- Ensuring best practices for testing, linting, releases
- 为Rust项目搭建CI/CD
- 排查工作流执行失败问题
- 利用缓存优化构建时间
- 确保测试、代码检查、发布环节遵循最佳实践
Before Making Changes
修改前须知
ALWAYS verify current state first:
bash
undefined务必先验证当前状态:
bash
undefinedGet repo info
获取仓库信息
gh repo view --json nameWithOwner,owner,name
gh repo view --json nameWithOwner,owner,name
List existing workflows
列出现有工作流
gh workflow list
gh workflow list
Check recent runs
查看最近的运行记录
gh run list --limit 10
gh run list --limit 10
View workflow files
查看工作流文件
ls -la .github/workflows/
undefinedls -la .github/workflows/
undefinedComplete Rust CI Workflow
完整的Rust CI工作流
See the full workflow template with:
- Check job (format, clippy, check)
- Test job (unit, integration, doc tests)
- Coverage job (tarpaulin, codecov)
- Audit job (security, licenses)
See linked files for caching strategies, troubleshooting, and release management.
查看包含以下内容的完整工作流模板:
- 检查任务(格式化、clippy检查、cargo check)
- 测试任务(单元测试、集成测试、文档测试)
- 覆盖率任务(tarpaulin、codecov)
- 审计任务(安全、许可证)
查看关联文件了解缓存策略、故障排查和发布管理的详细内容。
Core Workflow Components
核心工作流组件
| Job | Purpose | Tools |
|---|---|---|
| check | Code quality | rustfmt, clippy, cargo check |
| test | Verification | cargo test |
| coverage | Test metrics | cargo tarpaulin |
| audit | Security | cargo audit, deny |
| 任务 | 用途 | 工具 |
|---|---|---|
| check | 代码质量检查 | rustfmt, clippy, cargo check |
| test | 代码验证 | cargo test |
| coverage | 测试指标统计 | cargo tarpaulin |
| audit | 安全审计 | cargo audit, deny |
Common Patterns
常见模式
- Caching: Dependencies, target directory, sccache
- Matrix builds: Multiple Rust versions, targets
- Conditional jobs: Skip on docs-only changes
- Quality gates: Block merge on failures
- 缓存:依赖包、target目录、sccache
- 矩阵构建:多Rust版本、多目标平台
- 条件任务:仅文档变更时跳过任务
- 质量门禁:检查失败时阻止合并
PR Check Attachment Guardrail
PR检查附加防护
- After pushing fixes, validate checks are attached to the PR head SHA:
gh pr view --json statusCheckRollup,mergeStateStatusgh run list --commit <head_sha>
- If rollup is empty for required checks, treat as blocked and investigate trigger/path conditions.
- 推送修复后,验证检查是否关联到PR的头部SHA:
gh pr view --json statusCheckRollup,mergeStateStatusgh run list --commit <head_sha>
- 如果必填检查的汇总为空,则视为合并被阻止,需排查触发条件或路径规则。