Files
devstar/.gitea/workflows/devstar-studio-e2e.yaml

78 lines
2.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: DevStar E2E Test
on:
workflow_dispatch:
pull_request: # 【必须加】允许 PR 触发
branches: [ main, master ] # 根据你的主分支名字改,通常是 main
permissions:
contents: read
pull-requests: write
jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: start DevStar Container
run: |
# 启动容器
LOGS=$(public/assets/install.sh start \
--port=8082 \
--ssh-port=2224 \
--data-dir=/tmp/devstar_ci \
--image=devstar-studio:latest 2>&1)
echo "$LOGS"
TARGET_URL=$(echo "$LOGS" | grep -o 'http://[^ ]*' | tail -1 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g")
echo "TARGET_URL=$TARGET_URL" >> $GITHUB_ENV
- name: Run E2E Tests
run: |
make e2e-test TARGET_URL="$TARGET_URL"
env:
GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT: "true"
- name: 4. Upload E2E Test Report
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-test-report
path: tests/e2e/reports/
- name: Post Test Results
if: always() && github.event_name == 'pull_request'
uses: actions/github-script@v6
env:
# 传入任务状态success 或 failure
TEST_RESULT: ${{ job.status }}
with:
script: |
const testResult = process.env.TEST_RESULT || '未知';
const isSuccess = testResult === 'success';
// 动态生成构建链接
const runUrl = `${context.payload.repository.html_url}/actions/runs/${context.runId}`;
const comment = `
## 📋 E2E 测试结果报告
### 测试状态
${isSuccess ? '✅ **通过 (Passed)**' : '❌ **失败 (Failed)**'}
### 🔍 详细报告
HTML 报告已上传至 Artifacts请点击下方链接查看。
👉 [查看运行日志与下载报告](${runUrl})
### 🏗️ 构建信息
- **工作流**: ${context.workflow}
- **提交**: ${context.payload.pull_request.head.sha.slice(0, 7)}
- **触发者**: @${context.actor}
---
> *此评论由 DevStar Actions 自动生成,用于 PR 质量检查。*
`;
// 发送评论
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});