Repository navigation
fix(ci): replace Docker-based pr-size-labeler with pure-JS github-script - #1548
Conversation
The codelytv/pr-size-labeler@v1 action is Docker-based — it builds an alpine:3.15 image from Docker Hub at every workflow run. When Docker Hub rate-limits or times out (regular occurrence on busy mornings), the action fails during image build BEFORE the `with:` inputs are processed, so `continue-on-error: true` on the step does NOT contain the failure. The whole label-pr job goes red, which leaves a false "PR is broken" signal across the entire PR list. PR #1547 (rolling-log fmt-layer fix) hit this today: failed to resolve source metadata for docker.io/library/alpine:3.15: failed to do request: ... dial tcp 54.158.241.65:443: i/o timeout Replaces the action with an inline `actions/github-script@v7` step that computes additions+deletions from the PR payload, picks the appropriate `size: XS/S/M/L/XL` label using the same thresholds the codelytv config used (so historical label meanings stay consistent), removes any stale size labels, and applies the chosen one via the GitHub API. Pure JS on the node20 runner — no Docker, no registry pulls, no rate limits. `continue-on-error: true` retained on both steps as defense in depth: if the GH API request itself fails for some other reason (GitHub outage, secrets misconfig), the label-pr job still doesn't poison the PR view. Co-Authored-By: Claude Opus 4.7 <[email protected]>
joelteply
left a comment
There was a problem hiding this comment.
Adversarial review verdict: APPROVE (per [[agent-review-as-acceptable-approval]] — GH blocks self-approve via API, posting as comment-review; merger daemon should treat this as the agent approval signal).
Correctness: Thresholds (XS≤10, S≤50, M≤250, L≤500, XL=∞) match prior codelytv config exactly. Boundary semantics preserved by <=: at exactly 10 → XS, 11 → S, matches codelytv's xs_max_size: 10. totalChanges = additions + deletions matches codelytv's metric — historical 'size: M' meaning preserved across cutover.
Robustness: if (!pr) defends against non-PR contexts. (pr.labels || []) and (pr.additions || 0) defend against missing fields. The 404 swallow on removeLabel uses e.status — correct property on Octokit RequestError (not e.response.status); actions/github-script wraps with @octokit/request-error which exposes status directly. Race-condition handling on stale removal is correct.
Traits / API: github.rest.issues.addLabels({owner, repo, issue_number, labels:[chosen]}) and removeLabel({owner, repo, issue_number, name}) are canonical Octokit shapes. pull-requests: write already declared at job level.
Architecture / Modularity / Elegance: Inline script right-sized for ~40 lines. Thresholds array DRY. 'Why Docker was bad' rationale preserved in leading comment — future readers won't revert.
Speed: N+1 removeLabel bounded by size-label cardinality (max 4 stale). Negligible.
continue-on-error retention: Still appropriate — transient GH API failures shouldn't poison PR readiness, same as before.
No off-by-one, no wrong API shape, no missing permission, no removed defensive coding. Docker Hub failure mode that lit up #1547 is structurally eliminated.
APPROVE.
Summary
Replace the Docker-based
codelytv/pr-size-labeler@v1with a pure-JSactions/github-script@v7step. Same thresholds (XS≤10, S≤50, M≤250, L≤500, XL anything larger), same labels, same sync semantics — no Docker.Why
codelytv/pr-size-labeler@v1builds analpine:3.15image from Docker Hub at every workflow invocation. When Docker Hub rate-limits or its registry times out (regular occurrence), the action fails during image build before thewith:inputs are even processed, socontinue-on-error: trueon the step doesn't contain the failure — the wholelabel-prjob goes red.PR #1547 hit this earlier today:
Red
label-prchecks across the PR list are an active reliability lie — they look like real failures and mask the green substantive checks (validate, etc).What changed
.github/workflows/pr-labeler.yml:Add size labelstep now usesactions/github-script@v7instead ofcodelytv/pr-size-labeler@v1.additions + deletionsfrom the PR payload, picks the size category against the same thresholds (preserves historical label meaning across the cutover), removes stale size labels, applies the chosen one viagithub.rest.issues.{addLabels,removeLabel}.continue-on-error: trueretained as defense in depth — if the GH API itself flakes, the labeler still doesn't poison the PR view.Test plan
label-prpasses and the correctsize: M(or whichever) label appears.size:labels are removed when a PR grows fromsize: S→size: M.