在 CI 上运行
Tapilot 设计为 CI-native,没有桌面依赖,headless 模式默认开启。
GitHub Actions
yaml
# .github/workflows/e2e.yml
name: E2E Tests
on: [push, pull_request]
jobs:
web-e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npx mobai-api &
- run: sleep 3
- name: Run Web tests
run: |
curl -fsS -X POST http://localhost:3210/web/launch \
-H "Content-Type: application/json" \
-d '{"url":"https://your-site.com","headless":true}'
curl -fsS -X POST http://localhost:3210/web/assert \
-H "Content-Type: application/json" \
-d '{"selector":"h1","text":"Expected"}'
android-e2e:
runs-on: macos-latest # 需要 KVM/hypervisor, macOS runner 最稳
steps:
- uses: actions/checkout@v4
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
script: |
npx mobai-api &
sleep 3
# 调 DSL 或 HTTP API参数化 / 多环境
把环境变量注入到 DSL 的 ${VAR}:
yaml
vars:
BASE_URL: "${BASE_URL}" # 从 env 读
TOKEN: "${TEST_TOKEN}"产物 / Artifact
每次测试产生 tests/reports/TIMESTAMP/TEST_ID/ 目录。CI 建议:
yaml
- uses: actions/upload-artifact@v4
if: always()
with:
name: tapilot-report
path: tests/reports/并行多设备
Tapilot 的 runner 原生支持并行多设备,见 Solvers。
失败通知
bash
export SLACK_WEBHOOK_URL="https://hooks.slack.com/..."
export DISCORD_WEBHOOK_URL="https://discord.com/api/webhooks/..."DSL 跑失败会自动推到配置的 webhook。