qwen-code/.github/scripts/check-workflow-size.sh
Shaojin Wen 3b3818db87
fix(ci): keep qwen-autofix.yml under GitHub's 500 KB start-runs limit (#9517)
GitHub does not start runs for a workflow file larger than 500 KB (512,000
bytes) and reports nothing when it stops. qwen-autofix.yml crossed that line
on 2026-08-19 at 512,782 bytes: schedule ticks stopped firing, every
workflow_dispatch sat "queued" forever with zero jobs and could not be
cancelled, and issues/issue_comment went quiet — while pull_request_review
runs kept succeeding, because a PR event resolves the workflow from the PR's
own branch and those carry older, smaller copies of this file. The loop
therefore looked half-alive and stayed dark for a day.

Move 75 long comment blocks (1,326 lines) verbatim into a sibling design
record, .github/workflows/qwen-autofix.md, leaving each block's opening lines
plus a `qwen-autofix.md#af-NNN` pointer where it sat: 518,055 -> 426,437
bytes. No executable line changes — the YAML parses to an identical document
outside `run:`, every `run:` script still passes `bash -n`, and the only lines
removed anywhere are comments. Steps that are duplicated verbatim across jobs
share one pointer so they stay byte-identical.

Add .github/scripts/check-workflow-size.sh (gate at 470,000 bytes), wired into
CI on every profile: a .github-only PR classifies as `github_ci_only` and
skips the `full`-only checks, which is exactly the PR that can trip this.
Tests pin the gate, every workflow's size, and pointer/section symmetry.

Delete qwen-autofix-recovery.yml. It was cloned during the incident on the
theory that the workflow ENTITY was wedged, but it carried the same oversized
file, so its dispatches queued identically and its schedule never fired.
2026-08-20 01:56:45 +00:00

39 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# GitHub does not START RUNS for a workflow file larger than 500 KB (512,000
# bytes), and it says nothing when it stops: schedule ticks vanish, dispatches
# sit "queued" forever with zero jobs, `issues`/`issue_comment` go quiet, and
# only PR-event runs keep working — those resolve the workflow from the PR's
# own branch, so an older, smaller copy runs and the workflow looks half-alive.
# qwen-autofix.yml crossed the line on 2026-08-19 and the autofix loop went
# dark for a day before anyone read the size.
#
# The gate below sits well under the real ceiling on purpose: a PR that trips
# it still has room to land the fix, instead of discovering the wall with no
# space left to move prose out.
set -uo pipefail
GITHUB_LIMIT_BYTES=512000
GATE_BYTES="${WORKFLOW_SIZE_GATE_BYTES:-470000}"
WARN_BYTES=$((GATE_BYTES - 25000))
status=0
shopt -s nullglob
for file in .github/workflows/*.yml .github/workflows/*.yaml; do
if ! size="$(wc -c <"${file}")"; then
echo "::error file=${file}::unable to read ${file}"
status=1
continue
fi
pct=$((size * 100 / GITHUB_LIMIT_BYTES))
if ((size > GATE_BYTES)); then
echo "::error file=${file}::${file} is ${size} bytes — ${pct}% of GitHub's ${GITHUB_LIMIT_BYTES}-byte start-runs limit, past this repo's ${GATE_BYTES}-byte gate. Move prose into a sibling .md and long steps into .github/scripts/; do not raise the gate."
status=1
elif ((size > WARN_BYTES)); then
echo "::warning file=${file}::${file} is ${size} bytes (${pct}% of GitHub's limit) — approaching the ${GATE_BYTES}-byte gate."
fi
done
if ((status == 0)); then
echo "✅ every workflow file is under the ${GATE_BYTES}-byte gate"
fi
exit "${status}"