npx skills add https://github.com/a2f0/tearleads --skill fix-tests首先:使用 agentTool 包装器获取 PR 信息:
./scripts/agents/tooling/agentTool.ts getPrInfo --fields number,headRefName
提取 number 作为 PR_NUMBER 用于后续命令。
此技能用于诊断和修复失败的 CI 作业。当调用时带有参数(例如 /fix-tests electron-e2e),它可以针对特定作业;当调用时不带参数,则诊断所有失败。
| 作业名称 | 工作流 | 大致耗时 |
|---|---|---|
build | build.yml | ~15 分钟 |
web-e2e | web-e2e.yml |
First : Get PR info using the agentTool wrapper:
./scripts/agents/tooling/agentTool.ts getPrInfo --fields number,headRefName
Extract number as PR_NUMBER for use in subsequent commands.
This skill diagnoses and fixes failing CI jobs. It can target a specific job when called with an argument (e.g., /fix-tests electron-e2e) or diagnose all failures when called without arguments.
| Job Name | Workflow | Approx Duration |
|---|---|---|
build | build.yml | ~15 min |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| ~10 分钟 |
electron-e2e | electron-e2e.yml | ~10 分钟 |
android-maestro-release | android-maestro-release.yml | ~20 分钟 |
ios-maestro-release | ios-maestro-release.yml | ~30 分钟 |
website-e2e | website-e2e.yml | ~5 分钟 |
获取当前提交对应的失败工作流运行:
COMMIT=$(git rev-parse HEAD)
./scripts/agents/tooling/agentTool.ts getCiStatus --commit "$COMMIT"
这将返回包含 run_id、status、conclusion 以及 jobs 数组的 JSON,数组中每个作业包含 {name, status, conclusion}。
如果提供了特定的作业名称(例如 /fix-tests electron-e2e),则专注于该作业。否则,从 jobs 数组中识别所有 conclusion == "failure" 的失败作业。
仅下载失败作业的日志(而非所有制品):
# 直接查看失败作业日志(最节省令牌)
gh run view <run-id> --log-failed
# 或者下载特定制品进行详细分析
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact <artifact-name> --dest /tmp/<folder>
| 作业 | 制品名称 | 内容 |
|---|---|---|
build | coverage-reports | 覆盖率 JSON 文件 |
web-e2e | playwright-report | HTML 报告、截图、追踪记录 |
electron-e2e | (仅日志) | Electron 测试输出 |
android-maestro-release | android-maestro-debug | 截图、logcat、UI 层级结构 |
ios-maestro-release | ios-maestro-debug | 截图、日志 |
分析日志以确定失败类型:
症状:ESLint 错误,build 作业日志中的 TypeScript 错误
# 查找 lint 错误
grep -i "error\|warning" /tmp/logs.txt | head -20
# 常见模式:
# - "'foo' is defined but never used"
# - "Type 'X' is not assignable to type 'Y'"
# - "Unexpected any. Specify a different type"
修复:在源文件中解决 lint/类型错误。本地运行以验证:
pnpm lint
pnpm exec tsc -b
症状:测试断言失败,超时错误
# 对于单元测试 (build 作业)
grep -i "fail\|error\|timeout" /tmp/logs.txt
修复:更新测试断言或修复代码逻辑。本地运行:
# 单元测试
pnpm --filter @tearleads/<package> test
# E2E 测试
pnpm --filter @tearleads/client test:e2e
症状:"Coverage threshold not met" 错误
# 查找覆盖率错误
grep -i "coverage\|threshold" /tmp/logs.txt
修复:添加测试以恢复覆盖率。检查哪些文件下降了:
# 本地运行覆盖率测试
pnpm --filter @tearleads/<package> test:coverage
# 检查覆盖率报告
cat packages/<package>/coverage/coverage-summary.json
重点关注:
症状:测试在本地通过,但在 CI 中间歇性失败
常见原因:
修复选项:
.skip 并创建问题症状:网络错误、服务不可用、无测试输出的超时
修复:通常是暂时性的 - 重新运行 CI:
./scripts/agents/tooling/agentTool.ts rerunWorkflow --run-id <run-id>
如果持续存在,检查:
build 作业运行 lint、类型检查、构建以及带覆盖率的测试。
# 本地运行完整的构建流水线
pnpm lint && pnpm exec tsc -b && pnpm build && pnpm test:coverage
常见问题:
pnpm lintpnpm exec tsc -bpnpm buildpnpm --filter @tearleads/<pkg> test:coverage# 下载 Playwright 报告
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact playwright-report --dest /tmp/playwright
open /tmp/playwright/index.html
# 本地运行
pnpm --filter @tearleads/client test:e2e
常见问题:
await page.waitFor* 断言# 下载调试制品
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact android-maestro-debug --dest /tmp/maestro
# 查看截图
open /tmp/maestro/*.png
# 检查 logcat (Android)
grep -i "console\|error\|capacitor" /tmp/maestro/logcat.txt
# 查看 UI 层级结构
cat /tmp/maestro/ui-hierarchy.xml
常见问题:
androidWebViewHierarchy: devtoolswaitForAnimationToEnd 或增加 retryTapIfNoChange在源代码中进行修复
本地验证(运行相关的测试命令)
提交并推送:
git add -A
git commit -S -m "fix(tests): <修复描述>" >/dev/null
git push >/dev/null
报告修复了哪个作业以及更改了什么
如果 Maestro 在 WebView 中找不到元素:
appId: com.tearleads.app
androidWebViewHierarchy: devtools
- launchApp:
clearState: true
- assertVisible: "My Text"
如果应用启动后显示空白白屏,检查 logcat 中的 JavaScript 错误:
# 在 Maestro 调试输出中检查 JS 错误
grep -i "Capacitor/Console\|TypeError\|Error" /tmp/maestro/logcat.txt
# 常见错误:"Object.hasOwn is not a function"
# 这发生在 WebView < Chrome 93 的情况下(系统镜像附带的 WebView 是 91 版)
根本原因:Android 系统镜像(即使是 API 35)默认附带 WebView 91。WebView 91 不支持像 Object.hasOwn 这样的 ES2022 功能。
修复:在 packages/client/src/main.tsx 中为缺失的功能添加 polyfill:
// 在任何导入之前
if (!Object.hasOwn) {
Object.defineProperty(Object, 'hasOwn', {
value: function (obj: object, prop: PropertyKey) {
return Object.prototype.hasOwnProperty.call(obj, prop);
},
configurable: true,
writable: true
});
}
检查模拟器上的 WebView 版本:
adb shell "dumpsys webviewupdate" | grep "Current WebView"
- evalScript: document.querySelector('[data-testid="my-button"]').click()
// 替代方案:
await page.click('.dynamic-class');
// 使用:
await page.getByTestId('button-submit').click();
await page.getByRole('button', { name: 'Submit' }).click();
pnpm --filter @tearleads/<pkg> test:coverage 以验证--log-failed 而不是下载所有制品--jq 过滤以最小化 JSON 响应大小git commit ... >/dev/null && git push >/dev/null每周安装数
1
仓库
首次出现
1 天前
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
web-e2e| web-e2e.yml |
| ~10 min |
electron-e2e | electron-e2e.yml | ~10 min |
android-maestro-release | android-maestro-release.yml | ~20 min |
ios-maestro-release | ios-maestro-release.yml | ~30 min |
website-e2e | website-e2e.yml | ~5 min |
Get the failing workflow run for the current commit:
COMMIT=$(git rev-parse HEAD)
./scripts/agents/tooling/agentTool.ts getCiStatus --commit "$COMMIT"
This returns JSON with run_id, status, conclusion, and jobs array with each job's {name, status, conclusion}.
If a specific job name was provided (e.g., /fix-tests electron-e2e), focus on that job. Otherwise, identify all failing jobs from the jobs array where conclusion == "failure".
Download only the logs for failed jobs (not all artifacts):
# View failed job logs directly (most token-efficient)
gh run view <run-id> --log-failed
# Or download specific artifact for detailed analysis
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact <artifact-name> --dest /tmp/<folder>
| Job | Artifact Name | Contents |
|---|---|---|
build | coverage-reports | Coverage JSON files |
web-e2e | playwright-report | HTML report, screenshots, traces |
electron-e2e | (logs only) | Electron test output |
android-maestro-release | android-maestro-debug | Screenshots, logcat, UI hierarchy |
ios-maestro-release | ios-maestro-debug | Screenshots, logs |
Analyze the logs to determine the failure type:
Symptoms : ESLint errors, TypeScript errors in build job logs
# Look for lint errors
grep -i "error\|warning" /tmp/logs.txt | head -20
# Common patterns:
# - "'foo' is defined but never used"
# - "Type 'X' is not assignable to type 'Y'"
# - "Unexpected any. Specify a different type"
Fix : Address the lint/type error in the source file. Run locally to verify:
pnpm lint
pnpm exec tsc -b
Symptoms : Test assertion failures, timeout errors
# For unit tests (build job)
grep -i "fail\|error\|timeout" /tmp/logs.txt
Fix : Update test assertions or fix the code logic. Run locally:
# Unit tests
pnpm --filter @tearleads/<package> test
# E2E tests
pnpm --filter @tearleads/client test:e2e
Symptoms : "Coverage threshold not met" errors
# Look for coverage errors
grep -i "coverage\|threshold" /tmp/logs.txt
Fix : Add tests to restore coverage. Check which files dropped:
# Run coverage locally
pnpm --filter @tearleads/<package> test:coverage
# Check the coverage report
cat packages/<package>/coverage/coverage-summary.json
Focus on:
Symptoms : Test passes locally but fails intermittently in CI
Common causes :
Fix options :
.skip temporarily and create an issueSymptoms : Network errors, service unavailable, timeout without test output
Fix : Usually transient - rerun CI:
./scripts/agents/tooling/agentTool.ts rerunWorkflow --run-id <run-id>
If persistent, check:
The build job runs lint, type-check, build, and tests with coverage.
# Run the full build pipeline locally
pnpm lint && pnpm exec tsc -b && pnpm build && pnpm test:coverage
Common issues:
pnpm lintpnpm exec tsc -bpnpm buildpnpm --filter @tearleads/<pkg> test:coverage# Download Playwright report
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact playwright-report --dest /tmp/playwright
open /tmp/playwright/index.html
# Run locally
pnpm --filter @tearleads/client test:e2e
Common issues:
await page.waitFor* assertions# Download debug artifacts
./scripts/agents/tooling/agentTool.ts downloadArtifact --run-id <run-id> --artifact android-maestro-debug --dest /tmp/maestro
# View screenshots
open /tmp/maestro/*.png
# Check logcat (Android)
grep -i "console\|error\|capacitor" /tmp/maestro/logcat.txt
# View UI hierarchy
cat /tmp/maestro/ui-hierarchy.xml
Common issues:
androidWebViewHierarchy: devtools to testwaitForAnimationToEnd or increase retryTapIfNoChangeMake the fix in the source code
Verify locally (run the relevant test command)
Commit and push:
git add -A
git commit -S -m "fix(tests): <description of fix>" >/dev/null
git push >/dev/null
Report which job was fixed and what changed
If Maestro can't find elements in a WebView:
appId: com.tearleads.app
androidWebViewHierarchy: devtools
- launchApp:
clearState: true
- assertVisible: "My Text"
If the app shows a blank white screen after launch, check logcat for JavaScript errors:
# Check for JS errors in Maestro debug output
grep -i "Capacitor/Console\|TypeError\|Error" /tmp/maestro/logcat.txt
# Common error: "Object.hasOwn is not a function"
# This occurs on WebView < Chrome 93 (system images ship with WebView 91)
Root cause : Android system images (even API 35) ship with WebView 91 by default. WebView 91 doesn't support ES2022 features like Object.hasOwn.
Fix : Add polyfills for missing features in packages/client/src/main.tsx:
// Before any imports
if (!Object.hasOwn) {
Object.defineProperty(Object, 'hasOwn', {
value: function (obj: object, prop: PropertyKey) {
return Object.prototype.hasOwnProperty.call(obj, prop);
},
configurable: true,
writable: true
});
}
Check WebView version on emulator:
adb shell "dumpsys webviewupdate" | grep "Current WebView"
- evalScript: document.querySelector('[data-testid="my-button"]').click()
// Instead of:
await page.click('.dynamic-class');
// Use:
await page.getByTestId('button-submit').click();
await page.getByRole('button', { name: 'Submit' }).click();
pnpm --filter @tearleads/<pkg> test:coverage to verify--log-failed instead of downloading all artifacts when possible--jq filtering to minimize JSON response sizegit commit ... >/dev/null && git push >/dev/nullWeekly Installs
1
Repository
First Seen
1 day ago
Security Audits
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Azure Data Explorer (Kusto) 查询技能:KQL数据分析、日志遥测与时间序列处理
114,200 周安装