testing-ci

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

testing-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
    matrix
    strategy in YAML.
  • Quarantine flaky tests by marking them in reports and rerunning subsets automatically.
  • Generate JUnit XML reports via tools like
    junit-report
    or Allure for detailed test insights.
  • 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中的
    matrix
    策略配置支持并行分片的GitHub Actions工作流。
  • 通过在报告中标记不稳定测试并自动重新运行子集来隔离这些测试。
  • 通过
    junit-report
    等工具生成JUnit XML报告,或使用Allure生成详细的测试洞察报告。
  • 使用Codecov等工具设置阈值(例如行覆盖率>80%)来强制执行覆盖率门禁。
  • 与GitHub API集成以实现工作流调度和状态检查,需通过
    $GITHUB_TOKEN
    进行身份验证。

Usage Patterns

使用模式

Invoke this skill via OpenClaw CLI commands prefixed with
openclaw testing-ci
. 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
$GITHUB_TOKEN
, before execution. For parallel testing, define shards in your workflow YAML and trigger runs programmatically.
通过前缀为
openclaw testing-ci
的OpenClaw CLI命令调用该技能。API使用时,向OpenClaw端点发送请求(例如POST /api/skills/testing-ci)。在代码中,可通过检查技能ID并传入工作流名称或测试分片等参数,将其嵌入脚本中。执行前务必为敏感信息设置环境变量,例如
$GITHUB_TOKEN
。对于并行测试,在工作流YAML中定义分片并以编程方式触发运行。

Common 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
$GITHUB_TOKEN
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:
openclaw testing-ci dispatch --repo owner/repo --ref main
. For coverage gates, integrate with services like Codecov by adding a step in your workflow:
curl -Os codecov.io/bash && bash codecov -t $CODECOV_TOKEN
. Always validate inputs to avoid errors, such as checking if
$GITHUB_TOKEN
is set.
通过在
$GITHUB_TOKEN
中提供个人访问令牌,与GitHub进行API调用集成。对于JUnit/Allure报告,确保工作流输出XML文件并通过GitHub Actions工件上传。在工作流YAML中定义矩阵以实现并行分片,然后通过OpenClaw触发:
openclaw testing-ci dispatch --repo owner/repo --ref main
。对于覆盖率门禁,通过在工作流中添加步骤与Codecov等服务集成:
curl -Os codecov.io/bash && bash codecov -t $CODECOV_TOKEN
。始终验证输入以避免错误,例如检查
$GITHUB_TOKEN
是否已设置。

Error Handling

错误处理

Handle workflow failures by checking exit codes in scripts (e.g., if
$? != 0
, retry with
openclaw testing-ci rerun --workflow ID
). For API errors, parse responses for status codes (e.g., 401 for auth issues, resolve by verifying
$GITHUB_TOKEN
). In parallel runs, use sharding to isolate failures; quarantine flaky tests to prevent false negatives. Common issues: Invalid YAML syntax—validate with
yamllint
before running; coverage gate failures—adjust thresholds via config flags like
--gate 75
.
通过检查脚本中的退出码处理工作流失败(例如,如果
$? != 0
,使用
openclaw testing-ci rerun --workflow ID
重试)。对于API错误,解析响应状态码(例如401表示身份验证问题,可通过验证
$GITHUB_TOKEN
解决)。在并行运行中,使用分片隔离故障;隔离不稳定测试以避免假阴性。常见问题:YAML语法无效——运行前使用
yamllint
验证;覆盖率门禁失败——通过
--gate 75
等配置标志调整阈值。

Concrete Usage Examples

具体使用示例

  1. Set up parallel CI for a Node.js repo: Create a workflow file, then run:
    openclaw testing-ci run --workflow .github/workflows/tests.yml --parallel 4 --token $GITHUB_TOKEN
    . This shards tests across 4 runners, reducing execution time from 10m to 3m, and generates a JUnit report for analysis.
  2. Quarantine and report flaky tests: After a failed run, execute:
    openclaw testing-ci quarantine --report allure-results.xml --pattern "test_flaky_*"
    . This isolates flaky tests, reruns them, and integrates the Allure report into your GitHub workflow for visual debugging.
  1. 为Node.js仓库搭建并行CI:创建工作流文件,然后运行:
    openclaw testing-ci run --workflow .github/workflows/tests.yml --parallel 4 --token $GITHUB_TOKEN
    。该命令将测试分片到4个运行器执行,将执行时间从10分钟缩短至3分钟,并生成JUnit报告用于分析。
  2. 隔离并报告不稳定测试:运行失败后,执行:
    openclaw testing-ci quarantine --report allure-results.xml --pattern "test_flaky_*"
    。该命令会隔离不稳定测试、重新运行它们,并将Allure报告集成到GitHub工作流中以进行可视化调试。

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"归为一类)。