Skip to content

Commit 18d0695

Browse files
os-zhuangclaude
andauthored
ci(showcase-smoke): 诊断产物按真实 outputDir 上传,失败无产物即报错 (#4931) (#5913)
Showcase Smoke 的上传步骤配的是 examples/app-showcase/playwright-report/, 而这个目录在 CI 下从来不会被创建 —— examples/app-showcase/playwright.config.ts 的 reporter 是 `[['github'], ['list']]`(实测 CI=1 求值),两个都只写 stdout, 没有 html reporter。于是不是「路径写偏了一层」,而是「路径指向一个不存在的 产物」。加上 upload-artifact 的 `if-no-files-found` 缺省为 warn,错配只降成 一条 warning:run 30796529117(2026-08-03,3 failed)的日志里是 ##[warning]No files were found with the provided path: examples/app-showcase/playwright-report/. No artifacts will be uploaded. 该 run 的 artifacts 总数为 0,上传步骤自身仍判绿 —— 每一次失败的截图、trace、 error-context 都随 runner 回收丢掉,这正是一个半数失败的探针长期无从定位的 直接原因。 改动(仅本 workflow 文件): - 上传路径改为 examples/app-showcase/test-results/ —— 由 Playwright 自己解析 确认的 outputDir 绝对路径落点(config 未声明 outputDir,取默认值并按 config 所在目录解析);upload-artifact 的 `path` 按仓库根解析,故保留完整前缀。 未把 playwright-report/ 一并列上:它今天不可能有内容,列上等于留一条永远 为空的死声明。补 html reporter 属 config 面改动,已另行立单。 - 失败路径 `if-no-files-found: error`,并把前提从宽泛的 `failure()` 收窄到 `steps.smoke.outcome == 'failure'`:smoke 失败就一定留下了证据,空的 test-results/ 本身该报警;而更早的步骤倒下时本就无物可收,不该再叠一条 误导性的红。条件保留 `failure()` 是因为不含状态函数的 `if:` 会被套上隐式 `success()`,那样条件永远为假。 - 新增一条绿色路径上传(`ignore`,不会把夜跑弄红):CI 下 `retries: 1`, 「重试后才绿」的 run 会在 test-results/…-retry1/ 留下第一次尝试的 trace, 而那恰是第 1 缺陷最需要的证据 —— 只在 red 时收会永远错过 flaky-green。 验证边界:workflow 无法本地执行。已做 YAML 解析 + 步骤断言、 pnpm check:workflow-status-functions、pnpm check:nul-bytes,并用 Playwright 自身求值确认 outputDir/reporter/retries;真实产物验证发生在下一次夜跑。 本 PR 只修第 2 缺陷,不动探测条件与 spec 文件,故不 Close 本单。 Claude-Session: https://claude.ai/code/session_01GX3sL71LFq8m2usg6VqTSE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7adc841 commit 18d0695

1 file changed

Lines changed: 40 additions & 4 deletions

File tree

.github/workflows/showcase-smoke.yml

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,48 @@ jobs:
4545
working-directory: examples/app-showcase
4646
run: pnpm exec playwright install --with-deps chromium
4747
- name: Run showcase smoke
48+
id: smoke
4849
working-directory: examples/app-showcase
4950
run: pnpm test:smoke
50-
- name: Upload report on failure
51-
if: failure()
51+
# 诊断产物的真实落点是 Playwright 的 `outputDir`,而
52+
# examples/app-showcase/playwright.config.ts 没有声明它 —— 于是取默认值
53+
# `test-results/`,按 **config 文件所在目录** 解析,即
54+
# examples/app-showcase/test-results/。upload-artifact 的 `path` 按仓库根
55+
# 解析(`working-directory` 只对 `run:` 步骤生效),所以这里必须写完整的
56+
# examples/app-showcase/ 前缀。
57+
#
58+
# 之前配的 `playwright-report/` 是 HTML reporter 的输出目录,而 CI 的
59+
# reporter 是 `[['github'], ['list']]` —— 两个都只写 stdout,那个目录从来
60+
# 不会被创建,不是「路径写偏了」而是「路径指向一个不存在的产物」。实测
61+
# run 30796529117(2026-08-03,3 failed):
62+
# ##[warning]No files were found with the provided path:
63+
# examples/app-showcase/playwright-report/. No artifacts will be uploaded.
64+
# 该 run 的 artifacts 总数为 0,而上传步骤本身仍是绿的 —— 每次失败的
65+
# 截图/trace/error-context 都随 runner 回收而丢失(#4931 第 2 缺陷)。
66+
#
67+
# `if-no-files-found: error` 的前提刻意收窄到「smoke 自己失败了」,而不是
68+
# 宽泛的 `failure()`:smoke 失败就一定留下了证据,空的 test-results/ 本身
69+
# 就该报警;但若是更早的步骤(pnpm install / vendor Console)倒下,这里
70+
# 本来就无物可收,不该再叠一条误导性的红。条件里的 `failure()` 不是装饰
71+
# —— GitHub 会给任何不含状态函数的 `if:` 套一层隐式 `success()`,那样
72+
# 这个条件永远为假(理由见 scripts/check-workflow-status-functions.mjs)。
73+
- name: Upload smoke diagnostics (smoke failed)
74+
if: failure() && steps.smoke.outcome == 'failure'
5275
uses: actions/upload-artifact@v7
5376
with:
54-
name: showcase-smoke-report
55-
path: examples/app-showcase/playwright-report/
77+
name: showcase-smoke-diagnostics
78+
path: examples/app-showcase/test-results/
79+
if-no-files-found: error
80+
retention-days: 7
81+
# 绿也可能是「重试后才绿」(CI 下 `retries: 1`):第一次尝试的 trace 与
82+
# 截图就躺在 test-results/…-retry1/ 里,而那正是第 1 缺陷(图表面板时红时
83+
# 绿)最需要的证据 —— 只在 red 时收会永远错过 flaky-green。干净的绿则
84+
# 无物可收,故用 `ignore`:这一步绝不允许把绿色夜跑弄红。
85+
- name: Upload flaky-retry diagnostics (smoke passed)
86+
if: success()
87+
uses: actions/upload-artifact@v7
88+
with:
89+
name: showcase-smoke-flaky-diagnostics
90+
path: examples/app-showcase/test-results/
91+
if-no-files-found: ignore
5692
retention-days: 7

0 commit comments

Comments
 (0)