Skip to content

闭环修复演示: buggy_shop 6个Bug全部修复, 通过率100% #15

闭环修复演示: buggy_shop 6个Bug全部修复, 通过率100%

闭环修复演示: buggy_shop 6个Bug全部修复, 通过率100% #15

Workflow file for this run

# TestPilot AI - GitHub Actions 自动化测试模板(v4.0)
#
# 使用方式:
# 1. 将此文件放到你的项目 .github/workflows/ 目录下
# 2. 在项目根目录放置 testpilot.json 蓝本文件
# 3. 设置 Secrets: TP_AI_API_KEY(方舟平台API密钥)
# 4. push 代码即自动触发测试
#
# 触发条件可自定义:push、pull_request、定时等
name: TestPilot AI 自动化测试
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
# 也可以手动触发
workflow_dispatch:
inputs:
blueprint:
description: '蓝本文件路径'
required: false
default: 'testpilot.json'
base_url:
description: '被测应用URL(覆盖蓝本中的值)'
required: false
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
# 1. 检出代码
- name: 检出代码
uses: actions/checkout@v4
# 2. 安装 Python
- name: 安装 Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
# 3. 安装 Node.js(如果被测应用需要)
- name: 安装 Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
# 4. 安装 TestPilot AI
- name: 安装 TestPilot AI
run: |
pip install poetry
cd testpilot # 改为你的 TestPilot 安装路径
poetry install --no-interaction
poetry run playwright install chromium
poetry run playwright install-deps
# 5. 启动被测应用(按需修改)
- name: 启动被测应用
run: |
npm install
npm run build
npm run start &
sleep 5 # 等待应用启动
# 6. 启动 TestPilot 引擎
- name: 启动 TestPilot 引擎
env:
TP_AI_API_KEY: ${{ secrets.TP_AI_API_KEY }}
run: |
cd testpilot
poetry run python cli.py serve &
sleep 3 # 等待引擎启动
# 7. 执行测试
- name: 执行 TestPilot 测试
run: |
cd testpilot
BLUEPRINT="${{ github.event.inputs.blueprint || 'testpilot.json' }}"
BASE_URL="${{ github.event.inputs.base_url || '' }}"
CMD="poetry run python cli.py run -b ../$BLUEPRINT -o ../test-report.xml -f junit"
if [ -n "$BASE_URL" ]; then
CMD="$CMD --base-url $BASE_URL"
fi
$CMD || true # 不让测试失败阻断流水线
# 8. 同时生成HTML报告
- name: 生成HTML报告
if: always()
run: |
cd testpilot
poetry run python cli.py run -b ../testpilot.json -o ../test-report.html -f html || true
# 9. 上传测试报告
- name: 上传测试报告
if: always()
uses: actions/upload-artifact@v4
with:
name: testpilot-reports
path: |
test-report.xml
test-report.html
retention-days: 30
# 10. 发布JUnit测试结果(PR中显示)
- name: 发布测试结果
if: always()
uses: mikepenz/action-junit-report@v4
with:
report_paths: 'test-report.xml'
fail_on_failure: false
summary: 'TestPilot AI 自动化测试结果'