testing-ci
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesetesting-ci
testing-ci
Purpose
用途
This skill automates CI/CD pipelines using GitHub Actions, focusing on testing workflows. It handles parallel test execution, quarantines flaky tests, generates reports in JUnit XML or Allure formats, and enforces coverage gates to ensure code quality in repositories.
该技能使用GitHub Actions自动化CI/CD流水线,专注于测试工作流。它支持并行测试执行、隔离不稳定测试、生成JUnit XML或Allure格式的报告,并通过覆盖率门禁确保代码仓库的代码质量。
When to Use
适用场景
Use this skill when setting up or optimizing CI for GitHub repos, especially for projects with large test suites (e.g., >1000 tests), to reduce run times via parallel sharding. Apply it for flaky test management in unstable environments or when integrating coverage checks before merges.
当你为GitHub仓库搭建或优化CI时使用该技能,尤其适用于拥有大型测试套件(例如超过1000个测试用例)的项目,可通过并行分片缩短运行时间。在不稳定环境中管理不稳定测试,或者在代码合并前集成覆盖率检查时,也可使用该技能。
Key Capabilities
核心能力
- Configure GitHub Actions workflows with parallel sharding using the strategy in YAML.
matrix - Quarantine flaky tests by marking them in reports and rerunning subsets automatically.
- Generate JUnit XML reports via tools like or Allure for detailed test insights.
junit-report - Enforce coverage gates with thresholds (e.g., >80% line coverage) using tools like Codecov.
- Integrate with GitHub APIs for workflow dispatching and status checks, requiring authentication via .
$GITHUB_TOKEN
- 使用YAML中的策略配置支持并行分片的GitHub Actions工作流。
matrix - 通过在报告中标记不稳定测试并自动重新运行子集来隔离这些测试。
- 通过等工具生成JUnit XML报告,或使用Allure生成详细的测试洞察报告。
junit-report - 使用Codecov等工具设置阈值(例如行覆盖率>80%)来强制执行覆盖率门禁。
- 与GitHub API集成以实现工作流调度和状态检查,需通过进行身份验证。
$GITHUB_TOKEN
Usage Patterns
使用模式
Invoke this skill via OpenClaw CLI commands prefixed with . For API usage, send requests to the OpenClaw endpoint (e.g., POST /api/skills/testing-ci). In code, embed it in scripts by checking for the skill ID and passing parameters like workflow names or test shards. Always set environment variables for secrets, such as , before execution. For parallel testing, define shards in your workflow YAML and trigger runs programmatically.
openclaw testing-ci$GITHUB_TOKEN通过前缀为的OpenClaw CLI命令调用该技能。API使用时,向OpenClaw端点发送请求(例如POST /api/skills/testing-ci)。在代码中,可通过检查技能ID并传入工作流名称或测试分片等参数,将其嵌入脚本中。执行前务必为敏感信息设置环境变量,例如。对于并行测试,在工作流YAML中定义分片并以编程方式触发运行。
openclaw testing-ci$GITHUB_TOKENCommon Commands/API
常用命令/API
- CLI: Run a workflow with parallel sharding:
openclaw testing-ci run --workflow my-repo/tests.yml --parallel 4 --token $GITHUB_TOKEN - CLI: Quarantine flaky tests:
openclaw testing-ci quarantine --pattern "flaky-*" --report junit.xml - API: Create a workflow: POST /api/skills/testing-ci/workflows with JSON body:
{"name": "build", "matrix": {"shards": [1,2,3,4]}} - API: Get coverage report: GET /api/skills/testing-ci/coverage?gate=80
- Code snippet (YAML config for GitHub Actions):
jobs: test: strategy: matrix: shard: [1, 2, 3, 4] run: npm test --shard=${{ matrix.shard }}/4 - Code snippet (Shell script to handle flaky tests):
if grep -q "flaky" junit.xml; then openclaw testing-ci quarantine --file junit.xml fi
- CLI:运行带并行分片的工作流:
openclaw testing-ci run --workflow my-repo/tests.yml --parallel 4 --token $GITHUB_TOKEN - CLI:隔离不稳定测试:
openclaw testing-ci quarantine --pattern "flaky-*" --report junit.xml - API:创建工作流:向POST /api/skills/testing-ci/workflows发送JSON请求体:
{"name": "build", "matrix": {"shards": [1,2,3,4]}} - API:获取覆盖率报告:GET /api/skills/testing-ci/coverage?gate=80
- 代码片段(GitHub Actions的YAML配置):
jobs: test: strategy: matrix: shard: [1, 2, 3, 4] run: npm test --shard=${{ matrix.shard }}/4 - 代码片段(处理不稳定测试的Shell脚本):
if grep -q "flaky" junit.xml; then openclaw testing-ci quarantine --file junit.xml fi
Integration Notes
集成说明
Integrate with GitHub by providing a personal access token in for API calls. For JUnit/Allure reports, ensure your workflow outputs XML files and upload them via GitHub Actions artifacts. Use parallel sharding by defining matrices in workflow YAML, then trigger via OpenClaw: . For coverage gates, integrate with services like Codecov by adding a step in your workflow: . Always validate inputs to avoid errors, such as checking if is set.
$GITHUB_TOKENopenclaw testing-ci dispatch --repo owner/repo --ref maincurl -Os codecov.io/bash && bash codecov -t $CODECOV_TOKEN$GITHUB_TOKEN通过在中提供个人访问令牌,与GitHub进行API调用集成。对于JUnit/Allure报告,确保工作流输出XML文件并通过GitHub Actions工件上传。在工作流YAML中定义矩阵以实现并行分片,然后通过OpenClaw触发:。对于覆盖率门禁,通过在工作流中添加步骤与Codecov等服务集成:。始终验证输入以避免错误,例如检查是否已设置。
$GITHUB_TOKENopenclaw testing-ci dispatch --repo owner/repo --ref maincurl -Os codecov.io/bash && bash codecov -t $CODECOV_TOKEN$GITHUB_TOKENError Handling
错误处理
Handle workflow failures by checking exit codes in scripts (e.g., if , retry with ). For API errors, parse responses for status codes (e.g., 401 for auth issues, resolve by verifying ). In parallel runs, use sharding to isolate failures; quarantine flaky tests to prevent false negatives. Common issues: Invalid YAML syntax—validate with before running; coverage gate failures—adjust thresholds via config flags like .
$? != 0openclaw testing-ci rerun --workflow ID$GITHUB_TOKENyamllint--gate 75通过检查脚本中的退出码处理工作流失败(例如,如果,使用重试)。对于API错误,解析响应状态码(例如401表示身份验证问题,可通过验证解决)。在并行运行中,使用分片隔离故障;隔离不稳定测试以避免假阴性。常见问题:YAML语法无效——运行前使用验证;覆盖率门禁失败——通过等配置标志调整阈值。
$? != 0openclaw testing-ci rerun --workflow ID$GITHUB_TOKENyamllint--gate 75Concrete Usage Examples
具体使用示例
- Set up parallel CI for a Node.js repo: Create a workflow file, then run: . This shards tests across 4 runners, reducing execution time from 10m to 3m, and generates a JUnit report for analysis.
openclaw testing-ci run --workflow .github/workflows/tests.yml --parallel 4 --token $GITHUB_TOKEN - Quarantine and report flaky tests: After a failed run, execute: . This isolates flaky tests, reruns them, and integrates the Allure report into your GitHub workflow for visual debugging.
openclaw testing-ci quarantine --report allure-results.xml --pattern "test_flaky_*"
- 为Node.js仓库搭建并行CI:创建工作流文件,然后运行:。该命令将测试分片到4个运行器执行,将执行时间从10分钟缩短至3分钟,并生成JUnit报告用于分析。
openclaw testing-ci run --workflow .github/workflows/tests.yml --parallel 4 --token $GITHUB_TOKEN - 隔离并报告不稳定测试:运行失败后,执行:。该命令会隔离不稳定测试、重新运行它们,并将Allure报告集成到GitHub工作流中以进行可视化调试。
openclaw testing-ci quarantine --report allure-results.xml --pattern "test_flaky_*"
Graph Relationships
关联关系
- Related to cluster: "testing" (e.g., links to skills like "unit-testing" for deeper test implementation).
- Tagged with: "ci-cd" (connects to "deployment" skills), "github-actions" (integrates with "repo-management"), "parallel" (shares with "scalability" tools), "flaky" (links to "error-analysis"), "testing" (groups with "test-automation").
- 属于集群:"testing"(例如与"unit-testing"等技能关联,用于更深入的测试实现)。
- 标签关联:"ci-cd"(与"deployment"技能关联)、"github-actions"(与"repo-management"集成)、"parallel"(与"scalability"工具共享)、"flaky"(与"error-analysis"关联)、"testing"(与"test-automation"归为一类)。