|
84 | 84 | PR_COMMENT_PATH: pr_comment.md |
85 | 85 | CHECK_BODY_PATH: check_output.md |
86 | 86 | run: | |
| 87 | + { |
87 | 88 | python - <<'PY' |
88 | 89 | import os, sys, json, math, re |
89 | 90 | import wandb |
@@ -260,7 +261,7 @@ jobs: |
260 | 261 | v = by_rev.get(r,{}).get(bid,{}).get(metric) |
261 | 262 | if isinstance(v,(int,float)) and not (isinstance(v,float) and math.isnan(v)): |
262 | 263 | vals.append(float(v)) |
263 | | - return sum(vals) / len(vals) |
| 264 | + return sum(vals) / max(len(vals), 1) |
264 | 265 | |
265 | 266 | # ----- build TWO tables ----- |
266 | 267 | rows_rt = [] |
@@ -338,21 +339,25 @@ jobs: |
338 | 339 | check_body_path.write_text(check_body+"\n", encoding="utf-8") |
339 | 340 | pr_comment_path.write_text(comment_body+"\n", encoding="utf-8") |
340 | 341 |
|
341 | | - # flag for next steps |
342 | | - has_regressions_path = Path("HAS_REGRESSIONS.txt") |
343 | | - has_regressions_path.write_text("true\n" if reg_found else "false\n", encoding="utf-8") |
| 342 | + # exit with 1 if regressions are found, 0 otherwise |
| 343 | + sys.exit(1 if reg_found else 0) |
344 | 344 | PY |
| 345 | + echo "HAS_REGRESSIONS=$?" >> "$GITHUB_ENV" |
| 346 | + } || true |
345 | 347 |
|
346 | 348 | # expose outputs to later steps |
347 | | - echo "HAS_REGRESSIONS=$(cat HAS_REGRESSIONS.txt)" >> "$GITHUB_ENV" |
348 | | - { |
349 | | - echo 'CHECK_OUTPUT<<__EOF__' |
350 | | - cat check_output.md |
351 | | - echo '__EOF__' |
352 | | - } >> "$GITHUB_ENV" |
353 | | -
|
| 349 | + if [ -f "check_output.md" ]; then |
| 350 | + { |
| 351 | + echo 'CHECK_OUTPUT<<__EOF__' |
| 352 | + cat check_output.md |
| 353 | + echo '__EOF__' |
| 354 | + } >> "$GITHUB_ENV" |
| 355 | + else |
| 356 | + echo "CHECK_OUTPUT=" >> "$GITHUB_ENV" |
| 357 | + fi |
| 358 | + |
354 | 359 | # only set SCRIPT_OUTPUT when we actually want to comment |
355 | | - if [ -s "pr_comment.md" ]; then |
| 360 | + if [ "${HAS_REGRESSIONS}" = "1" ] && [ -s "pr_comment.md" ]; then |
356 | 361 | { |
357 | 362 | echo 'SCRIPT_OUTPUT<<__EOF__' |
358 | 363 | cat pr_comment.md |
@@ -387,7 +392,7 @@ jobs: |
387 | 392 | with: |
388 | 393 | script: | |
389 | 394 | const sha = context.payload.workflow_run.head_sha; |
390 | | - const hasRegs = (process.env.HAS_REGRESSIONS || 'false').trim() === 'true'; |
| 395 | + const hasRegs = (process.env.HAS_REGRESSIONS || '0').trim() === '1'; |
391 | 396 | const conclusion = 'success'; |
392 | 397 | const summary = hasRegs |
393 | 398 | ? '🔴 Regressions detected. See tables below.' |
|
0 commit comments