Skip to content

Commit 9e96782

Browse files
authored
[CE] add ce log analysis (#4503)
1 parent c15f219 commit 9e96782

1 file changed

Lines changed: 47 additions & 8 deletions

File tree

.github/workflows/formers_bot_analysis.yml

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- "Fleet Model Test"
1010
- "Codestyle Check"
1111
- "CI_XPU"
12+
- "Model Unittest GPU CE Develop"
13+
- "Unittest GPU CE"
1214
types:
1315
- completed
1416

@@ -23,23 +25,28 @@ jobs:
2325
actions: read
2426
outputs:
2527
skip: ${{ steps.check.outputs.skip }}
28+
is_schedule: ${{ steps.check.outputs.is_schedule }}
2629
pr_number: ${{ steps.check.outputs.pr_number }}
2730
failed_job_urls: ${{ steps.check.outputs.failed_job_urls }}
2831
failed_run_ids: ${{ steps.check.outputs.failed_run_ids }}
2932
steps:
3033
- name: Check all workflows done and collect failed job URLs
3134
id: check
3235
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
REPO: ${{ github.repository }}
35-
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
REPO: ${{ github.repository }}
38+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
39+
TRIGGER_EVENT: ${{ github.event.workflow_run.event }}
40+
TRIGGERING_RUN_ID: ${{ github.event.workflow_run.id }}
3641
run: |
3742
python3 - <<'PYEOF'
3843
import json, os, urllib.request, sys, time
3944
40-
token = os.environ['GITHUB_TOKEN']
41-
repo = os.environ['REPO']
42-
head_sha = os.environ['HEAD_SHA']
45+
token = os.environ['GITHUB_TOKEN']
46+
repo = os.environ['REPO']
47+
head_sha = os.environ['HEAD_SHA']
48+
trigger_event = os.environ.get('TRIGGER_EVENT', '')
49+
triggering_run_id = os.environ.get('TRIGGERING_RUN_ID', '')
4350
4451
watched = {
4552
"Unittest GPU CI", "Model Unittest GPU CI",
@@ -75,6 +82,35 @@ jobs:
7582
# GitHub workflow_run completed 后状态同步有延迟
7683
time.sleep(20)
7784
85+
# ── 定时触发路径:直接检查触发本次的 run,不依赖 PR ──────────────
86+
if trigger_event == 'schedule':
87+
print(f"Schedule trigger detected, run_id={triggering_run_id}")
88+
run_data = gh_get(
89+
f"https://api.github.com/repos/{repo}/actions/runs/{triggering_run_id}"
90+
)
91+
conclusion = run_data.get('conclusion', '')
92+
if conclusion != 'failure':
93+
skip(f"Schedule run {triggering_run_id} did not fail (conclusion: {conclusion})")
94+
jobs_data = gh_get(
95+
f"https://api.github.com/repos/{repo}/actions/runs"
96+
f"/{triggering_run_id}/jobs?per_page=100"
97+
)
98+
failed_job_urls = [
99+
j['html_url'] for j in jobs_data.get('jobs', [])
100+
if j['conclusion'] == 'failure'
101+
and not any(kw in j['name'].lower() for kw in skip_keywords)
102+
]
103+
failed_job_urls = list(dict.fromkeys(failed_job_urls))
104+
print(f"Schedule failed_job_urls: {failed_job_urls}")
105+
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
106+
f.write("skip=false\n")
107+
f.write("is_schedule=true\n")
108+
f.write("pr_number=\n")
109+
f.write(f"failed_job_urls={' '.join(failed_job_urls)}\n")
110+
f.write(f"failed_run_ids={triggering_run_id}\n")
111+
sys.exit(0)
112+
113+
# ── PR 触发路径:原有逻辑 ─────────────────────────────────────────
78114
# 1. find PR
79115
pr_number = None
80116
for state in ['open', 'closed']:
@@ -161,7 +197,6 @@ jobs:
161197
162198
failed_job_urls.append(job['html_url'])
163199
164-
# 去重
165200
failed_job_urls = list(dict.fromkeys(failed_job_urls))
166201
167202
# 失败 workflow 的 run_id 列表(用于按 run_id 上报到 monitor,
@@ -173,6 +208,7 @@ jobs:
173208
174209
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
175210
f.write("skip=false\n")
211+
f.write("is_schedule=false\n")
176212
f.write(f"pr_number={pr_number}\n")
177213
f.write(f"failed_job_urls={' '.join(failed_job_urls)}\n")
178214
f.write(f"failed_run_ids={' '.join(failed_run_ids)}\n")
@@ -228,7 +264,10 @@ jobs:
228264

229265
post-comment:
230266
needs: [check-and-collect, analyze]
231-
if: always() && needs.check-and-collect.outputs.skip == 'false'
267+
if: >-
268+
always() &&
269+
needs.check-and-collect.outputs.skip == 'false' &&
270+
needs.check-and-collect.outputs.is_schedule == 'false'
232271
runs-on: ubuntu-latest
233272
permissions:
234273
actions: read

0 commit comments

Comments
 (0)