Skip to content

Commit f1a19f7

Browse files
committed
foo
1 parent 5da90c1 commit f1a19f7

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

.github/workflows/alarm.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
PR_COMMENT_PATH: pr_comment.md
8585
CHECK_BODY_PATH: check_output.md
8686
run: |
87+
{
8788
python - <<'PY'
8889
import os, sys, json, math, re
8990
import wandb
@@ -260,7 +261,7 @@ jobs:
260261
v = by_rev.get(r,{}).get(bid,{}).get(metric)
261262
if isinstance(v,(int,float)) and not (isinstance(v,float) and math.isnan(v)):
262263
vals.append(float(v))
263-
return sum(vals) / len(vals)
264+
return sum(vals) / max(len(vals), 1)
264265
265266
# ----- build TWO tables -----
266267
rows_rt = []
@@ -338,21 +339,25 @@ jobs:
338339
check_body_path.write_text(check_body+"\n", encoding="utf-8")
339340
pr_comment_path.write_text(comment_body+"\n", encoding="utf-8")
340341
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)
344344
PY
345+
echo "HAS_REGRESSIONS=$?" >> "$GITHUB_ENV"
346+
} || true
345347
346348
# 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+
354359
# 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
356361
{
357362
echo 'SCRIPT_OUTPUT<<__EOF__'
358363
cat pr_comment.md
@@ -387,7 +392,7 @@ jobs:
387392
with:
388393
script: |
389394
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';
391396
const conclusion = 'success';
392397
const summary = hasRegs
393398
? '🔴 Regressions detected. See tables below.'

0 commit comments

Comments
 (0)