Skip to content

refactor(ci): extract shared helpers from description-check scripts#5486

Open
rudra496 wants to merge 1 commit into
odysseus-dev:devfrom
rudra496:refactor/2453-extract-shared-ci-helpers
Open

refactor(ci): extract shared helpers from description-check scripts#5486
rudra496 wants to merge 1 commit into
odysseus-dev:devfrom
rudra496:refactor/2453-extract-shared-ci-helpers

Conversation

@rudra496

Copy link
Copy Markdown
Contributor

Summary

The two description-check scripts — check-pr-description.js and check-issue-description.js — had three near-identical blocks of logic copied between them: markdown section extraction, fail-soft label management, and find-by-marker comment upsert/delete. Every fix had to be made twice, and the two copies had already drifted (the issue script escaped ? in Are you willing to implement this? as \\? while the PR script didn't).

This PR extracts the shared logic into .github/scripts/lib/:

  • markdown.jsstrip(text) and section(body, heading). section escapes regex specials in the heading internally so callers pass plain text (e.g. Are you willing to implement this? without pre-escaping the ?). This fixes the drift — both scripts now use the same escaping.
  • labels.jslabelExists / addLabel / dropLabel / swapLabel, preserving the existing fail-soft discipline (never auto-create; warn and skip when absent).
  • comment.jsfindComment / upsertComment / deleteComment (find-by-marker, paginated lookup).

Both check scripts now require() these helpers instead of carrying their own copies. No behaviour change — the same API calls are made in the same order with the same fail-soft handling.

Target branch

  • This PR targets dev, not main.

Linked Issue

Fixes #2453

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets dev
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
  • I ran node --check on all 5 files (2 scripts + 3 lib modules) — all pass.

How to Test

  1. node --check .github/scripts/check-pr-description.js — passes.
  2. node --check .github/scripts/check-issue-description.js — passes.
  3. node --check .github/scripts/lib/markdown.js && node --check .github/scripts/lib/labels.js && node --check .github/scripts/lib/comment.js — all pass.
  4. The CI workflows that call these scripts (ci.yml → "Check PR description" and issue-description-check.yml → "Check Issue description") will exercise the refactored code on this PR itself.

Visual / UI changes — REQUIRED if you touched anything that renders

Not applicable: CI/automation scripts only.

  • I am not an LLM agent submitting a bulk PR. If you are, please open an issue describing the problem first — bulk auto-generated PRs that don't match the project's visual style are closed on sight, even when the underlying fix is correct.

Copilot AI review requested due to automatic review settings July 12, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract shared helpers from the description-check scripts (.github/scripts/lib/)

3 participants